#247 Remove primefaces dependency #248

Merged
romanov73 merged 9 commits from 247-restore-mvc into dev 2024-05-02 13:10:01 +04:00
65 changed files with 470 additions and 686 deletions
Showing only changes of commit a9e8336986 - Show all commits

View File

@ -83,9 +83,10 @@ dependencies {
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-security' 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-aop'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-mail' 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-data-jpa'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-thymeleaf' 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: 'nz.net.ultraq.thymeleaf', name: 'thymeleaf-layout-dialect'
implementation group: 'org.thymeleaf.extras', name: 'thymeleaf-extras-springsecurity6' implementation group: 'org.thymeleaf.extras', name: 'thymeleaf-extras-springsecurity6'
implementation group: 'com.fasterxml.jackson.module', name: 'jackson-module-afterburner' 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.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: 'com.mattbertolini', name: 'liquibase-slf4j', version: '2.0.0'
implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.7' 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.npm', name: 'jquery.easing', version: '1.4.1'
implementation group: 'org.webjars', name: 'font-awesome', version: '4.7.0' implementation group: 'org.webjars', name: 'font-awesome', version: '4.7.0'
implementation group: 'io.springfox', name: 'springfox-swagger2', version: '2.6.0' implementation group: 'org.springdoc', name: 'springdoc-openapi-ui', version: '1.8.0'
implementation group: 'io.springfox', name: 'springfox-swagger-ui', version: '2.6.0'
implementation group: 'net.sourceforge.htmlunit', name: 'htmlunit', version: '2.35.0' implementation group: 'net.sourceforge.htmlunit', name: 'htmlunit', version: '2.35.0'
implementation group: 'xalan', name: 'xalan', version: '2.7.2' implementation group: 'xalan', name: 'xalan', version: '2.7.2'

View File

@ -1,6 +1,8 @@
package ru.ulstu.conference.controller; package ru.ulstu.conference.controller;
import io.swagger.v3.oas.annotations.Hidden;
import jakarta.validation.Valid;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap; import org.springframework.ui.ModelMap;
import org.springframework.validation.Errors; 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.model.ConferenceUser;
import ru.ulstu.conference.service.ConferenceService; import ru.ulstu.conference.service.ConferenceService;
import ru.ulstu.user.model.User; import ru.ulstu.user.model.User;
import springfox.documentation.annotations.ApiIgnore;
import javax.validation.Valid;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
@ -29,7 +29,7 @@ import static ru.ulstu.core.controller.Navigation.REDIRECT_TO;
@Controller() @Controller()
@RequestMapping(value = "/conferences") @RequestMapping(value = "/conferences")
@ApiIgnore @Hidden
public class ConferenceController { public class ConferenceController {
private final ConferenceService conferenceService; private final ConferenceService conferenceService;

View File

@ -1,5 +1,17 @@
package ru.ulstu.conference.model; 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.Fetch;
import org.hibernate.annotations.FetchMode; import org.hibernate.annotations.FetchMode;
import org.springframework.format.annotation.DateTimeFormat; 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.timeline.model.Event;
import ru.ulstu.user.model.User; 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.ArrayList;
import java.util.Comparator; import java.util.Comparator;
import java.util.Date; import java.util.Date;

View File

@ -2,16 +2,16 @@ package ru.ulstu.conference.model;
import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty; 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 org.springframework.format.annotation.DateTimeFormat;
import ru.ulstu.core.model.BaseEntity; import ru.ulstu.core.model.BaseEntity;
import ru.ulstu.deadline.model.Deadline; import ru.ulstu.deadline.model.Deadline;
import ru.ulstu.name.NameContainer; import ru.ulstu.name.NameContainer;
import ru.ulstu.paper.model.Paper; 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.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;

View File

@ -2,18 +2,17 @@ package ru.ulstu.conference.model;
import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty; 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.core.model.BaseEntity;
import ru.ulstu.user.model.User; 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 @Entity
@Table(name = "users_conference") @Table(name = "users_conference")
public class ConferenceUser extends BaseEntity { public class ConferenceUser extends BaseEntity {
@ -70,7 +69,6 @@ public class ConferenceUser extends BaseEntity {
public ConferenceUser(User user) { public ConferenceUser(User user) {
this.user = user; this.user = user;
this.deposit = Deposit.REPORT; this.deposit = Deposit.REPORT;
this.participation = Participation.INTRAMURAL;
} }
@JsonCreator @JsonCreator

View File

@ -13,7 +13,7 @@ import java.util.List;
public interface ConferenceRepository extends JpaRepository<Conference, Integer>, BaseRepository { public interface ConferenceRepository extends JpaRepository<Conference, Integer>, BaseRepository {
@Query("SELECT c FROM Conference c LEFT JOIN c.users u WHERE (:user IS NULL OR u.user = :user) " + @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<Conference> findByUserAndYear(@Param("user") User user, @Param("year") Integer year); List<Conference> findByUserAndYear(@Param("user") User user, @Param("year") Integer year);
@Query("SELECT c FROM Conference c WHERE c.beginDate > :date") @Query("SELECT c FROM Conference c WHERE c.beginDate > :date")

View File

@ -1,6 +1,5 @@
package ru.ulstu.conference.service; package ru.ulstu.conference.service;
import com.google.common.collect.ImmutableMap;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import ru.ulstu.conference.model.Conference; import ru.ulstu.conference.model.Conference;
import ru.ulstu.core.util.DateUtils; import ru.ulstu.core.util.DateUtils;
@ -57,22 +56,22 @@ public class ConferenceNotificationService {
} }
private void sendMessageDeadline(Conference conference) { private void sendMessageDeadline(Conference conference) {
Map<String, Object> variables = ImmutableMap.of("conference", conference); Map<String, Object> variables = Map.of("conference", conference);
sendForAllParticipants(variables, conference, TEMPLATE_DEADLINE, String.format(TITLE_DEADLINE, conference.getTitle())); sendForAllParticipants(variables, conference, TEMPLATE_DEADLINE, String.format(TITLE_DEADLINE, conference.getTitle()));
} }
public void sendCreateNotification(Conference conference) { public void sendCreateNotification(Conference conference) {
Map<String, Object> variables = ImmutableMap.of("conference", conference); Map<String, Object> variables = Map.of("conference", conference);
sendForAllUsers(variables, String.format(TITLE_CREATE, conference.getTitle())); sendForAllUsers(variables, String.format(TITLE_CREATE, conference.getTitle()));
} }
public void updateDeadlineNotification(Conference conference) { public void updateDeadlineNotification(Conference conference) {
Map<String, Object> variables = ImmutableMap.of("conference", conference); Map<String, Object> variables = Map.of("conference", conference);
sendForAllParticipants(variables, conference, TEMPLATE_UPDATE_DEADLINES, String.format(TITLE_UPDATE_DEADLINES, conference.getTitle())); sendForAllParticipants(variables, conference, TEMPLATE_UPDATE_DEADLINES, String.format(TITLE_UPDATE_DEADLINES, conference.getTitle()));
} }
public void updateConferencesDatesNotification(Conference conference, Date oldBeginDate, Date oldEndDate) { public void updateConferencesDatesNotification(Conference conference, Date oldBeginDate, Date oldEndDate) {
Map<String, Object> variables = ImmutableMap.of("conference", conference, "oldBeginDate", oldBeginDate, "oldEndDate", oldEndDate); Map<String, Object> variables = Map.of("conference", conference, "oldBeginDate", oldBeginDate, "oldEndDate", oldEndDate);
sendForAllParticipants(variables, conference, TEMPLATE_UPDATE_DATES, String.format(TITLE_UPDATE_DATES, conference.getTitle())); 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) { private void sendMessagePing(Conference conference) {
Map<String, Object> variables = ImmutableMap.of("conference", conference); Map<String, Object> variables = Map.of("conference", conference);
sendForAllParticipants(variables, conference, TEMPLATE_PING, String.format(TITLE_PING, conference.getTitle())); sendForAllParticipants(variables, conference, TEMPLATE_PING, String.format(TITLE_PING, conference.getTitle()));
} }
} }

View File

@ -81,7 +81,7 @@ public class ConferenceService extends BaseService {
public List<Conference> findAll() { public List<Conference> findAll() {
return conferenceRepository.findAll(new Sort(Sort.Direction.DESC, "beginDate")); return conferenceRepository.findAll(Sort.by(Sort.Direction.DESC, "beginDate"));
} }
public List<ConferenceDto> findAllDto() { public List<ConferenceDto> findAllDto() {

View File

@ -1,11 +1,10 @@
package ru.ulstu.configuration; package ru.ulstu.configuration;
import jakarta.validation.constraints.NotBlank;
import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import javax.validation.constraints.NotBlank;
@Component @Component
@ConfigurationProperties(prefix = "ng-tracker") @ConfigurationProperties(prefix = "ng-tracker")
@Validated @Validated

View File

@ -1,10 +1,10 @@
package ru.ulstu.configuration; 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.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.thymeleaf.extras.springsecurity5.dialect.SpringSecurityDialect; import org.thymeleaf.extras.springsecurity6.dialect.SpringSecurityDialect;
import org.thymeleaf.spring5.SpringTemplateEngine; import org.thymeleaf.spring6.SpringTemplateEngine;
import org.thymeleaf.templateresolver.ClassLoaderTemplateResolver; import org.thymeleaf.templateresolver.ClassLoaderTemplateResolver;
import org.thymeleaf.templateresolver.ITemplateResolver; import org.thymeleaf.templateresolver.ITemplateResolver;

View File

@ -9,22 +9,12 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment; import org.springframework.core.env.Environment;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; 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.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.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer;
import org.springframework.security.config.oauth2.client.CommonOAuth2Provider; import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.oauth2.client.endpoint.DefaultAuthorizationCodeTokenResponseClient; import org.springframework.security.web.SecurityFilterChain;
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.authentication.AuthenticationFailureHandler; import org.springframework.security.web.authentication.AuthenticationFailureHandler;
import org.springframework.security.web.authentication.AuthenticationSuccessHandler; import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
import org.springframework.security.web.authentication.logout.LogoutSuccessHandler; 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.model.UserRoleConstants;
import ru.ulstu.user.service.UserService; import ru.ulstu.user.service.UserService;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
@Configuration @Configuration
@EnableWebSecurity @EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled = true, securedEnabled = true) public class SecurityConfiguration {
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
private final Logger log = LoggerFactory.getLogger(SecurityConfiguration.class); private final Logger log = LoggerFactory.getLogger(SecurityConfiguration.class);
private static List<String> clients = Arrays.asList("google");
private static final String CLIENT_PROPERTY_KEY
= "spring.security.oauth2.client.registration.";
@Autowired @Autowired
private Environment env; private Environment env;
@ -75,104 +57,60 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
this.authenticationFailureHandler = authenticationFailureHandler; this.authenticationFailureHandler = authenticationFailureHandler;
} }
@Override @Bean
protected void configure(HttpSecurity http) throws Exception { public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
http.csrf().disable(); http.csrf(AbstractHttpConfigurer::disable);
if (applicationProperties.isDevMode()) { if (applicationProperties.isDevMode()) {
log.debug("Security disabled"); log.debug("Security disabled");
http.authorizeRequests() http.authorizeHttpRequests((authz) -> authz
.anyRequest() .anyRequest()
.permitAll(); .permitAll()
http.anonymous() );
http.anonymous((anonymousCustomizer) -> anonymousCustomizer
.principal("admin") .principal("admin")
.authorities(UserRoleConstants.ADMIN); .authorities(UserRoleConstants.ADMIN)
);
} else { } else {
log.debug("Security enabled"); log.debug("Security enabled");
http.authorizeRequests() http.authorizeHttpRequests((authz) -> authz
.antMatchers(UserController.ACTIVATE_URL).permitAll() .requestMatchers(UserController.ACTIVATE_URL).permitAll()
.antMatchers(Constants.PASSWORD_RESET_REQUEST_PAGE).permitAll() .requestMatchers(Constants.PASSWORD_RESET_REQUEST_PAGE).permitAll()
.antMatchers(Constants.PASSWORD_RESET_PAGE).permitAll() .requestMatchers(Constants.PASSWORD_RESET_PAGE).permitAll()
.antMatchers("/users/block").permitAll() .requestMatchers("/users/block").permitAll()
.antMatchers(UserController.URL + UserController.REGISTER_URL).permitAll() .requestMatchers(UserController.URL + UserController.REGISTER_URL).permitAll()
.antMatchers(UserController.URL + UserController.ACTIVATE_URL).permitAll() .requestMatchers(UserController.URL + UserController.ACTIVATE_URL).permitAll()
.antMatchers(UserController.URL + UserController.PASSWORD_RESET_REQUEST_URL).permitAll() .requestMatchers(UserController.URL + UserController.PASSWORD_RESET_REQUEST_URL).permitAll()
.antMatchers(UserController.URL + UserController.PASSWORD_RESET_URL).permitAll() .requestMatchers(UserController.URL + UserController.PASSWORD_RESET_URL).permitAll()
.antMatchers("/swagger-ui.html").hasAuthority(UserRoleConstants.ADMIN) .requestMatchers("/swagger-ui.html").hasAuthority(UserRoleConstants.ADMIN)
.anyRequest().authenticated() .anyRequest().authenticated())
.and() .formLogin((formLoginCustomizer) -> formLoginCustomizer
.formLogin()
.loginPage("/login") .loginPage("/login")
.successHandler(authenticationSuccessHandler) .successHandler(authenticationSuccessHandler)
.failureHandler(authenticationFailureHandler) .failureHandler(authenticationFailureHandler)
.permitAll() .permitAll()
.and() )
.logout() .logout((logoutCustomizer) -> logoutCustomizer
.logoutSuccessHandler(logoutSuccessHandler) .logoutSuccessHandler(logoutSuccessHandler)
.logoutSuccessUrl(Constants.LOGOUT_URL) .logoutSuccessUrl(Constants.LOGOUT_URL)
.invalidateHttpSession(false) .invalidateHttpSession(false)
.clearAuthentication(true) .clearAuthentication(true)
.deleteCookies(Constants.COOKIES_NAME) .deleteCookies(Constants.COOKIES_NAME)
.permitAll(); .permitAll()
http.csrf().disable(); );
} http.csrf(AbstractHttpConfigurer::disable);
if (applicationProperties.isUseHttps()) {
http.portMapper()
.http(httpPort)
.mapsTo(httpsPort)
.and()
.requiresChannel()
.anyRequest()
.requiresSecure();
} }
return http.build();
} }
@Bean @Bean
public AuthorizationRequestRepository<OAuth2AuthorizationRequest> authorizationRequestRepository() { public WebSecurityCustomizer webSecurityCustomizer() {
return new HttpSessionOAuth2AuthorizationRequestRepository(); return (web) -> web.ignoring()
} .requestMatchers("/css/**",
"/javax.faces.resource/**",
@Bean "/js/**",
public OAuth2AccessTokenResponseClient<OAuth2AuthorizationCodeGrantRequest> accessTokenResponseClient() { "/templates/**",
DefaultAuthorizationCodeTokenResponseClient accessTokenResponseClient = new DefaultAuthorizationCodeTokenResponseClient(); "/webjars/**",
return accessTokenResponseClient; "/img/**");
}
//@Bean
public ClientRegistrationRepository clientRegistrationRepository() {
List<ClientRegistration> 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/**");
} }
@Autowired @Autowired

View File

@ -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();
}
}

View File

@ -15,7 +15,7 @@ public class OffsetablePageRequest implements Pageable, Serializable {
} }
public OffsetablePageRequest(long offset, int count, Sort.Direction direction, String... properties) { 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) { public OffsetablePageRequest(long offset, int count, Sort sort) {
@ -30,6 +30,12 @@ public class OffsetablePageRequest implements Pageable, Serializable {
this.sort = sort; this.sort = sort;
} }
@Override
public Pageable withPage(int pageNumber) {
//TODO
return null;
}
@Override @Override
public Sort getSort() { public Sort getSort() {
return sort; return sort;

View File

@ -1,12 +1,12 @@
package ru.ulstu.core.model; 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.core.AuthenticationException;
import org.springframework.security.web.authentication.AuthenticationFailureHandler; import org.springframework.security.web.authentication.AuthenticationFailureHandler;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import ru.ulstu.user.error.UserBlockedException; import ru.ulstu.user.error.UserBlockedException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
@Component @Component

View File

@ -1,11 +1,12 @@
package ru.ulstu.core.model; package ru.ulstu.core.model;
import javax.persistence.GeneratedValue; import jakarta.persistence.GeneratedValue;
import javax.persistence.GenerationType; import jakarta.persistence.GenerationType;
import javax.persistence.Id; import jakarta.persistence.Id;
import javax.persistence.MappedSuperclass; import jakarta.persistence.MappedSuperclass;
import javax.persistence.Version; import jakarta.persistence.Version;
import javax.validation.constraints.NotNull; import jakarta.validation.constraints.NotNull;
import java.io.Serializable; import java.io.Serializable;
@MappedSuperclass @MappedSuperclass

View File

@ -1,9 +1,9 @@
package ru.ulstu.core.repository; package ru.ulstu.core.repository;
import jakarta.persistence.EntityManager;
import org.springframework.data.jpa.repository.support.JpaEntityInformation; import org.springframework.data.jpa.repository.support.JpaEntityInformation;
import org.springframework.data.jpa.repository.support.SimpleJpaRepository; import org.springframework.data.jpa.repository.support.SimpleJpaRepository;
import javax.persistence.EntityManager;
import java.io.Serializable; import java.io.Serializable;
public class JpaDetachableRepositoryImpl<T, ID extends Serializable> extends SimpleJpaRepository<T, ID> public class JpaDetachableRepositoryImpl<T, ID extends Serializable> extends SimpleJpaRepository<T, ID>

View File

@ -2,15 +2,15 @@ package ru.ulstu.deadline.model;
import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty; 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 org.springframework.format.annotation.DateTimeFormat;
import ru.ulstu.core.model.BaseEntity; import ru.ulstu.core.model.BaseEntity;
import ru.ulstu.user.model.User; 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.Date;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;

View File

@ -1,10 +1,10 @@
package ru.ulstu.file.model; package ru.ulstu.file.model;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Table;
import ru.ulstu.core.model.BaseEntity; import ru.ulstu.core.model.BaseEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date; import java.util.Date;
@Entity @Entity

View File

@ -1,5 +1,7 @@
package ru.ulstu.grant.controller; package ru.ulstu.grant.controller;
import io.swagger.v3.oas.annotations.Hidden;
import jakarta.validation.Valid;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap; import org.springframework.ui.ModelMap;
import org.springframework.validation.Errors; import org.springframework.validation.Errors;
@ -16,9 +18,7 @@ import ru.ulstu.grant.model.GrantDto;
import ru.ulstu.grant.service.GrantService; import ru.ulstu.grant.service.GrantService;
import ru.ulstu.paper.model.PaperDto; import ru.ulstu.paper.model.PaperDto;
import ru.ulstu.user.model.User; import ru.ulstu.user.model.User;
import springfox.documentation.annotations.ApiIgnore;
import javax.validation.Valid;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
@ -29,7 +29,7 @@ import static ru.ulstu.core.controller.Navigation.REDIRECT_TO;
@Controller() @Controller()
@RequestMapping(value = "/grants") @RequestMapping(value = "/grants")
@ApiIgnore @Hidden
public class GrantController { public class GrantController {
private final GrantService grantService; private final GrantService grantService;

View File

@ -1,5 +1,20 @@
package ru.ulstu.grant.model; 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.Fetch;
import org.hibernate.annotations.FetchMode; import org.hibernate.annotations.FetchMode;
import ru.ulstu.core.model.BaseEntity; 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.timeline.model.Event;
import ru.ulstu.user.model.User; 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.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;

View File

@ -2,6 +2,7 @@ package ru.ulstu.grant.model;
import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import jakarta.validation.constraints.NotEmpty;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import ru.ulstu.deadline.model.Deadline; import ru.ulstu.deadline.model.Deadline;
import ru.ulstu.file.model.FileDataDto; 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.project.model.ProjectDto;
import ru.ulstu.user.model.UserDto; import ru.ulstu.user.model.UserDto;
import javax.validation.constraints.NotEmpty;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;

View File

@ -1,6 +1,5 @@
package ru.ulstu.grant.service; package ru.ulstu.grant.service;
import com.google.common.collect.ImmutableMap;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import ru.ulstu.core.util.DateUtils; import ru.ulstu.core.util.DateUtils;
import ru.ulstu.grant.model.Grant; import ru.ulstu.grant.model.Grant;
@ -46,22 +45,22 @@ public class GrantNotificationService {
} }
private void sendMessageDeadline(Grant grant) { private void sendMessageDeadline(Grant grant) {
Map<String, Object> variables = ImmutableMap.of("grant", grant); Map<String, Object> variables = Map.of("grant", grant);
sendForAllAuthors(variables, grant, TEMPLATE_DEADLINE, String.format(TITLE_DEADLINE, grant.getTitle())); sendForAllAuthors(variables, grant, TEMPLATE_DEADLINE, String.format(TITLE_DEADLINE, grant.getTitle()));
} }
public void sendCreateNotification(Grant grant) { public void sendCreateNotification(Grant grant) {
Map<String, Object> variables = ImmutableMap.of("grant", grant); Map<String, Object> variables = Map.of("grant", grant);
sendForAllAuthors(variables, grant, TEMPLATE_CREATE, String.format(TITLE_CREATE, grant.getTitle())); sendForAllAuthors(variables, grant, TEMPLATE_CREATE, String.format(TITLE_CREATE, grant.getTitle()));
} }
public void sendAuthorsChangeNotification(Grant grant, Set<User> oldAuthors) { public void sendAuthorsChangeNotification(Grant grant, Set<User> oldAuthors) {
Map<String, Object> variables = ImmutableMap.of("grant", grant, "oldAuthors", oldAuthors); Map<String, Object> variables = Map.of("grant", grant, "oldAuthors", oldAuthors);
sendForAllAuthors(variables, grant, TEMPLATE_AUTHORS_CHANGED, String.format(TITLE_AUTHORS_CHANGED, grant.getTitle())); sendForAllAuthors(variables, grant, TEMPLATE_AUTHORS_CHANGED, String.format(TITLE_AUTHORS_CHANGED, grant.getTitle()));
} }
public void sendLeaderChangeNotification(Grant grant, User oldLeader) { public void sendLeaderChangeNotification(Grant grant, User oldLeader) {
Map<String, Object> variables = ImmutableMap.of("grant", grant, "oldLeader", oldLeader); Map<String, Object> variables = Map.of("grant", grant, "oldLeader", oldLeader);
sendForAllAuthors(variables, grant, TEMPLATE_LEADER_CHANGED, String.format(TITLE_LEADER_CHANGED, grant.getTitle())); sendForAllAuthors(variables, grant, TEMPLATE_LEADER_CHANGED, String.format(TITLE_LEADER_CHANGED, grant.getTitle()));
} }

View File

@ -1,16 +1,16 @@
package ru.ulstu.index.controller; package ru.ulstu.index.controller;
import io.swagger.v3.oas.annotations.Hidden;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap; import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import ru.ulstu.core.controller.AdviceController; import ru.ulstu.core.controller.AdviceController;
import ru.ulstu.user.service.UserService; import ru.ulstu.user.service.UserService;
import springfox.documentation.annotations.ApiIgnore;
@Controller() @Controller()
@RequestMapping(value = "/index") @RequestMapping(value = "/index")
@ApiIgnore @Hidden
public class IndexController extends AdviceController { public class IndexController extends AdviceController {
public IndexController(UserService userService) { public IndexController(UserService userService) {
super(userService); super(userService);

View File

@ -1,14 +1,14 @@
package ru.ulstu.odin.model; package ru.ulstu.odin.model;
import com.fasterxml.jackson.annotation.JsonProperty; 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.core.error.OdinException;
import ru.ulstu.odin.model.annotation.OdinCaption; import ru.ulstu.odin.model.annotation.OdinCaption;
import ru.ulstu.odin.model.annotation.OdinReadOnly; import ru.ulstu.odin.model.annotation.OdinReadOnly;
import ru.ulstu.odin.model.annotation.OdinVisible; 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.annotation.Annotation;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;

View File

@ -1,10 +1,10 @@
package ru.ulstu.odin.model; 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;
import ru.ulstu.odin.model.annotation.OdinString.OdinStringType; import ru.ulstu.odin.model.annotation.OdinString.OdinStringType;
import javax.validation.constraints.Email;
import javax.validation.constraints.Size;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import static ru.ulstu.odin.model.annotation.OdinString.OdinStringType.EMAIL; import static ru.ulstu.odin.model.annotation.OdinString.OdinStringType.EMAIL;

View File

@ -1,5 +1,7 @@
package ru.ulstu.paper.controller; 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.HttpHeaders;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; 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.LatexService;
import ru.ulstu.paper.service.PaperService; import ru.ulstu.paper.service.PaperService;
import ru.ulstu.user.model.User; import ru.ulstu.user.model.User;
import springfox.documentation.annotations.ApiIgnore;
import javax.validation.Valid;
import java.io.IOException; import java.io.IOException;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.util.ArrayList; import java.util.ArrayList;
@ -37,7 +37,7 @@ import static org.springframework.util.StringUtils.isEmpty;
@Controller() @Controller()
@RequestMapping(value = "/papers") @RequestMapping(value = "/papers")
@ApiIgnore @Hidden
public class PaperController { public class PaperController {
private final PaperService paperService; private final PaperService paperService;
private final ConferenceService conferenceService; private final ConferenceService conferenceService;

View File

@ -1,5 +1,6 @@
package ru.ulstu.paper.controller; package ru.ulstu.paper.controller;
import jakarta.validation.Valid;
import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable; 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.model.ReferenceDto;
import ru.ulstu.paper.service.PaperService; import ru.ulstu.paper.service.PaperService;
import javax.validation.Valid;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;

View File

@ -1,5 +1,20 @@
package ru.ulstu.paper.model; 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.Fetch;
import org.hibernate.annotations.FetchMode; import org.hibernate.annotations.FetchMode;
import ru.ulstu.conference.model.Conference; 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.timeline.model.Event;
import ru.ulstu.user.model.User; 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.ArrayList;
import java.util.Comparator; import java.util.Comparator;
import java.util.Date; import java.util.Date;

View File

@ -2,14 +2,14 @@ package ru.ulstu.paper.model;
import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.Size;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import ru.ulstu.core.model.BaseEntity; import ru.ulstu.core.model.BaseEntity;
import ru.ulstu.deadline.model.Deadline; import ru.ulstu.deadline.model.Deadline;
import ru.ulstu.file.model.FileDataDto; import ru.ulstu.file.model.FileDataDto;
import ru.ulstu.user.model.UserDto; import ru.ulstu.user.model.UserDto;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.Size;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;

View File

@ -1,12 +1,11 @@
package ru.ulstu.paper.model; 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 ru.ulstu.core.model.BaseEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
@Entity @Entity
public class Reference extends BaseEntity { public class Reference extends BaseEntity {

View File

@ -1,6 +1,5 @@
package ru.ulstu.paper.service; package ru.ulstu.paper.service;
import com.google.common.collect.ImmutableMap;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import ru.ulstu.core.util.DateUtils; import ru.ulstu.core.util.DateUtils;
import ru.ulstu.paper.model.Paper; import ru.ulstu.paper.model.Paper;
@ -46,22 +45,22 @@ public class PaperNotificationService {
} }
private void sendMessageDeadline(Paper paper) { private void sendMessageDeadline(Paper paper) {
Map<String, Object> variables = ImmutableMap.of("paper", paper); Map<String, Object> variables = Map.of("paper", paper);
sendForAllAuhtors(variables, paper, TEMPLATE_DEADLINE, TITLE_DEADLINE); sendForAllAuhtors(variables, paper, TEMPLATE_DEADLINE, TITLE_DEADLINE);
} }
public void sendCreateNotification(Paper paper) { public void sendCreateNotification(Paper paper) {
Map<String, Object> variables = ImmutableMap.of("paper", paper); Map<String, Object> variables = Map.of("paper", paper);
sendForAllAuhtors(variables, paper, TEMPLATE_CREATE, TITLE_CREATE); sendForAllAuhtors(variables, paper, TEMPLATE_CREATE, TITLE_CREATE);
} }
public void statusChangeNotification(Paper paper, Paper.PaperStatus oldStatus) { public void statusChangeNotification(Paper paper, Paper.PaperStatus oldStatus) {
Map<String, Object> variables = ImmutableMap.of("paper", paper, "oldStatus", oldStatus); Map<String, Object> variables = Map.of("paper", paper, "oldStatus", oldStatus);
sendForAllAuhtors(variables, paper, TEMPLATE_STATUS_CHANGED, TITLE_STATUS_CHANGED); sendForAllAuhtors(variables, paper, TEMPLATE_STATUS_CHANGED, TITLE_STATUS_CHANGED);
} }
public void sendFailedNotification(Paper paper, Paper.PaperStatus oldStatus) { public void sendFailedNotification(Paper paper, Paper.PaperStatus oldStatus) {
Map<String, Object> variables = ImmutableMap.of("paper", paper, "oldStatus", oldStatus); Map<String, Object> variables = Map.of("paper", paper, "oldStatus", oldStatus);
sendForAllAuhtors(variables, paper, TEMPLATE_FAILED, TITLE_FAILED); sendForAllAuhtors(variables, paper, TEMPLATE_FAILED, TITLE_FAILED);
} }

View File

@ -1,8 +1,17 @@
package ru.ulstu.ping.model; 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.Any;
import org.hibernate.annotations.AnyMetaDef; import org.hibernate.annotations.AnyDiscriminator;
import org.hibernate.annotations.MetaValue; import org.hibernate.annotations.AnyDiscriminatorValue;
import org.hibernate.annotations.AnyKeyJavaClass;
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat;
import ru.ulstu.conference.model.Conference; import ru.ulstu.conference.model.Conference;
import ru.ulstu.core.model.BaseEntity; 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.project.model.Project;
import ru.ulstu.user.model.User; 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; import java.util.Date;
@Entity @Entity
@ -36,20 +37,15 @@ public class Ping extends BaseEntity {
@Column(name = "activity_type", insertable = false, updatable = false) @Column(name = "activity_type", insertable = false, updatable = false)
private String activityType; private String activityType;
@Any( @Any
metaColumn = @Column(name = "activity_type"), @AnyDiscriminator(DiscriminatorType.STRING)
fetch = FetchType.LAZY @AnyKeyJavaClass(Integer.class)
)
@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")
}
)
@JoinColumn(name = "activity_id") @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; private UserActivity activity;
public Ping() { public Ping() {

View File

@ -1,6 +1,5 @@
package ru.ulstu.ping.service; package ru.ulstu.ping.service;
import com.google.common.collect.ImmutableMap;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
@ -15,6 +14,7 @@ import ru.ulstu.user.service.MailService;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Set; import java.util.Set;
@Service @Service
@ -51,7 +51,7 @@ public class PingScheduler {
} }
for (PingInfo pingInfo : pingInfos) { for (PingInfo pingInfo : pingInfos) {
mailService.sendEmailFromTemplate(ImmutableMap.of("pings", pingInfo.getPings()), mailService.sendEmailFromTemplate(Map.of("pings", pingInfo.getPings()),
pingInfo.getUser(), "pingsInfoWeekEmail", PING_MAIL_SUBJECT); pingInfo.getUser(), "pingsInfoWeekEmail", PING_MAIL_SUBJECT);
} }
} }

View File

@ -28,7 +28,7 @@ public class PingService {
@Transactional @Transactional
public Ping addPing(UserActivity activity) throws IOException { public Ping addPing(UserActivity activity) throws IOException {
Ping newPing = new Ping(new Date(), userService.getCurrentUser()); Ping newPing = new Ping(new Date(), userService.getCurrentUser());
newPing.setActivity(activity); //newPing.setActivity(activity);
return pingRepository.save(newPing); return pingRepository.save(newPing);
} }

View File

@ -1,5 +1,7 @@
package ru.ulstu.project.controller; package ru.ulstu.project.controller;
import io.swagger.v3.oas.annotations.Hidden;
import jakarta.validation.Valid;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap; import org.springframework.ui.ModelMap;
import org.springframework.validation.Errors; 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.model.ProjectDto;
import ru.ulstu.project.service.ProjectService; import ru.ulstu.project.service.ProjectService;
import ru.ulstu.user.model.User; import ru.ulstu.user.model.User;
import springfox.documentation.annotations.ApiIgnore;
import javax.validation.Valid;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -27,7 +27,7 @@ import static org.springframework.util.StringUtils.isEmpty;
@Controller() @Controller()
@RequestMapping(value = "/projects") @RequestMapping(value = "/projects")
@ApiIgnore @Hidden
public class ProjectController { public class ProjectController {
private final ProjectService projectService; private final ProjectService projectService;

View File

@ -1,5 +1,18 @@
package ru.ulstu.project.model; 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.Fetch;
import org.hibernate.annotations.FetchMode; import org.hibernate.annotations.FetchMode;
import ru.ulstu.core.model.BaseEntity; 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.timeline.model.Event;
import ru.ulstu.user.model.User; 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.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;

View File

@ -2,6 +2,7 @@ package ru.ulstu.project.model;
import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import jakarta.validation.constraints.NotEmpty;
import org.thymeleaf.util.StringUtils; import org.thymeleaf.util.StringUtils;
import ru.ulstu.deadline.model.Deadline; import ru.ulstu.deadline.model.Deadline;
import ru.ulstu.file.model.FileDataDto; 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.User;
import ru.ulstu.user.model.UserDto; import ru.ulstu.user.model.UserDto;
import javax.validation.constraints.NotEmpty;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;

View File

@ -1,5 +1,7 @@
package ru.ulstu.students.controller; package ru.ulstu.students.controller;
import io.swagger.v3.oas.annotations.Hidden;
import jakarta.validation.Valid;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap; import org.springframework.ui.ModelMap;
import org.springframework.validation.Errors; 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.model.TaskFilterDto;
import ru.ulstu.students.service.TaskService; import ru.ulstu.students.service.TaskService;
import ru.ulstu.tags.model.Tag; import ru.ulstu.tags.model.Tag;
import springfox.documentation.annotations.ApiIgnore;
import javax.validation.Valid;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -29,7 +29,7 @@ import static ru.ulstu.students.controller.Navigation.TASK_PAGE;
@Controller() @Controller()
@RequestMapping(value = "/students") @RequestMapping(value = "/students")
@ApiIgnore @Hidden
public class TaskController { public class TaskController {
private final TaskService taskService; private final TaskService taskService;

View File

@ -1,14 +1,14 @@
package ru.ulstu.students.model; 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 org.springframework.format.annotation.DateTimeFormat;
import ru.ulstu.core.model.BaseEntity; 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; import java.util.Date;
@Entity @Entity

View File

@ -1,5 +1,19 @@
package ru.ulstu.students.model; 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.Fetch;
import org.hibernate.annotations.FetchMode; import org.hibernate.annotations.FetchMode;
import ru.ulstu.core.model.BaseEntity; 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.timeline.model.Event;
import ru.ulstu.user.model.User; 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.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Date; import java.util.Date;

View File

@ -2,11 +2,11 @@ package ru.ulstu.students.model;
import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import jakarta.validation.constraints.NotEmpty;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import ru.ulstu.deadline.model.Deadline; import ru.ulstu.deadline.model.Deadline;
import ru.ulstu.tags.model.Tag; import ru.ulstu.tags.model.Tag;
import javax.validation.constraints.NotEmpty;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;

View File

@ -11,16 +11,16 @@ import java.util.List;
public interface TaskRepository extends JpaRepository<Task, Integer> { public interface TaskRepository extends JpaRepository<Task, Integer> {
@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<Task> filterNew(@Param("status") Task.TaskStatus status, @Param("tag") Tag tag); List<Task> 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<Task> filterOld(@Param("status") Task.TaskStatus status, @Param("tag") Tag tag); List<Task> 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<Task> findByTag(@Param("tag") Tag tag); List<Task> 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<Task> findAllYear(@Param("date") Date date); List<Task> findAllYear(@Param("date") Date date);

View File

@ -55,7 +55,7 @@ public class TaskService {
} }
public List<Task> findAll() { public List<Task> findAll() {
return taskRepository.findAll(new Sort(Sort.Direction.DESC, "createDate")); return taskRepository.findAll(Sort.by(Sort.Direction.DESC, "createDate"));
} }
public List<TaskDto> findAllDto() { public List<TaskDto> findAllDto() {

View File

@ -2,13 +2,13 @@ package ru.ulstu.tags.model;
import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty; 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 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; import java.util.Objects;
@Entity @Entity

View File

@ -1,5 +1,6 @@
package ru.ulstu.timeline.controller; package ru.ulstu.timeline.controller;
import jakarta.validation.Valid;
import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable; 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.model.EventDto;
import ru.ulstu.timeline.service.EventService; import ru.ulstu.timeline.service.EventService;
import javax.validation.Valid;
import java.util.List; import java.util.List;
@RestController @RestController

View File

@ -1,5 +1,19 @@
package ru.ulstu.timeline.model; 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.conference.model.Conference;
import ru.ulstu.core.model.BaseEntity; import ru.ulstu.core.model.BaseEntity;
import ru.ulstu.grant.model.Grant; 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.students.model.Task;
import ru.ulstu.user.model.User; 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.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;

View File

@ -2,6 +2,8 @@ package ru.ulstu.timeline.model;
import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty; 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.conference.model.ConferenceDto;
import ru.ulstu.grant.model.GrantDto; import ru.ulstu.grant.model.GrantDto;
import ru.ulstu.paper.model.PaperDto; 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.students.model.TaskDto;
import ru.ulstu.user.model.UserDto; import ru.ulstu.user.model.UserDto;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;

View File

@ -1,11 +1,11 @@
package ru.ulstu.timeline.model; 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 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.ArrayList;
import java.util.List; import java.util.List;

View File

@ -1,6 +1,5 @@
package ru.ulstu.timeline.service; package ru.ulstu.timeline.service;
import com.google.common.collect.ImmutableMap;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
@ -31,7 +30,7 @@ public class EventScheduler {
public void sendNotifications() { public void sendNotifications() {
List<Event> events = eventService.findByCurrentDate(); List<Event> events = eventService.findByCurrentDate();
events.forEach(event -> { events.forEach(event -> {
Map<String, Object> variables = ImmutableMap.of("description", event.getDescription()); Map<String, Object> variables = Map.of("description", event.getDescription());
event.getRecipients() event.getRecipients()
.forEach(recipient -> mailService.sendEmailFromTemplate(variables, recipient, "eventNotification", event.getTitle())); .forEach(recipient -> mailService.sendEmailFromTemplate(variables, recipient, "eventNotification", event.getTitle()));
if (event.getPeriod() == null) { if (event.getPeriod() == null) {

View File

@ -1,9 +1,8 @@
package ru.ulstu.user.component; package ru.ulstu.user.component;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import javax.servlet.http.HttpServletRequest;
final class IpAddressResolver { final class IpAddressResolver {
private static final String CLIENT_IP_HEADER = "Client-IP"; private static final String CLIENT_IP_HEADER = "Client-IP";
private static final String FORWARDED_FOR_HEADER = "X-Forwarded-For"; private static final String FORWARDED_FOR_HEADER = "X-Forwarded-For";

View File

@ -1,5 +1,9 @@
package ru.ulstu.user.component; 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.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.security.core.Authentication; import org.springframework.security.core.Authentication;
@ -9,10 +13,6 @@ import org.springframework.stereotype.Component;
import ru.ulstu.configuration.Constants; import ru.ulstu.configuration.Constants;
import ru.ulstu.user.service.UserSessionService; 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; import java.io.IOException;
@Component @Component

View File

@ -1,5 +1,9 @@
package ru.ulstu.user.component; 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.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.security.core.Authentication; import org.springframework.security.core.Authentication;
@ -9,10 +13,6 @@ import org.springframework.stereotype.Component;
import ru.ulstu.configuration.Constants; import ru.ulstu.configuration.Constants;
import ru.ulstu.user.service.UserSessionService; 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; import java.io.IOException;
@Component @Component

View File

@ -1,5 +1,8 @@
package ru.ulstu.user.controller; 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.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.security.access.annotation.Secured; 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.UserService;
import ru.ulstu.user.service.UserSessionService; 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 java.util.Map;
import static ru.ulstu.user.controller.UserController.URL; import static ru.ulstu.user.controller.UserController.URL;

View File

@ -1,6 +1,7 @@
package ru.ulstu.user.controller; 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.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller; 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.UserService;
import ru.ulstu.user.service.UserSessionService; import ru.ulstu.user.service.UserSessionService;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -65,7 +64,7 @@ public class UserMvcController extends OdinController<UserListDto, UserDto> {
@ModelAttribute("allActivities") @ModelAttribute("allActivities")
public Map<String, String> getAllActivites() { public Map<String, String> getAllActivites() {
return ImmutableMap.of("PAPER", "Статьи", return Map.of("PAPER", "Статьи",
"GRANT", "Гранты", "GRANT", "Гранты",
"PROJECT", "Проекты", "PROJECT", "Проекты",
"CONFERENCE", "Конференции"); "CONFERENCE", "Конференции");

View File

@ -1,14 +1,24 @@
package ru.ulstu.user.model; 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 org.hibernate.annotations.BatchSize;
import ru.ulstu.configuration.Constants; import ru.ulstu.configuration.Constants;
import ru.ulstu.core.model.BaseEntity; 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.Collection;
import java.util.Date; import java.util.Date;
import java.util.HashSet; import java.util.HashSet;

View File

@ -1,6 +1,10 @@
package ru.ulstu.user.model; package ru.ulstu.user.model;
import com.fasterxml.jackson.annotation.JsonIgnore; 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 org.springframework.util.StringUtils;
import ru.ulstu.configuration.Constants; import ru.ulstu.configuration.Constants;
import ru.ulstu.odin.model.OdinDto; 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.odin.model.annotation.OdinVisible;
import ru.ulstu.user.controller.UserController; import ru.ulstu.user.controller.UserController;
import javax.validation.constraints.Email; import java.util.Collection;
import javax.validation.constraints.NotBlank; import java.util.Date;
import javax.validation.constraints.Pattern; import java.util.LinkedHashSet;
import javax.validation.constraints.Size; import java.util.Objects;
import java.util.*; import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static ru.ulstu.odin.model.annotation.OdinString.OdinStringType.PASSWORD; import static ru.ulstu.odin.model.annotation.OdinString.OdinStringType.PASSWORD;

View File

@ -1,9 +1,9 @@
package ru.ulstu.user.model; package ru.ulstu.user.model;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.Size;
import ru.ulstu.configuration.Constants; import ru.ulstu.configuration.Constants;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.Size;
import java.util.Objects; import java.util.Objects;
public class UserResetPasswordDto { public class UserResetPasswordDto {

View File

@ -1,11 +1,11 @@
package ru.ulstu.user.model; package ru.ulstu.user.model;
import javax.persistence.Column; import jakarta.persistence.Column;
import javax.persistence.Entity; import jakarta.persistence.Entity;
import javax.persistence.Id; import jakarta.persistence.Id;
import javax.persistence.Table; import jakarta.persistence.Table;
import javax.validation.constraints.NotNull; import jakarta.validation.constraints.NotNull;
import javax.validation.constraints.Size; import jakarta.validation.constraints.Size;
@Entity @Entity
@Table(name = "user_roles") @Table(name = "user_roles")

View File

@ -1,15 +1,15 @@
package ru.ulstu.user.model; 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 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; import java.util.Date;
@Entity @Entity

View File

@ -1,5 +1,7 @@
package ru.ulstu.user.service; package ru.ulstu.user.service;
import jakarta.mail.MessagingException;
import jakarta.mail.internet.MimeMessage;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -10,13 +12,11 @@ import org.springframework.mail.javamail.MimeMessageHelper;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.thymeleaf.context.Context; import org.thymeleaf.context.Context;
import org.thymeleaf.spring5.SpringTemplateEngine; import org.thymeleaf.spring6.SpringTemplateEngine;
import ru.ulstu.configuration.ApplicationProperties; import ru.ulstu.configuration.ApplicationProperties;
import ru.ulstu.configuration.Constants; import ru.ulstu.configuration.Constants;
import ru.ulstu.user.model.User; import ru.ulstu.user.model.User;
import javax.mail.MessagingException;
import javax.mail.internet.MimeMessage;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.Map; import java.util.Map;
@ -113,7 +113,7 @@ public class MailService {
sendEmailFromTemplate(user, "activationEmail", Constants.MAIL_ACTIVATE); 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); sendEmailFromTemplate(user, "passwordResetEmail", Constants.MAIL_RESET);
} }

View File

@ -1,6 +1,6 @@
package ru.ulstu.user.service; package ru.ulstu.user.service;
import com.google.common.collect.ImmutableMap; import jakarta.mail.MessagingException;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Lazy; 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.core.model.response.PageableItems;
import ru.ulstu.ping.model.Ping; import ru.ulstu.ping.model.Ping;
import ru.ulstu.ping.service.PingService; import ru.ulstu.ping.service.PingService;
import ru.ulstu.user.error.*; import ru.ulstu.user.error.UserActivationError;
import ru.ulstu.user.model.*; 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.UserRepository;
import ru.ulstu.user.repository.UserRoleRepository; import ru.ulstu.user.repository.UserRoleRepository;
import ru.ulstu.user.util.UserUtils; 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.errors.TimetableClientException;
import ru.ulstu.utils.timetable.model.Lesson; import ru.ulstu.utils.timetable.model.Lesson;
import javax.mail.MessagingException;
import java.text.ParseException; 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; import java.util.stream.Collectors;
@Service @Service
@ -258,7 +283,7 @@ public class UserService implements UserDetailsService {
user = userRepository.save(user); user = userRepository.save(user);
try { try {
mailService.sendPasswordResetMail(user); mailService.sendPasswordResetMail(user);
} catch (MessagingException | MailException e) { } catch (MailException e) {
throw new UserSendingMailException(email); throw new UserSendingMailException(email);
} }
log.debug("Created Reset Password Request for User: {}", user.getLogin()); log.debug("Created Reset Password Request for User: {}", user.getLogin());
@ -356,7 +381,7 @@ public class UserService implements UserDetailsService {
user.setActivated(true); user.setActivated(true);
userRepository.save(user); userRepository.save(user);
Map<String, Object> variables = ImmutableMap.of("password", password, "email", email); Map<String, Object> variables = Map.of("password", password, "email", email);
try { try {
mailService.sendInviteMail(variables, email); mailService.sendInviteMail(variables, email);
} catch (MessagingException | MailException e) { } catch (MessagingException | MailException e) {
@ -386,7 +411,7 @@ public class UserService implements UserDetailsService {
userSessionService.isOnline(user)) userSessionService.isOnline(user))
); );
} }
return ImmutableMap.of("users", usersInfoNow, "error", err); return Map.of("users", usersInfoNow, "error", err);
} }
public Map<String, Integer> getActivitiesPings(Integer userId, public Map<String, Integer> getActivitiesPings(Integer userId,

View File

@ -33,7 +33,7 @@ public class UserSessionService {
@Transactional(readOnly = true) @Transactional(readOnly = true)
public PageableItems<UserSessionListDto> getSessions(int offset, int count) { public PageableItems<UserSessionListDto> getSessions(int offset, int count) {
final Page<UserSession> page = userSessionRepository.findAll( final Page<UserSession> 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(), return new PageableItems<>(page.getTotalElements(),
convert(page.getContent(), UserSessionListDto::new)); convert(page.getContent(), UserSessionListDto::new));
} }

View File

@ -29,6 +29,7 @@ spring.datasource.username=postgres
spring.datasource.password=postgres spring.datasource.password=postgres
spring.jpa.hibernate.ddl-auto=validate spring.jpa.hibernate.ddl-auto=validate
spring.jpa.properties.hibernate.temp.use_jdbc_metadata_defaults = false spring.jpa.properties.hibernate.temp.use_jdbc_metadata_defaults = false
spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect
# Liquibase Settings # Liquibase Settings
spring.liquibase.change-log=classpath:db/changelog-master.xml spring.liquibase.change-log=classpath:db/changelog-master.xml
spring.liquibase.drop-first=false spring.liquibase.drop-first=false

View File

@ -78,8 +78,8 @@
</div> </div>
</div> </div>
</nav> </nav>
<div th:replace="users/inviteModal"/> <div th:replace="~{users/inviteModal}"/>
<div th:replace="users/changePassword"/> <div th:replace="~{users/changePassword}"/>
<div class="container-fluid"> <div class="container-fluid">
<div class="container"> <div class="container">
<ul id="messages" class="feedback-panel"> <ul id="messages" class="feedback-panel">

View File

@ -18,7 +18,7 @@
<div class="row"> <div class="row">
<div class="col-lg-12 text-center"> <div class="col-lg-12 text-center">
<h2 class="section-heading text-uppercase">Редактирование статьи</h2> <h2 class="section-heading text-uppercase">Редактирование статьи</h2>
<div th:replace="papers/fragments/paperNavigationFragment"/> <div th:replace="~{papers/fragments/paperNavigationFragment}"/>
</div> </div>
</div> </div>
<hr/> <hr/>
@ -29,18 +29,6 @@
th:object="${paperDto}"> th:object="${paperDto}">
<div class="row"> <div class="row">
<div class="col-md-7 col-sm-12"> <div class="col-md-7 col-sm-12">
<nav>
<div class="nav nav-tabs" id="nav-tab" role="tablist">
<a class="nav-item nav-link active" id="nav-main-tab" data-toggle="tab"
href="#nav-main" role="tab" aria-controls="nav-main" aria-selected="true">Статья</a>
<a class="nav-item nav-link" id="nav-references-tab" data-toggle="tab"
href="#nav-references" role="tab" aria-controls="nav-references"
aria-selected="false">References</a>
</div>
</nav>
<div class="tab-content" id="nav-tabContent">
<div class="tab-pane fade show active" id="nav-main" role="tabpanel"
aria-labelledby="nav-main-tab">
<input type="hidden" id="paperId" name="id" th:field="*{id}"/> <input type="hidden" id="paperId" name="id" th:field="*{id}"/>
<div class="form-group"> <div class="form-group">
<label for="title">Название:</label> <label for="title">Название:</label>
@ -132,7 +120,7 @@
<div class="form-group files-list" id="files-list"> <div class="form-group files-list" id="files-list">
<label>Файлы:</label> <label>Файлы:</label>
<div th:replace="papers/fragments/paperFilesListFragment :: filesList(isLatexAttach = ${false})"/> <div th:replace="~{papers/fragments/paperFilesListFragment :: filesList(isLatexAttach = ${false})}"/>
</div> </div>
@ -148,157 +136,7 @@
</div> </div>
</div> </div>
</div> </div>
<div class="tab-pane fade" id="nav-latex" role="tabpanel"
aria-labelledby="nav-profile-tab">
<div class="form-group">
<label for="latex-text">Latex текст:</label>
<textarea class="form-control" id="latex-text" type="text" rows="10"
placeholder="Latex.."
th:field="*{latexText}"/>
</div>
<div class="form-group files-list" id="latex-files-list">
<label>Файлы:</label>
<div th:replace="papers/fragments/paperFilesListFragment :: filesList(isLatexAttach = ${true})"/>
</div>
<div class="form-group">
<label for="latex-loader">Загрузить файлы:</label>
<div id="latex-loader">
</div>
</div>
<div class="form-group">
<button id="pdfBtn" class="btn btn-primary text-uppercase"
onclick="generatePDF()"
type="button">
<i id="pdfLoadingIcon" class='fa fa-circle-o-notch fa-spin'
style="display: none;"></i>
pdf
</button>
</div>
</div>
<div class="tab-pane fade" id="nav-references" role="tabpanel"
aria-labelledby="nav-profile-tab">
<div class="form-group">
<label>References:</label>
<th:block th:each="reference, rowStat : *{references}">
<div class="row" th:id="|reference${rowStat.index}|"
th:style="${reference.deleted} ? 'display: none;' :''">
<div class="form-group col-11">
<a data-toggle="collapse"
th:href="${'#collapseReference'+rowStat.index}"
aria-expanded="false">
<div class="collapse-heading"
th:text="${(reference.referenceType.toString() == 'ARTICLE'?'Статья':'Книга') +'. '
+(reference.publicationTitle==null?'':reference.publicationTitle+'. ')+(reference.authors==null?'':reference.authors+'. ') }">
</div>
</a>
</div>
<div class="col-1">
<a class="btn btn-danger float-right"
th:onclick="|$('#references${rowStat.index}\\.deleted').val('true'); $('#reference${rowStat.index}').hide(); |"><span
aria-hidden="true"><i class="fa fa-times"/></span>
</a>
</div>
<div class="collapse" th:id="${'collapseReference'+rowStat.index}">
<input type="hidden"
th:field="*{references[__${rowStat.index}__].id}"/>
<input type="hidden"
th:field="*{references[__${rowStat.index}__].deleted}"/>
<div class="form-group col-12">
<label class="col-4">Вид публикации:</label>
<select class="form-control col-7"
th:field="*{references[__${rowStat.index}__].referenceType}">
<option th:each="type : ${allReferenceTypes}"
th:value="${type}"
th:text="${type.typeName}">Type
</option>
</select>
</div>
<div class="form-group col-12">
<label class="col-4">Авторы:</label>
<input type="text"
class="form-control col-7 autocomplete author"
name="authors"
th:field="*{references[__${rowStat.index}__].authors}"/>
</div>
<div class="form-group col-12">
<label class="col-4 ">Название публикации:</label>
<input type="text"
class="form-control col-7 autocomplete publicationTitle"
name="publicationTitle"
th:field="*{references[__${rowStat.index}__].publicationTitle}"/>
</div>
<div class="form-group col-12">
<label class="col-4">Год издания:</label>
<input type="number"
class="form-control col-7 publicationYear"
name="publicationYear"
th:field="*{references[__${rowStat.index}__].publicationYear}"/>
</div>
<div class="form-group col-12">
<label class="col-4">Издательство:</label>
<input type="text"
class="form-control col-7 autocomplete publisher"
name="publisher"
th:field="*{references[__${rowStat.index}__].publisher}"/>
</div>
<div class="form-group col-12">
<label class="col-4">Страницы:</label>
<input type="text" class="form-control col-7 pages"
name="pages"
th:field="*{references[__${rowStat.index}__].pages}"/>
</div>
<div class="form-group col-12">
<label class="col-4">Название журнала или сборника статей
конференции:</label>
<input type="text"
class="form-control col-7 autocomplete journalOrCollectionTitle"
name="journalOrCollectionTitle"
th:field="*{references[__${rowStat.index}__].journalOrCollectionTitle}"/>
</div>
</div>
</div>
</th:block>
<div class="form-group">
<input type="submit" id="addReference" name="addReference"
class="btn btn-primary"
value="Добавить источник"/>
</div>
<div class="form-group">
<div class="col-12 form-group">
<label for="formatStandard">Стандарт форматирования:</label>
<select class="form-control" th:field="*{formatStandard}"
id="formatStandard">
<option th:each="standard : ${allFormatStandards}"
th:value="${standard}"
th:text="${standard.standardName}">standard
</option>
</select>
</div>
<div class="col-12 form-group">
<button id="formatBtn" class="btn btn-primary text-uppercase"
onclick="getFormattedReferences()"
type="button">
Форматировать
</button>
</div>
<div class="col-12">
<textarea class="form-control"
id="formattedReferencesArea"></textarea>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="col-md-4 offset-md-1 col-sm-12 offset-sm-0"> <div class="col-md-4 offset-md-1 col-sm-12 offset-sm-0">
<div class="form-group"> <div class="form-group">
<div class="row"> <div class="row">
@ -333,7 +171,7 @@
</button> </button>
</div> </div>
</div> </div>
</div>
<div class="clearfix"></div> <div class="clearfix"></div>
<div class="col-lg-12"> <div class="col-lg-12">
<div class="form-group"> <div class="form-group">
@ -347,8 +185,6 @@
Отмена Отмена
</a> </a>
</div> </div>
</div>
</div> </div>
</form> </form>
</div> </div>