#73 first fixes by update versions
This commit is contained in:
parent
c374cb4232
commit
e74261184f
13
build.gradle
13
build.gradle
@ -1,6 +1,6 @@
|
||||
buildscript {
|
||||
ext {
|
||||
versionSpringBoot = '1.5.10.RELEASE'
|
||||
versionSpringBoot = '2.1.3.RELEASE'
|
||||
}
|
||||
|
||||
repositories {
|
||||
@ -101,18 +101,15 @@ dependencies {
|
||||
compile group: 'org.springframework.boot', name: 'spring-boot-starter-jetty'
|
||||
compile group: 'org.springframework.boot', name: 'spring-boot-starter-data-jpa'
|
||||
compile group: 'org.springframework.boot', name: 'spring-boot-starter-thymeleaf'
|
||||
compile group: 'org.thymeleaf.extras', name: 'thymeleaf-extras-springsecurity4'
|
||||
compile group: 'nz.net.ultraq.thymeleaf', name: 'thymeleaf-layout-dialect'
|
||||
compile group: 'org.thymeleaf.extras', name: 'thymeleaf-extras-springsecurity5'
|
||||
compile group: 'com.fasterxml.jackson.module', name: 'jackson-module-afterburner'
|
||||
compile group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-hibernate5'
|
||||
|
||||
compile group: 'postgresql', name: 'postgresql', version: '9.1-901.jdbc4'
|
||||
compile group: 'org.postgresql', name: 'postgresql', version: '42.2.5'
|
||||
|
||||
compile group: 'org.liquibase', name: 'liquibase-core', version: '3.5.3'
|
||||
compile group: 'org.liquibase', name: 'liquibase-core', version: '3.6.3'
|
||||
compile group: 'com.mattbertolini', name: 'liquibase-slf4j', version: '2.0.0'
|
||||
|
||||
compile group: 'org.apache.poi', name: 'poi', version: '3.9'
|
||||
compile group: 'org.apache.poi', name: 'poi-ooxml', version: '3.9'
|
||||
|
||||
compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.7'
|
||||
|
||||
compile group: 'org.webjars', name: 'bootstrap', version: '4.1.0'
|
||||
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.5.1-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-bin.zip
|
||||
|
@ -2,18 +2,18 @@ package ru.ulstu.configuration;
|
||||
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer;
|
||||
import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer;
|
||||
import org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainerFactory;
|
||||
import org.springframework.boot.context.embedded.jetty.JettyServerCustomizer;
|
||||
import org.springframework.boot.web.embedded.jetty.JettyServerCustomizer;
|
||||
import org.springframework.boot.web.embedded.jetty.JettyServletWebServerFactory;
|
||||
import org.springframework.boot.web.server.ConfigurableWebServerFactory;
|
||||
import org.springframework.boot.web.server.WebServerFactoryCustomizer;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
public class HttpListenerConfiguration implements EmbeddedServletContainerCustomizer {
|
||||
public class HttpListenerConfiguration implements WebServerFactoryCustomizer<ConfigurableWebServerFactory> {
|
||||
@Value("${server.http.port}")
|
||||
private int httpPort;
|
||||
|
||||
private void configureJetty(JettyEmbeddedServletContainerFactory jettyFactory) {
|
||||
private void configureJetty(JettyServletWebServerFactory jettyFactory) {
|
||||
jettyFactory.addServerCustomizers((JettyServerCustomizer) server -> {
|
||||
ServerConnector serverConnector = new ServerConnector(server);
|
||||
serverConnector.setPort(httpPort);
|
||||
@ -22,9 +22,9 @@ public class HttpListenerConfiguration implements EmbeddedServletContainerCustom
|
||||
}
|
||||
|
||||
@Override
|
||||
public void customize(ConfigurableEmbeddedServletContainer container) {
|
||||
if (container instanceof JettyEmbeddedServletContainerFactory) {
|
||||
configureJetty((JettyEmbeddedServletContainerFactory) container);
|
||||
public void customize(ConfigurableWebServerFactory factory) {
|
||||
if (factory instanceof JettyServletWebServerFactory) {
|
||||
configureJetty((JettyServletWebServerFactory) factory);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,8 +3,8 @@ package ru.ulstu.configuration;
|
||||
import nz.net.ultraq.thymeleaf.LayoutDialect;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.thymeleaf.extras.springsecurity4.dialect.SpringSecurityDialect;
|
||||
import org.thymeleaf.spring4.SpringTemplateEngine;
|
||||
import org.thymeleaf.extras.springsecurity5.dialect.SpringSecurityDialect;
|
||||
import org.thymeleaf.spring5.SpringTemplateEngine;
|
||||
import org.thymeleaf.templateresolver.ClassLoaderTemplateResolver;
|
||||
import org.thymeleaf.templateresolver.ITemplateResolver;
|
||||
|
||||
@ -26,21 +26,21 @@ public class MailTemplateConfiguration {
|
||||
public ClassLoaderTemplateResolver emailTemplateResolver() {
|
||||
ClassLoaderTemplateResolver emailTemplateResolver = new ClassLoaderTemplateResolver();
|
||||
emailTemplateResolver.setPrefix("mail_templates/");
|
||||
emailTemplateResolver.setTemplateMode("HTML5");
|
||||
emailTemplateResolver.setSuffix(".html");
|
||||
emailTemplateResolver.setOrder(1);
|
||||
emailTemplateResolver.setCharacterEncoding(StandardCharsets.UTF_8.name());
|
||||
return emailTemplateResolver;
|
||||
}
|
||||
|
||||
public ClassLoaderTemplateResolver mvcTemplateResolver() {
|
||||
ClassLoaderTemplateResolver emailTemplateResolver = new ClassLoaderTemplateResolver();
|
||||
emailTemplateResolver.setPrefix("templates");
|
||||
emailTemplateResolver.setTemplateMode("HTML5");
|
||||
emailTemplateResolver.setTemplateMode("HTML");
|
||||
emailTemplateResolver.setSuffix(".html");
|
||||
emailTemplateResolver.setOrder(2);
|
||||
emailTemplateResolver.setCharacterEncoding(StandardCharsets.UTF_8.name());
|
||||
return emailTemplateResolver;
|
||||
}
|
||||
|
||||
public ClassLoaderTemplateResolver mvcTemplateResolver() {
|
||||
ClassLoaderTemplateResolver emailTemplateResolver = new ClassLoaderTemplateResolver();
|
||||
emailTemplateResolver.setPrefix("templates/");
|
||||
emailTemplateResolver.setTemplateMode("HTML");
|
||||
emailTemplateResolver.setSuffix(".html");
|
||||
emailTemplateResolver.setOrder(1);
|
||||
emailTemplateResolver.setCharacterEncoding(StandardCharsets.UTF_8.name());
|
||||
return emailTemplateResolver;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -6,19 +6,19 @@ import org.springframework.data.domain.Sort;
|
||||
import java.io.Serializable;
|
||||
|
||||
public class OffsetablePageRequest implements Pageable, Serializable {
|
||||
private final int offset;
|
||||
private final long offset;
|
||||
private final int count;
|
||||
private final Sort sort;
|
||||
|
||||
public OffsetablePageRequest(int offset, int count) {
|
||||
public OffsetablePageRequest(long offset, int count) {
|
||||
this(offset, count, null);
|
||||
}
|
||||
|
||||
public OffsetablePageRequest(int 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));
|
||||
}
|
||||
|
||||
public OffsetablePageRequest(int offset, int count, Sort sort) {
|
||||
public OffsetablePageRequest(long offset, int count, Sort sort) {
|
||||
if (offset < 0) {
|
||||
throw new IllegalArgumentException("Offset value must not be less than zero!");
|
||||
}
|
||||
@ -42,11 +42,11 @@ public class OffsetablePageRequest implements Pageable, Serializable {
|
||||
|
||||
@Override
|
||||
public int getPageNumber() {
|
||||
return offset / count;
|
||||
return (int) (offset / count);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOffset() {
|
||||
public long getOffset() {
|
||||
return offset;
|
||||
}
|
||||
|
||||
@ -89,9 +89,9 @@ public class OffsetablePageRequest implements Pageable, Serializable {
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
long result = 1;
|
||||
result = prime * result + offset;
|
||||
result = prime * result + count;
|
||||
return result;
|
||||
return (int) result;
|
||||
}
|
||||
}
|
||||
|
@ -1,207 +0,0 @@
|
||||
package ru.ulstu.core.service;
|
||||
|
||||
import org.apache.poi.POIXMLDocument;
|
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
import org.apache.poi.ss.util.CellRangeAddress;
|
||||
import org.apache.poi.ss.util.RegionUtil;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import ru.ulstu.core.error.XlsParseException;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
public class XlsDocumentBuilder {
|
||||
private static final int DEFAULT_SHEET_NUM = 0;
|
||||
private File documentFile;
|
||||
private Workbook workBook;
|
||||
private Sheet currentSheet;
|
||||
|
||||
/**
|
||||
* Constructor for reading and writing data from/to *.[xls|xlsx] document
|
||||
*
|
||||
* @param file contains existing document for reading or new document to save
|
||||
*/
|
||||
public XlsDocumentBuilder(File file) throws IOException, XlsParseException {
|
||||
this.documentFile = file;
|
||||
if (file.exists()) {
|
||||
workBook = getWorkBook(file);
|
||||
currentSheet = workBook.getSheetAt(DEFAULT_SHEET_NUM);
|
||||
} else {
|
||||
workBook = new XSSFWorkbook();
|
||||
currentSheet = workBook.createSheet();
|
||||
}
|
||||
}
|
||||
|
||||
private Workbook getWorkBook(File file) throws XlsParseException, IOException {
|
||||
InputStream inputStream = new PushbackInputStream(new FileInputStream(file), 4096);
|
||||
if (isXlsx(inputStream)) {
|
||||
return new XSSFWorkbook(inputStream);
|
||||
} else if (isExcel(inputStream)) {
|
||||
return new HSSFWorkbook(inputStream);
|
||||
}
|
||||
throw new XlsParseException("Wrong document format");
|
||||
}
|
||||
|
||||
/**
|
||||
* Change active sheet to write or read data
|
||||
*
|
||||
* @param index index of sheet to activate
|
||||
*/
|
||||
public XlsDocumentBuilder setActiveSheet(int index) {
|
||||
workBook.setActiveSheet(index);
|
||||
currentSheet = workBook.getSheetAt(index);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create new sheet in document and set it active
|
||||
*
|
||||
* @param sheetName
|
||||
*/
|
||||
public XlsDocumentBuilder insertNewSheet(String sheetName) {
|
||||
currentSheet = workBook.createSheet(sheetName);
|
||||
workBook.setActiveSheet(getSheetCount() - 1);
|
||||
return this;
|
||||
}
|
||||
|
||||
public XlsDocumentBuilder insertNewSheet(String sheetName, int order) {
|
||||
insertNewSheet(sheetName);
|
||||
workBook.setSheetOrder(sheetName, order);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns number of sheet in document
|
||||
*
|
||||
* @return sheets count
|
||||
*/
|
||||
public int getSheetCount() {
|
||||
return workBook.getNumberOfSheets();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns number of rows in sheet
|
||||
*
|
||||
* @return rows count
|
||||
*/
|
||||
public int getRowCount() {
|
||||
return currentSheet.getLastRowNum();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns number of columns in sheet
|
||||
*
|
||||
* @return columns count
|
||||
*/
|
||||
public int getColumnCount() {
|
||||
Row row = currentSheet.getRow(getRowCount());
|
||||
if (row == null) {
|
||||
return 0;
|
||||
}
|
||||
return row.getLastCellNum() - 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns converted to string representation of cell value
|
||||
*
|
||||
* @param rowIndex row index of current sheet
|
||||
* @param colIndex column index of current sheet
|
||||
* @return string value of cell
|
||||
*/
|
||||
public String getCellAsString(int rowIndex, int colIndex) {
|
||||
Cell cell = currentSheet.getRow(rowIndex).getCell(colIndex);
|
||||
cell.setCellType(Cell.CELL_TYPE_STRING);
|
||||
return cell.getStringCellValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets string cell value
|
||||
*
|
||||
* @param rowIndex row index of current sheet
|
||||
* @param colIndex column index of current sheet
|
||||
*/
|
||||
public XlsDocumentBuilder setCellValue(int rowIndex, int colIndex, String value) {
|
||||
if (currentSheet.getRow(rowIndex) == null) {
|
||||
currentSheet.createRow(rowIndex);
|
||||
}
|
||||
if (currentSheet.getRow(rowIndex).getCell(colIndex) == null) {
|
||||
currentSheet.getRow(rowIndex).createCell(colIndex);
|
||||
}
|
||||
Cell cell = currentSheet.getRow(rowIndex).getCell(colIndex);
|
||||
cell.setCellValue(value);
|
||||
setColumnAutosize(colIndex, colIndex);
|
||||
return this;
|
||||
}
|
||||
|
||||
public XlsDocumentBuilder setCellValue(int rowIndex, int colIndex, int value) {
|
||||
return setCellValue(rowIndex, colIndex, String.valueOf(value));
|
||||
}
|
||||
|
||||
public XlsDocumentBuilder setCellValue(int rowIndex, int colIndex, long value) {
|
||||
return setCellValue(rowIndex, colIndex, String.valueOf(value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Save current file
|
||||
*/
|
||||
public XlsDocumentBuilder save() throws IOException {
|
||||
OutputStream out = new FileOutputStream(documentFile);
|
||||
workBook.write(out);
|
||||
return this;
|
||||
}
|
||||
|
||||
private boolean isExcel(InputStream i) throws IOException {
|
||||
return (POIFSFileSystem.hasPOIFSHeader(i) || POIXMLDocument.hasOOXMLHeader(i));
|
||||
}
|
||||
|
||||
private boolean isXlsx(InputStream i) throws IOException {
|
||||
return POIXMLDocument.hasOOXMLHeader(i);
|
||||
}
|
||||
|
||||
public int getActiveSheetIndex() {
|
||||
return workBook.getActiveSheetIndex();
|
||||
}
|
||||
|
||||
public XlsDocumentBuilder mergeCells(int rowFrom, int rowTo, int colFrom, int colTo) {
|
||||
currentSheet.addMergedRegion(new CellRangeAddress(rowFrom, rowTo, colFrom, colTo));
|
||||
return this;
|
||||
}
|
||||
|
||||
public void setRegionBorderWithMedium(int rowFrom, int rowTo, int colFrom, int colTo) {
|
||||
for (int row = rowFrom; row < rowTo; row++) {
|
||||
for (int col = colFrom; col <= colTo; col++) {
|
||||
CellRangeAddress cellRangeAddress = new CellRangeAddress(row, row, col, col);
|
||||
RegionUtil.setBorderBottom(CellStyle.BORDER_THIN, cellRangeAddress, currentSheet, workBook);
|
||||
RegionUtil.setBorderLeft(CellStyle.BORDER_THIN, cellRangeAddress, currentSheet, workBook);
|
||||
RegionUtil.setBorderRight(CellStyle.BORDER_THIN, cellRangeAddress, currentSheet, workBook);
|
||||
RegionUtil.setBorderTop(CellStyle.BORDER_THIN, cellRangeAddress, currentSheet, workBook);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public XlsDocumentBuilder setColumnAutosize(int from, int to) {
|
||||
for (int col = from; col <= to; col++) {
|
||||
currentSheet.autoSizeColumn(col, true);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public XlsDocumentBuilder setRowAutosize(int from, int to) {
|
||||
CellStyle style = workBook.createCellStyle();
|
||||
style.setWrapText(true);
|
||||
for (int row = from; row <= to; row++) {
|
||||
for (int col = 0; col <= currentSheet.getRow(row).getLastCellNum(); col++) {
|
||||
if (currentSheet.getRow(row).getCell(col) != null) {
|
||||
currentSheet.getRow(row).getCell(col).setCellStyle(style);
|
||||
}
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public XlsDocumentBuilder deleteSheet(int index) {
|
||||
workBook.removeSheetAt(index);
|
||||
return this;
|
||||
}
|
||||
}
|
@ -26,7 +26,7 @@ public class DeadlineService {
|
||||
|
||||
@Transactional
|
||||
public Deadline update(Deadline deadline) {
|
||||
Deadline updateDeadline = deadlineRepository.findOne(deadline.getId());
|
||||
Deadline updateDeadline = deadlineRepository.getOne(deadline.getId());
|
||||
updateDeadline.setDate(deadline.getDate());
|
||||
updateDeadline.setDescription(deadline.getDescription());
|
||||
deadlineRepository.save(updateDeadline);
|
||||
|
@ -60,7 +60,7 @@ public class FileService {
|
||||
}
|
||||
|
||||
public FileData getFile(Integer fileId) {
|
||||
return fileRepository.findOne(fileId);
|
||||
return fileRepository.getOne(fileId);
|
||||
}
|
||||
|
||||
public void deleteTmpFile(String tmpFileName) throws IOException {
|
||||
|
@ -52,7 +52,7 @@ public class GrantService {
|
||||
}
|
||||
|
||||
public GrantDto findOneDto(Integer id) {
|
||||
return new GrantDto(grantRepository.findOne(id));
|
||||
return new GrantDto(grantRepository.getOne(id));
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@ -83,7 +83,7 @@ public class GrantService {
|
||||
|
||||
@Transactional
|
||||
public Integer update(GrantDto grantDto) throws IOException {
|
||||
Grant grant = grantRepository.findOne(grantDto.getId());
|
||||
Grant grant = grantRepository.getOne(grantDto.getId());
|
||||
Grant.GrantStatus oldStatus = grant.getStatus();
|
||||
if (grantDto.getApplicationFileName() != null && grant.getApplication() != null) {
|
||||
fileService.deleteFile(grant.getApplication());
|
||||
@ -94,7 +94,7 @@ public class GrantService {
|
||||
|
||||
@Transactional
|
||||
public void delete(Integer grantId) throws IOException {
|
||||
Grant grant = grantRepository.findOne(grantId);
|
||||
Grant grant = grantRepository.getOne(grantId);
|
||||
if (grant.getApplication() != null) {
|
||||
fileService.deleteFile(grant.getApplication());
|
||||
}
|
||||
|
@ -1,13 +1,13 @@
|
||||
package ru.ulstu.odin.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import org.hibernate.validator.constraints.NotBlank;
|
||||
import org.hibernate.validator.constraints.NotEmpty;
|
||||
import ru.ulstu.core.error.OdinException;
|
||||
import ru.ulstu.odin.model.annotation.OdinCaption;
|
||||
import ru.ulstu.odin.model.annotation.OdinReadOnly;
|
||||
import ru.ulstu.odin.model.annotation.OdinVisible;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Field;
|
||||
|
@ -69,7 +69,7 @@ public class PaperService {
|
||||
}
|
||||
|
||||
public PaperDto findOneDto(Integer id) {
|
||||
return new PaperDto(paperRepository.findOne(id));
|
||||
return new PaperDto(paperRepository.getOne(id));
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@ -100,7 +100,7 @@ public class PaperService {
|
||||
|
||||
@Transactional
|
||||
public Integer update(PaperDto paperDto) throws IOException {
|
||||
Paper paper = paperRepository.findOne(paperDto.getId());
|
||||
Paper paper = paperRepository.getOne(paperDto.getId());
|
||||
Paper.PaperStatus oldStatus = paper.getStatus();
|
||||
Set<User> oldAuthors = new HashSet<>(paper.getAuthors());
|
||||
if (paperDto.getTmpFileName() != null && paper.getFileData() != null) {
|
||||
@ -123,7 +123,7 @@ public class PaperService {
|
||||
|
||||
@Transactional
|
||||
public void delete(Integer paperId) throws IOException {
|
||||
Paper paper = paperRepository.findOne(paperId);
|
||||
Paper paper = paperRepository.getOne(paperId);
|
||||
if (paper.getFileData() != null) {
|
||||
fileService.deleteFile(paper.getFileData());
|
||||
}
|
||||
@ -197,7 +197,7 @@ public class PaperService {
|
||||
}
|
||||
|
||||
public PaperDto findById(Integer paperId) {
|
||||
return new PaperDto(paperRepository.findOne(paperId));
|
||||
return new PaperDto(paperRepository.getOne(paperId));
|
||||
}
|
||||
|
||||
public List<User> getPaperAuthors() {
|
||||
|
@ -53,7 +53,7 @@ public class ProjectService {
|
||||
}
|
||||
|
||||
public Project findById(Integer id) {
|
||||
return projectRepository.findOne(id);
|
||||
return projectRepository.getOne(id);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -52,19 +52,19 @@ public class EventService {
|
||||
|
||||
@Transactional
|
||||
public Integer update(EventDto eventDto) {
|
||||
Event event = eventRepository.findOne(eventDto.getId());
|
||||
Event event = eventRepository.getOne(eventDto.getId());
|
||||
return eventRepository.save(copyFromDto(event, eventDto)).getId();
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void delete(Integer eventId) {
|
||||
Event event = eventRepository.findOne(eventId);
|
||||
Event event = eventRepository.getOne(eventId);
|
||||
event.setParents(null);
|
||||
eventRepository.delete(event);
|
||||
}
|
||||
|
||||
public List<Event> findByIds(List<Integer> ids) {
|
||||
return eventRepository.findAll(ids);
|
||||
return eventRepository.findAllById(ids);
|
||||
}
|
||||
|
||||
public void createBasedOn(Event event, Date executeDate) {
|
||||
@ -79,7 +79,7 @@ public class EventService {
|
||||
event = eventRepository.save(event);
|
||||
|
||||
//set child to parent
|
||||
Event parentEvent = eventRepository.findOne(parentEventId);
|
||||
Event parentEvent = eventRepository.getOne(parentEventId);
|
||||
parentEvent.setChild(event);
|
||||
eventRepository.save(parentEvent);
|
||||
}
|
||||
|
@ -39,13 +39,13 @@ public class TimelineService {
|
||||
|
||||
@Transactional
|
||||
public Integer update(TimelineDto timelineDto) {
|
||||
Timeline timeline = timelineRepository.findOne(timelineDto.getId());
|
||||
Timeline timeline = timelineRepository.getOne(timelineDto.getId());
|
||||
return timelineRepository.save(copyFromDto(timeline, timelineDto)).getId();
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void delete(Integer timelineId) {
|
||||
Timeline timeline = timelineRepository.findOne(timelineId);
|
||||
Timeline timeline = timelineRepository.getOne(timelineId);
|
||||
timelineRepository.delete(timeline);
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package ru.ulstu.user.model;
|
||||
|
||||
import org.hibernate.annotations.BatchSize;
|
||||
import org.hibernate.validator.constraints.Email;
|
||||
import ru.ulstu.configuration.Constants;
|
||||
import ru.ulstu.core.model.BaseEntity;
|
||||
|
||||
@ -13,6 +12,7 @@ import javax.persistence.ManyToMany;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
import javax.validation.constraints.Email;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Pattern;
|
||||
import javax.validation.constraints.Size;
|
||||
|
@ -1,8 +1,6 @@
|
||||
package ru.ulstu.user.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import org.hibernate.validator.constraints.Email;
|
||||
import org.hibernate.validator.constraints.NotBlank;
|
||||
import org.springframework.util.StringUtils;
|
||||
import ru.ulstu.configuration.Constants;
|
||||
import ru.ulstu.odin.model.OdinDto;
|
||||
@ -12,6 +10,8 @@ import ru.ulstu.odin.model.annotation.OdinString;
|
||||
import ru.ulstu.odin.model.annotation.OdinVisible;
|
||||
import ru.ulstu.user.controller.UserController;
|
||||
|
||||
import javax.validation.constraints.Email;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.Pattern;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.util.Collection;
|
||||
|
@ -8,7 +8,7 @@ import org.springframework.mail.javamail.MimeMessageHelper;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.thymeleaf.context.Context;
|
||||
import org.thymeleaf.spring4.SpringTemplateEngine;
|
||||
import org.thymeleaf.spring5.SpringTemplateEngine;
|
||||
import ru.ulstu.configuration.ApplicationProperties;
|
||||
import ru.ulstu.configuration.Constants;
|
||||
import ru.ulstu.user.model.User;
|
||||
@ -19,11 +19,9 @@ import java.util.Map;
|
||||
|
||||
@Service
|
||||
public class MailService {
|
||||
private final Logger log = LoggerFactory.getLogger(MailService.class);
|
||||
|
||||
private static final String USER = "user";
|
||||
private static final String BASE_URL = "baseUrl";
|
||||
|
||||
private final Logger log = LoggerFactory.getLogger(MailService.class);
|
||||
private final JavaMailSender javaMailSender;
|
||||
private final SpringTemplateEngine templateEngine;
|
||||
private final MailProperties mailProperties;
|
||||
|
@ -26,7 +26,7 @@ public class UserMapper {
|
||||
public Set<UserRole> rolesFromDto(Set<UserRoleDto> strings) {
|
||||
return Optional.ofNullable(strings).orElse(Collections.emptySet()).stream()
|
||||
.filter(Objects::nonNull)
|
||||
.map(role -> userRoleRepository.findOne(role.getId().toString()))
|
||||
.map(role -> userRoleRepository.getOne(role.getId().toString()))
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import org.slf4j.LoggerFactory;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
import org.springframework.security.core.userdetails.UserDetailsService;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
@ -163,7 +164,7 @@ public class UserService implements UserDetailsService {
|
||||
userDto.getId())) {
|
||||
throw new UserLoginExistsException(userDto.getLogin());
|
||||
}
|
||||
User user = userRepository.findOne(userDto.getId());
|
||||
User user = userRepository.getOne(userDto.getId());
|
||||
if (user == null) {
|
||||
throw new UserNotFoundException(userDto.getId().toString());
|
||||
}
|
||||
@ -215,7 +216,7 @@ public class UserService implements UserDetailsService {
|
||||
userDto.getId())) {
|
||||
throw new UserEmailExistsException(userDto.getEmail());
|
||||
}
|
||||
User user = userRepository.findOne(userDto.getId());
|
||||
User user = userRepository.getOne(userDto.getId());
|
||||
if (user == null) {
|
||||
throw new UserNotFoundException(userDto.getId().toString());
|
||||
}
|
||||
@ -234,7 +235,7 @@ public class UserService implements UserDetailsService {
|
||||
if (!userDto.isPasswordsValid() || !userDto.isOldPasswordValid()) {
|
||||
throw new UserPasswordsNotValidOrNotMatchException();
|
||||
}
|
||||
final String login = UserUtils.getCurrentUserLogin();
|
||||
final String login = UserUtils.getCurrentUserLogin(SecurityContextHolder.getContext());
|
||||
final User user = userRepository.findOneByLoginIgnoreCase(login);
|
||||
if (user == null) {
|
||||
throw new UserNotFoundException(login);
|
||||
@ -280,7 +281,7 @@ public class UserService implements UserDetailsService {
|
||||
}
|
||||
|
||||
public UserDto deleteUser(Integer userId) {
|
||||
final User user = userRepository.findOne(userId);
|
||||
final User user = userRepository.getOne(userId);
|
||||
if (user == null) {
|
||||
throw new UserNotFoundException(userId.toString());
|
||||
}
|
||||
@ -309,15 +310,15 @@ public class UserService implements UserDetailsService {
|
||||
}
|
||||
|
||||
public List<User> findByIds(List<Integer> ids) {
|
||||
return userRepository.findAll(ids);
|
||||
return userRepository.findAllById(ids);
|
||||
}
|
||||
|
||||
public User findById(Integer id) {
|
||||
return userRepository.findOne(id);
|
||||
return userRepository.getOne(id);
|
||||
}
|
||||
|
||||
public User getCurrentUser() {
|
||||
String login = UserUtils.getCurrentUserLogin();
|
||||
String login = UserUtils.getCurrentUserLogin(SecurityContextHolder.getContext());
|
||||
User user = userRepository.findOneByLoginIgnoreCase(login);
|
||||
if (user == null) {
|
||||
throw new UserNotFoundException(login);
|
||||
|
@ -17,12 +17,15 @@ public class UserUtils {
|
||||
return RandomStringUtils.randomNumeric(DEF_COUNT);
|
||||
}
|
||||
|
||||
public static String getCurrentUserLogin() {
|
||||
final SecurityContext securityContext = SecurityContextHolder.getContext();
|
||||
public static String getCurrentUserLogin(SecurityContext securityContext) {
|
||||
if (securityContext == null) {
|
||||
return null;
|
||||
}
|
||||
final Authentication authentication = securityContext.getAuthentication();
|
||||
|
||||
if (authentication == null) {
|
||||
return "admin";
|
||||
}
|
||||
if (authentication.getPrincipal() instanceof UserDetails) {
|
||||
final UserDetails springSecurityUser = (UserDetails) authentication.getPrincipal();
|
||||
return springSecurityUser.getUsername();
|
||||
|
@ -27,10 +27,15 @@ spring.datasource.username=postgres
|
||||
spring.datasource.password=postgres
|
||||
spring.datasource.driverclassName=org.postgresql.Driver
|
||||
spring.jpa.hibernate.ddl-auto=validate
|
||||
spring.jpa.database-platform=org.hibernate.dialect.PostgreSQL95Dialect
|
||||
pring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true
|
||||
# Liquibase Settings
|
||||
liquibase.drop-first=false
|
||||
liquibase.enabled=true
|
||||
liquibase.change-log=classpath:db/changelog-master.xml
|
||||
#liquibase.drop-first=false
|
||||
#liquibase.enabled=true
|
||||
#liquibase.change-log=classpath:db/changelog-master.xml
|
||||
spring.liquibase.change-log=classpath:db/changelog-master.xml
|
||||
spring.liquibase.drop-first=false
|
||||
spring.liquibase.enabled=true
|
||||
# Application Settings
|
||||
ng-tracker.base-url=http://127.0.0.1:8080
|
||||
ng-tracker.undead-user-login=admin
|
||||
|
@ -67,7 +67,7 @@
|
||||
th:onclick="|$('#deadlines${rowStat.index}\\.description').val('');
|
||||
$('#deadlines${rowStat.index}\\.date').val('');
|
||||
$('#addDeadline').click();|"><span
|
||||
aria-hidden="true"><i class="fa fa-times"/></span>
|
||||
aria-hidden="true"><i class="fa fa-times c1"/></span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user