From e74261184f7a8442c8b359f6cc86bd59c3578949 Mon Sep 17 00:00:00 2001 From: Anton Romanov Date: Wed, 20 Mar 2019 14:37:57 +0400 Subject: [PATCH 01/15] #73 first fixes by update versions --- build.gradle | 13 +- gradle/wrapper/gradle-wrapper.properties | 2 +- .../HttpListenerConfiguration.java | 18 +- .../MailTemplateConfiguration.java | 26 +-- .../ulstu/core/jpa/OffsetablePageRequest.java | 16 +- .../core/service/XlsDocumentBuilder.java | 207 ------------------ .../deadline/service/DeadlineService.java | 2 +- .../ru/ulstu/file/service/FileService.java | 2 +- .../ru/ulstu/grant/service/GrantService.java | 6 +- .../java/ru/ulstu/odin/model/OdinField.java | 4 +- .../ru/ulstu/paper/service/PaperService.java | 8 +- .../ulstu/project/service/ProjectService.java | 2 +- .../ulstu/timeline/service/EventService.java | 8 +- .../timeline/service/TimelineService.java | 4 +- src/main/java/ru/ulstu/user/model/User.java | 2 +- .../java/ru/ulstu/user/model/UserDto.java | 4 +- .../ru/ulstu/user/service/MailService.java | 6 +- .../ru/ulstu/user/service/UserMapper.java | 2 +- .../ru/ulstu/user/service/UserService.java | 15 +- .../java/ru/ulstu/user/util/UserUtils.java | 7 +- src/main/resources/application.properties | 11 +- .../resources/templates/papers/paper.html | 2 +- 22 files changed, 82 insertions(+), 285 deletions(-) delete mode 100644 src/main/java/ru/ulstu/core/service/XlsDocumentBuilder.java diff --git a/build.gradle b/build.gradle index 4e0e9cb..53f06a9 100644 --- a/build.gradle +++ b/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' diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 568c50b..663c448 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -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 diff --git a/src/main/java/ru/ulstu/configuration/HttpListenerConfiguration.java b/src/main/java/ru/ulstu/configuration/HttpListenerConfiguration.java index bcbcab8..514319d 100644 --- a/src/main/java/ru/ulstu/configuration/HttpListenerConfiguration.java +++ b/src/main/java/ru/ulstu/configuration/HttpListenerConfiguration.java @@ -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 { @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); } } } diff --git a/src/main/java/ru/ulstu/configuration/MailTemplateConfiguration.java b/src/main/java/ru/ulstu/configuration/MailTemplateConfiguration.java index addf7ac..e212e5b 100644 --- a/src/main/java/ru/ulstu/configuration/MailTemplateConfiguration.java +++ b/src/main/java/ru/ulstu/configuration/MailTemplateConfiguration.java @@ -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; + } + } diff --git a/src/main/java/ru/ulstu/core/jpa/OffsetablePageRequest.java b/src/main/java/ru/ulstu/core/jpa/OffsetablePageRequest.java index 388e9a1..af3be5c 100644 --- a/src/main/java/ru/ulstu/core/jpa/OffsetablePageRequest.java +++ b/src/main/java/ru/ulstu/core/jpa/OffsetablePageRequest.java @@ -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; } } diff --git a/src/main/java/ru/ulstu/core/service/XlsDocumentBuilder.java b/src/main/java/ru/ulstu/core/service/XlsDocumentBuilder.java deleted file mode 100644 index d70d86e..0000000 --- a/src/main/java/ru/ulstu/core/service/XlsDocumentBuilder.java +++ /dev/null @@ -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; - } -} diff --git a/src/main/java/ru/ulstu/deadline/service/DeadlineService.java b/src/main/java/ru/ulstu/deadline/service/DeadlineService.java index 2180025..30aa6b0 100644 --- a/src/main/java/ru/ulstu/deadline/service/DeadlineService.java +++ b/src/main/java/ru/ulstu/deadline/service/DeadlineService.java @@ -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); diff --git a/src/main/java/ru/ulstu/file/service/FileService.java b/src/main/java/ru/ulstu/file/service/FileService.java index 2f1fb6d..3f9e603 100644 --- a/src/main/java/ru/ulstu/file/service/FileService.java +++ b/src/main/java/ru/ulstu/file/service/FileService.java @@ -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 { diff --git a/src/main/java/ru/ulstu/grant/service/GrantService.java b/src/main/java/ru/ulstu/grant/service/GrantService.java index d5beec3..7041f7d 100644 --- a/src/main/java/ru/ulstu/grant/service/GrantService.java +++ b/src/main/java/ru/ulstu/grant/service/GrantService.java @@ -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()); } diff --git a/src/main/java/ru/ulstu/odin/model/OdinField.java b/src/main/java/ru/ulstu/odin/model/OdinField.java index 5917a44..17ee2dc 100644 --- a/src/main/java/ru/ulstu/odin/model/OdinField.java +++ b/src/main/java/ru/ulstu/odin/model/OdinField.java @@ -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; diff --git a/src/main/java/ru/ulstu/paper/service/PaperService.java b/src/main/java/ru/ulstu/paper/service/PaperService.java index 9df8be2..f724bdb 100644 --- a/src/main/java/ru/ulstu/paper/service/PaperService.java +++ b/src/main/java/ru/ulstu/paper/service/PaperService.java @@ -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 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 getPaperAuthors() { diff --git a/src/main/java/ru/ulstu/project/service/ProjectService.java b/src/main/java/ru/ulstu/project/service/ProjectService.java index b54a60a..cbcc232 100644 --- a/src/main/java/ru/ulstu/project/service/ProjectService.java +++ b/src/main/java/ru/ulstu/project/service/ProjectService.java @@ -53,7 +53,7 @@ public class ProjectService { } public Project findById(Integer id) { - return projectRepository.findOne(id); + return projectRepository.getOne(id); } } diff --git a/src/main/java/ru/ulstu/timeline/service/EventService.java b/src/main/java/ru/ulstu/timeline/service/EventService.java index ca95b9a..7d0d251 100644 --- a/src/main/java/ru/ulstu/timeline/service/EventService.java +++ b/src/main/java/ru/ulstu/timeline/service/EventService.java @@ -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 findByIds(List 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); } diff --git a/src/main/java/ru/ulstu/timeline/service/TimelineService.java b/src/main/java/ru/ulstu/timeline/service/TimelineService.java index 94388ee..4101f92 100644 --- a/src/main/java/ru/ulstu/timeline/service/TimelineService.java +++ b/src/main/java/ru/ulstu/timeline/service/TimelineService.java @@ -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); } } diff --git a/src/main/java/ru/ulstu/user/model/User.java b/src/main/java/ru/ulstu/user/model/User.java index de9f028..de3be9e 100644 --- a/src/main/java/ru/ulstu/user/model/User.java +++ b/src/main/java/ru/ulstu/user/model/User.java @@ -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; diff --git a/src/main/java/ru/ulstu/user/model/UserDto.java b/src/main/java/ru/ulstu/user/model/UserDto.java index c98e0bb..ecb8bbe 100644 --- a/src/main/java/ru/ulstu/user/model/UserDto.java +++ b/src/main/java/ru/ulstu/user/model/UserDto.java @@ -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; diff --git a/src/main/java/ru/ulstu/user/service/MailService.java b/src/main/java/ru/ulstu/user/service/MailService.java index da1da6d..77be5e7 100644 --- a/src/main/java/ru/ulstu/user/service/MailService.java +++ b/src/main/java/ru/ulstu/user/service/MailService.java @@ -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; diff --git a/src/main/java/ru/ulstu/user/service/UserMapper.java b/src/main/java/ru/ulstu/user/service/UserMapper.java index 7359bba..647754b 100644 --- a/src/main/java/ru/ulstu/user/service/UserMapper.java +++ b/src/main/java/ru/ulstu/user/service/UserMapper.java @@ -26,7 +26,7 @@ public class UserMapper { public Set rolesFromDto(Set 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()); } diff --git a/src/main/java/ru/ulstu/user/service/UserService.java b/src/main/java/ru/ulstu/user/service/UserService.java index 25d8e95..e318401 100644 --- a/src/main/java/ru/ulstu/user/service/UserService.java +++ b/src/main/java/ru/ulstu/user/service/UserService.java @@ -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 findByIds(List 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); diff --git a/src/main/java/ru/ulstu/user/util/UserUtils.java b/src/main/java/ru/ulstu/user/util/UserUtils.java index de585a5..377db6e 100644 --- a/src/main/java/ru/ulstu/user/util/UserUtils.java +++ b/src/main/java/ru/ulstu/user/util/UserUtils.java @@ -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(); diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index fb1b116..62e6bbc 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -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 diff --git a/src/main/resources/templates/papers/paper.html b/src/main/resources/templates/papers/paper.html index a5ff6b5..6792be2 100644 --- a/src/main/resources/templates/papers/paper.html +++ b/src/main/resources/templates/papers/paper.html @@ -67,7 +67,7 @@ th:onclick="|$('#deadlines${rowStat.index}\\.description').val(''); $('#deadlines${rowStat.index}\\.date').val(''); $('#addDeadline').click();|"> + aria-hidden="true"> From 1487affb8e29bc5e65fc1326e58f5517f41c45f7 Mon Sep 17 00:00:00 2001 From: Anton Romanov Date: Wed, 20 Mar 2019 19:20:28 +0400 Subject: [PATCH 02/15] #73 fix deprecated annotations and classes --- .../java/ru/ulstu/configuration/ApplicationProperties.java | 3 ++- src/main/java/ru/ulstu/configuration/MvcConfiguration.java | 4 ++-- src/main/java/ru/ulstu/grant/model/Grant.java | 2 +- src/main/java/ru/ulstu/grant/model/GrantDto.java | 2 +- src/main/java/ru/ulstu/odin/model/OdinStringField.java | 2 +- src/main/java/ru/ulstu/paper/model/Paper.java | 2 +- src/main/java/ru/ulstu/paper/model/PaperDto.java | 2 +- src/main/java/ru/ulstu/project/model/Project.java | 2 +- src/main/java/ru/ulstu/project/model/ProjectDto.java | 2 +- src/main/java/ru/ulstu/timeline/model/Event.java | 2 +- src/main/java/ru/ulstu/timeline/model/EventDto.java | 2 +- src/main/java/ru/ulstu/user/model/UserResetPasswordDto.java | 2 +- src/main/java/ru/ulstu/user/service/UserService.java | 2 +- 13 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/main/java/ru/ulstu/configuration/ApplicationProperties.java b/src/main/java/ru/ulstu/configuration/ApplicationProperties.java index 8615cb2..339bcb7 100644 --- a/src/main/java/ru/ulstu/configuration/ApplicationProperties.java +++ b/src/main/java/ru/ulstu/configuration/ApplicationProperties.java @@ -1,10 +1,11 @@ package ru.ulstu.configuration; -import org.hibernate.validator.constraints.NotBlank; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.stereotype.Component; import org.springframework.validation.annotation.Validated; +import javax.validation.constraints.NotBlank; + @Component @ConfigurationProperties(prefix = "ng-tracker") @Validated diff --git a/src/main/java/ru/ulstu/configuration/MvcConfiguration.java b/src/main/java/ru/ulstu/configuration/MvcConfiguration.java index 3e8d66f..f9e887f 100644 --- a/src/main/java/ru/ulstu/configuration/MvcConfiguration.java +++ b/src/main/java/ru/ulstu/configuration/MvcConfiguration.java @@ -3,10 +3,10 @@ package ru.ulstu.configuration; import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; @Configuration -public class MvcConfiguration extends WebMvcConfigurerAdapter { +public class MvcConfiguration implements WebMvcConfigurer { @Override public void addViewControllers(ViewControllerRegistry registry) { registry.addViewController("/{articlename:\\w+}"); diff --git a/src/main/java/ru/ulstu/grant/model/Grant.java b/src/main/java/ru/ulstu/grant/model/Grant.java index 685a1d5..09c2cdf 100644 --- a/src/main/java/ru/ulstu/grant/model/Grant.java +++ b/src/main/java/ru/ulstu/grant/model/Grant.java @@ -1,6 +1,5 @@ package ru.ulstu.grant.model; -import org.hibernate.validator.constraints.NotBlank; import ru.ulstu.core.model.BaseEntity; import ru.ulstu.deadline.model.Deadline; import ru.ulstu.file.model.FileData; @@ -14,6 +13,7 @@ import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; import javax.persistence.OneToMany; import javax.persistence.Table; +import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; import java.util.ArrayList; import java.util.Comparator; diff --git a/src/main/java/ru/ulstu/grant/model/GrantDto.java b/src/main/java/ru/ulstu/grant/model/GrantDto.java index fb29164..1d0a43c 100644 --- a/src/main/java/ru/ulstu/grant/model/GrantDto.java +++ b/src/main/java/ru/ulstu/grant/model/GrantDto.java @@ -2,10 +2,10 @@ package ru.ulstu.grant.model; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; -import org.hibernate.validator.constraints.NotEmpty; import ru.ulstu.deadline.model.Deadline; import ru.ulstu.project.model.ProjectDto; +import javax.validation.constraints.NotEmpty; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/ru/ulstu/odin/model/OdinStringField.java b/src/main/java/ru/ulstu/odin/model/OdinStringField.java index 5157d7e..498b375 100644 --- a/src/main/java/ru/ulstu/odin/model/OdinStringField.java +++ b/src/main/java/ru/ulstu/odin/model/OdinStringField.java @@ -1,9 +1,9 @@ package ru.ulstu.odin.model; -import org.hibernate.validator.constraints.Email; import ru.ulstu.odin.model.annotation.OdinString; import ru.ulstu.odin.model.annotation.OdinString.OdinStringType; +import javax.validation.constraints.Email; import javax.validation.constraints.Size; import java.lang.reflect.Field; diff --git a/src/main/java/ru/ulstu/paper/model/Paper.java b/src/main/java/ru/ulstu/paper/model/Paper.java index c09fd28..685a901 100644 --- a/src/main/java/ru/ulstu/paper/model/Paper.java +++ b/src/main/java/ru/ulstu/paper/model/Paper.java @@ -2,7 +2,6 @@ package ru.ulstu.paper.model; import org.hibernate.annotations.Fetch; import org.hibernate.annotations.FetchMode; -import org.hibernate.validator.constraints.NotBlank; import ru.ulstu.core.model.BaseEntity; import ru.ulstu.core.model.UserContainer; import ru.ulstu.deadline.model.Deadline; @@ -22,6 +21,7 @@ import javax.persistence.OneToMany; import javax.persistence.OrderBy; import javax.persistence.Temporal; import javax.persistence.TemporalType; +import javax.validation.constraints.NotBlank; import java.util.ArrayList; import java.util.Comparator; import java.util.Date; diff --git a/src/main/java/ru/ulstu/paper/model/PaperDto.java b/src/main/java/ru/ulstu/paper/model/PaperDto.java index 3405768..c828381 100644 --- a/src/main/java/ru/ulstu/paper/model/PaperDto.java +++ b/src/main/java/ru/ulstu/paper/model/PaperDto.java @@ -3,10 +3,10 @@ package ru.ulstu.paper.model; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import org.apache.commons.lang3.StringUtils; -import org.hibernate.validator.constraints.NotEmpty; import ru.ulstu.deadline.model.Deadline; import ru.ulstu.user.model.UserDto; +import javax.validation.constraints.NotEmpty; import javax.validation.constraints.Size; import java.util.ArrayList; import java.util.Date; diff --git a/src/main/java/ru/ulstu/project/model/Project.java b/src/main/java/ru/ulstu/project/model/Project.java index 06722a1..896c53d 100644 --- a/src/main/java/ru/ulstu/project/model/Project.java +++ b/src/main/java/ru/ulstu/project/model/Project.java @@ -1,6 +1,5 @@ package ru.ulstu.project.model; -import org.hibernate.validator.constraints.NotBlank; import ru.ulstu.core.model.BaseEntity; import ru.ulstu.deadline.model.Deadline; @@ -8,6 +7,7 @@ import javax.persistence.CascadeType; import javax.persistence.Entity; import javax.persistence.JoinColumn; import javax.persistence.OneToMany; +import javax.validation.constraints.NotBlank; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/ru/ulstu/project/model/ProjectDto.java b/src/main/java/ru/ulstu/project/model/ProjectDto.java index db7fc75..65f4365 100644 --- a/src/main/java/ru/ulstu/project/model/ProjectDto.java +++ b/src/main/java/ru/ulstu/project/model/ProjectDto.java @@ -2,9 +2,9 @@ package ru.ulstu.project.model; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; -import org.hibernate.validator.constraints.NotEmpty; import ru.ulstu.deadline.model.Deadline; +import javax.validation.constraints.NotEmpty; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/ru/ulstu/timeline/model/Event.java b/src/main/java/ru/ulstu/timeline/model/Event.java index 290f136..f64963d 100644 --- a/src/main/java/ru/ulstu/timeline/model/Event.java +++ b/src/main/java/ru/ulstu/timeline/model/Event.java @@ -1,6 +1,5 @@ package ru.ulstu.timeline.model; -import org.hibernate.validator.constraints.NotBlank; import ru.ulstu.core.model.BaseEntity; import ru.ulstu.user.model.User; @@ -16,6 +15,7 @@ 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.Date; import java.util.List; diff --git a/src/main/java/ru/ulstu/timeline/model/EventDto.java b/src/main/java/ru/ulstu/timeline/model/EventDto.java index 9e70a9d..b053d36 100644 --- a/src/main/java/ru/ulstu/timeline/model/EventDto.java +++ b/src/main/java/ru/ulstu/timeline/model/EventDto.java @@ -2,9 +2,9 @@ package ru.ulstu.timeline.model; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; -import org.hibernate.validator.constraints.NotBlank; import ru.ulstu.user.model.UserDto; +import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; import java.util.Date; import java.util.List; diff --git a/src/main/java/ru/ulstu/user/model/UserResetPasswordDto.java b/src/main/java/ru/ulstu/user/model/UserResetPasswordDto.java index 33d84bc..6da2813 100644 --- a/src/main/java/ru/ulstu/user/model/UserResetPasswordDto.java +++ b/src/main/java/ru/ulstu/user/model/UserResetPasswordDto.java @@ -1,8 +1,8 @@ package ru.ulstu.user.model; -import org.hibernate.validator.constraints.NotEmpty; import ru.ulstu.configuration.Constants; +import javax.validation.constraints.NotEmpty; import javax.validation.constraints.Size; import java.util.Objects; diff --git a/src/main/java/ru/ulstu/user/service/UserService.java b/src/main/java/ru/ulstu/user/service/UserService.java index e318401..198ffcd 100644 --- a/src/main/java/ru/ulstu/user/service/UserService.java +++ b/src/main/java/ru/ulstu/user/service/UserService.java @@ -94,7 +94,7 @@ public class UserService implements UserDetailsService { @Transactional(readOnly = true) public PageableItems getAllUsers(int offset, int count) { - final Page page = userRepository.findAll(new OffsetablePageRequest(offset, count, new Sort("id"))); + final Page page = userRepository.findAll(new OffsetablePageRequest(offset, count, Sort.by("id"))); return new PageableItems<>(page.getTotalElements(), userMapper.userEntitiesToUserListDtos(page.getContent())); } From 9bd954ea9b16904a183747d5b286be76072b9501 Mon Sep 17 00:00:00 2001 From: Anton Romanov Date: Wed, 20 Mar 2019 20:31:46 +0400 Subject: [PATCH 03/15] #73 fix new thymeleaf syntax --- .../configuration/MailTemplateConfiguration.java | 15 +-------------- src/main/resources/templates/activate.html | 2 +- src/main/resources/templates/admin/commits.html | 2 +- src/main/resources/templates/admin/userList.html | 2 +- .../resources/templates/admin/userSessions.html | 2 +- .../templates/conferences/conference.html | 2 +- .../templates/conferences/conferences.html | 2 +- src/main/resources/templates/error/403.html | 2 +- src/main/resources/templates/error/404.html | 2 +- src/main/resources/templates/error/500.html | 2 +- .../resources/templates/grants/dashboard.html | 2 +- src/main/resources/templates/grants/grant.html | 5 ++--- src/main/resources/templates/grants/grants.html | 2 +- src/main/resources/templates/index.html | 2 +- src/main/resources/templates/load.html | 2 +- src/main/resources/templates/login.html | 2 +- .../resources/templates/papers/dashboard.html | 2 +- src/main/resources/templates/papers/paper.html | 4 ++-- src/main/resources/templates/papers/papers.html | 2 +- src/main/resources/templates/reset.html | 2 +- src/main/resources/templates/resetRequest.html | 2 +- src/main/resources/templates/timeline.html | 2 +- 22 files changed, 24 insertions(+), 38 deletions(-) diff --git a/src/main/java/ru/ulstu/configuration/MailTemplateConfiguration.java b/src/main/java/ru/ulstu/configuration/MailTemplateConfiguration.java index e212e5b..31de65c 100644 --- a/src/main/java/ru/ulstu/configuration/MailTemplateConfiguration.java +++ b/src/main/java/ru/ulstu/configuration/MailTemplateConfiguration.java @@ -17,7 +17,6 @@ public class MailTemplateConfiguration { final SpringTemplateEngine templateEngine = new SpringTemplateEngine(); templateEngine.addTemplateResolver(templateResolver); templateEngine.addTemplateResolver(emailTemplateResolver()); - templateEngine.addTemplateResolver(mvcTemplateResolver()); templateEngine.addDialect(new LayoutDialect()); templateEngine.addDialect(sec); return templateEngine; @@ -25,22 +24,10 @@ public class MailTemplateConfiguration { public ClassLoaderTemplateResolver emailTemplateResolver() { ClassLoaderTemplateResolver emailTemplateResolver = new ClassLoaderTemplateResolver(); - emailTemplateResolver.setPrefix("mail_templates/"); + emailTemplateResolver.setPrefix("/mail_templates/"); 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; - } - } diff --git a/src/main/resources/templates/activate.html b/src/main/resources/templates/activate.html index b20a284..d06cdc8 100644 --- a/src/main/resources/templates/activate.html +++ b/src/main/resources/templates/activate.html @@ -2,7 +2,7 @@ + layout:decorate="~{default}"> diff --git a/src/main/resources/templates/admin/commits.html b/src/main/resources/templates/admin/commits.html index a8b8e85..9b2f115 100644 --- a/src/main/resources/templates/admin/commits.html +++ b/src/main/resources/templates/admin/commits.html @@ -2,7 +2,7 @@ + layout:decorate="~{default}"> diff --git a/src/main/resources/templates/admin/userList.html b/src/main/resources/templates/admin/userList.html index b47f720..911601f 100644 --- a/src/main/resources/templates/admin/userList.html +++ b/src/main/resources/templates/admin/userList.html @@ -2,7 +2,7 @@ + layout:decorate="~{default}"> diff --git a/src/main/resources/templates/admin/userSessions.html b/src/main/resources/templates/admin/userSessions.html index 2c3405a..12d3a61 100644 --- a/src/main/resources/templates/admin/userSessions.html +++ b/src/main/resources/templates/admin/userSessions.html @@ -2,7 +2,7 @@ + layout:decorate="~{default}"> diff --git a/src/main/resources/templates/conferences/conference.html b/src/main/resources/templates/conferences/conference.html index 078e697..713c533 100644 --- a/src/main/resources/templates/conferences/conference.html +++ b/src/main/resources/templates/conferences/conference.html @@ -1,7 +1,7 @@ + layout:decorate="~{default}"> diff --git a/src/main/resources/templates/conferences/conferences.html b/src/main/resources/templates/conferences/conferences.html index ab9fd31..b81d33c 100644 --- a/src/main/resources/templates/conferences/conferences.html +++ b/src/main/resources/templates/conferences/conferences.html @@ -1,7 +1,7 @@ + layout:decorate="~{default}"> diff --git a/src/main/resources/templates/error/403.html b/src/main/resources/templates/error/403.html index d850fa9..a80b444 100644 --- a/src/main/resources/templates/error/403.html +++ b/src/main/resources/templates/error/403.html @@ -1,7 +1,7 @@ + layout:decorate="~{default}"> diff --git a/src/main/resources/templates/error/404.html b/src/main/resources/templates/error/404.html index 7233d72..8f1d80b 100644 --- a/src/main/resources/templates/error/404.html +++ b/src/main/resources/templates/error/404.html @@ -1,7 +1,7 @@ + layout:decorate="~{default}"> diff --git a/src/main/resources/templates/error/500.html b/src/main/resources/templates/error/500.html index d42e7b4..f89b83a 100644 --- a/src/main/resources/templates/error/500.html +++ b/src/main/resources/templates/error/500.html @@ -1,7 +1,7 @@ + layout:decorate="~{default}"> diff --git a/src/main/resources/templates/grants/dashboard.html b/src/main/resources/templates/grants/dashboard.html index b469875..12079d4 100644 --- a/src/main/resources/templates/grants/dashboard.html +++ b/src/main/resources/templates/grants/dashboard.html @@ -1,7 +1,7 @@ + layout:decorate="~{default}" xmlns:th="http://www.w3.org/1999/xhtml"> diff --git a/src/main/resources/templates/grants/grant.html b/src/main/resources/templates/grants/grant.html index fc2878d..fe4d755 100644 --- a/src/main/resources/templates/grants/grant.html +++ b/src/main/resources/templates/grants/grant.html @@ -1,7 +1,7 @@ + layout:decorate="~{default}" xmlns:th="http://www.w3.org/1999/xhtml" xmlns="http://www.w3.org/1999/html"> @@ -63,8 +63,7 @@ + $('#addDeadline').click();|"> diff --git a/src/main/resources/templates/grants/grants.html b/src/main/resources/templates/grants/grants.html index 83083a0..627d589 100644 --- a/src/main/resources/templates/grants/grants.html +++ b/src/main/resources/templates/grants/grants.html @@ -1,7 +1,7 @@ + layout:decorate="~{default}" xmlns:th=""> diff --git a/src/main/resources/templates/index.html b/src/main/resources/templates/index.html index 40a1281..a4dbe74 100644 --- a/src/main/resources/templates/index.html +++ b/src/main/resources/templates/index.html @@ -1,7 +1,7 @@ + layout:decorate="~{default}"> diff --git a/src/main/resources/templates/load.html b/src/main/resources/templates/load.html index 70c6314..dbd991a 100644 --- a/src/main/resources/templates/load.html +++ b/src/main/resources/templates/load.html @@ -1,7 +1,7 @@ + layout:decorate="~{default}"> diff --git a/src/main/resources/templates/login.html b/src/main/resources/templates/login.html index 9d87073..48e325e 100644 --- a/src/main/resources/templates/login.html +++ b/src/main/resources/templates/login.html @@ -1,7 +1,7 @@ + layout:decorate="~{default}" xmlns:th="http://www.w3.org/1999/xhtml"> diff --git a/src/main/resources/templates/papers/dashboard.html b/src/main/resources/templates/papers/dashboard.html index b7849f7..b677c84 100644 --- a/src/main/resources/templates/papers/dashboard.html +++ b/src/main/resources/templates/papers/dashboard.html @@ -1,7 +1,7 @@ + layout:decorate="~{default}" xmlns:th="http://www.w3.org/1999/xhtml"> diff --git a/src/main/resources/templates/papers/paper.html b/src/main/resources/templates/papers/paper.html index 6792be2..14befa7 100644 --- a/src/main/resources/templates/papers/paper.html +++ b/src/main/resources/templates/papers/paper.html @@ -1,7 +1,7 @@ + layout:decorate="~{default}" xmlns:th="http://www.w3.org/1999/xhtml" xmlns="http://www.w3.org/1999/html"> @@ -67,7 +67,7 @@ th:onclick="|$('#deadlines${rowStat.index}\\.description').val(''); $('#deadlines${rowStat.index}\\.date').val(''); $('#addDeadline').click();|"> + aria-hidden="true"> diff --git a/src/main/resources/templates/papers/papers.html b/src/main/resources/templates/papers/papers.html index a797d26..d07ca07 100644 --- a/src/main/resources/templates/papers/papers.html +++ b/src/main/resources/templates/papers/papers.html @@ -1,7 +1,7 @@ + layout:decorate="~{default}" xmlns:th=""> diff --git a/src/main/resources/templates/reset.html b/src/main/resources/templates/reset.html index 232e260..c2dd78f 100644 --- a/src/main/resources/templates/reset.html +++ b/src/main/resources/templates/reset.html @@ -2,7 +2,7 @@ + layout:decorate="~{default}"> diff --git a/src/main/resources/templates/resetRequest.html b/src/main/resources/templates/resetRequest.html index 2adab37..ef960f4 100644 --- a/src/main/resources/templates/resetRequest.html +++ b/src/main/resources/templates/resetRequest.html @@ -2,7 +2,7 @@ + layout:decorate="~{default}"> diff --git a/src/main/resources/templates/timeline.html b/src/main/resources/templates/timeline.html index 5eda9f3..0fdaddd 100644 --- a/src/main/resources/templates/timeline.html +++ b/src/main/resources/templates/timeline.html @@ -1,7 +1,7 @@ + layout:decorate="~{default}"> From 993a034527569b3aa180a5914dfbff6b14c8feb6 Mon Sep 17 00:00:00 2001 From: Anton Romanov Date: Wed, 20 Mar 2019 20:32:10 +0400 Subject: [PATCH 04/15] #73 restore authentication --- src/main/java/ru/ulstu/user/util/UserUtils.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/main/java/ru/ulstu/user/util/UserUtils.java b/src/main/java/ru/ulstu/user/util/UserUtils.java index 377db6e..8524c74 100644 --- a/src/main/java/ru/ulstu/user/util/UserUtils.java +++ b/src/main/java/ru/ulstu/user/util/UserUtils.java @@ -23,9 +23,6 @@ public class UserUtils { } final Authentication authentication = securityContext.getAuthentication(); - if (authentication == null) { - return "admin"; - } if (authentication.getPrincipal() instanceof UserDetails) { final UserDetails springSecurityUser = (UserDetails) authentication.getPrincipal(); return springSecurityUser.getUsername(); From 167de9bf656fec34bed94f7526c34504b2f97427 Mon Sep 17 00:00:00 2001 From: Anton Romanov Date: Wed, 20 Mar 2019 20:35:24 +0400 Subject: [PATCH 05/15] #73 fix deprecated parameters --- src/main/resources/application.properties | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 62e6bbc..75bd2a4 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -2,12 +2,11 @@ spring.main.banner-mode=off server.port=8443 server.http.port=8080 -spring.http.multipart.maxFileSize=20MB -spring.http.multipart.maxRequestSize=20MB +multipart.maxFileSize=20MB +multipart.maxRequestSize=20MB # Thymeleaf Settings spring.thymeleaf.cache=false # SSL Settings -security.require-ssl=true server.ssl.key-store=classpath:sample.jks server.ssl.key-store-password=secret server.ssl.key-password=password @@ -25,14 +24,9 @@ spring.mail.properties.mail.smtp.socketFactory.class=javax.net.ssl.SSLSocketFact spring.datasource.url=jdbc:postgresql://localhost:5432/ng-tracker 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 +spring.jpa.properties.hibernate.temp.use_jdbc_metadata_defaults = false # Liquibase Settings -#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 From 09cae66ca4126465f503c71ee4766c4cb1596d2d Mon Sep 17 00:00:00 2001 From: Anton Romanov Date: Tue, 23 Apr 2019 12:38:15 +0400 Subject: [PATCH 06/15] fix image --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0effceb..1901408 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,4 +1,4 @@ -image: romanov73/is:ng-tracker-container +image: romanov73/is:ng-tracker-container-11 variables: GRADLE_OPTS: "-Dorg.gradle.daemon=false" From e16b1da7613a1b20b1cce97d1962d695d905f980 Mon Sep 17 00:00:00 2001 From: Anton Romanov Date: Tue, 23 Apr 2019 12:46:17 +0400 Subject: [PATCH 07/15] fix script --- .gitlab-ci.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1901408..b064dce 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -6,11 +6,11 @@ variables: before_script: - service postgresql stop - service postgresql start - - eval $(ssh-agent -s) - - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null - - mkdir -p ~/.ssh - - chmod 700 ~/.ssh - - git log --pretty="%cn;%cd;%s" > src/main/resources/commits.log + - eval $(ssh-agent -s) + - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null + - mkdir -p ~/.ssh + - chmod 700 ~/.ssh + - git log --pretty="%cn;%cd;%s" > src/main/resources/commits.log build: stage: build From 955bdaa4381945dc8e1d34120ec26ed5089367cb Mon Sep 17 00:00:00 2001 From: Anton Romanov Date: Tue, 23 Apr 2019 13:55:59 +0400 Subject: [PATCH 08/15] fix repository method --- src/main/java/ru/ulstu/project/service/ProjectService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/ru/ulstu/project/service/ProjectService.java b/src/main/java/ru/ulstu/project/service/ProjectService.java index e2feef4..115f5ae 100644 --- a/src/main/java/ru/ulstu/project/service/ProjectService.java +++ b/src/main/java/ru/ulstu/project/service/ProjectService.java @@ -67,7 +67,7 @@ public class ProjectService { project.setStatus(projectDto.getStatus() == null ? APPLICATION : projectDto.getStatus()); project.setTitle(projectDto.getTitle()); if (projectDto.getGrant() != null && projectDto.getGrant().getId() != null) { - project.setGrant(grantRepository.findOne(projectDto.getGrant().getId())); + project.setGrant(grantRepository.getOne(projectDto.getGrant().getId())); } project.setRepository(projectDto.getRepository()); project.setDeadlines(deadlineService.saveOrCreate(projectDto.getDeadlines())); From 9393fbe326c2e5c6260dc0c557f8a7465e566b7a Mon Sep 17 00:00:00 2001 From: Anton Romanov Date: Fri, 26 Apr 2019 09:46:38 +0400 Subject: [PATCH 09/15] fix deprecated imports --- src/main/java/ru/ulstu/conference/model/Conference.java | 2 +- src/main/java/ru/ulstu/conference/model/ConferenceDto.java | 2 +- src/main/java/ru/ulstu/students/model/Task.java | 2 +- src/main/java/ru/ulstu/students/model/TaskDto.java | 2 +- src/main/java/ru/ulstu/tags/model/Tag.java | 2 +- src/main/java/ru/ulstu/timeline/model/Event.java | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/ru/ulstu/conference/model/Conference.java b/src/main/java/ru/ulstu/conference/model/Conference.java index e252e4d..9831a0e 100644 --- a/src/main/java/ru/ulstu/conference/model/Conference.java +++ b/src/main/java/ru/ulstu/conference/model/Conference.java @@ -2,7 +2,6 @@ package ru.ulstu.conference.model; import org.hibernate.annotations.Fetch; import org.hibernate.annotations.FetchMode; -import org.hibernate.validator.constraints.NotBlank; import org.springframework.format.annotation.DateTimeFormat; import ru.ulstu.core.model.BaseEntity; import ru.ulstu.deadline.model.Deadline; @@ -20,6 +19,7 @@ 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.Date; import java.util.List; diff --git a/src/main/java/ru/ulstu/conference/model/ConferenceDto.java b/src/main/java/ru/ulstu/conference/model/ConferenceDto.java index 2e2f13b..5eca110 100644 --- a/src/main/java/ru/ulstu/conference/model/ConferenceDto.java +++ b/src/main/java/ru/ulstu/conference/model/ConferenceDto.java @@ -2,13 +2,13 @@ package ru.ulstu.conference.model; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; -import org.hibernate.validator.constraints.NotEmpty; import org.springframework.format.annotation.DateTimeFormat; import ru.ulstu.deadline.model.Deadline; import ru.ulstu.paper.model.Paper; import javax.persistence.Temporal; import javax.persistence.TemporalType; +import javax.validation.constraints.NotEmpty; import javax.validation.constraints.Size; import java.util.ArrayList; import java.util.Date; diff --git a/src/main/java/ru/ulstu/students/model/Task.java b/src/main/java/ru/ulstu/students/model/Task.java index c4d7409..5646ef3 100644 --- a/src/main/java/ru/ulstu/students/model/Task.java +++ b/src/main/java/ru/ulstu/students/model/Task.java @@ -2,7 +2,6 @@ package ru.ulstu.students.model; import org.hibernate.annotations.Fetch; import org.hibernate.annotations.FetchMode; -import org.hibernate.validator.constraints.NotBlank; import ru.ulstu.core.model.BaseEntity; import ru.ulstu.deadline.model.Deadline; import ru.ulstu.tags.model.Tag; @@ -20,6 +19,7 @@ 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.Date; import java.util.List; diff --git a/src/main/java/ru/ulstu/students/model/TaskDto.java b/src/main/java/ru/ulstu/students/model/TaskDto.java index 941a6df..5071dab 100644 --- a/src/main/java/ru/ulstu/students/model/TaskDto.java +++ b/src/main/java/ru/ulstu/students/model/TaskDto.java @@ -3,10 +3,10 @@ package ru.ulstu.students.model; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import org.apache.commons.lang3.StringUtils; -import org.hibernate.validator.constraints.NotEmpty; import ru.ulstu.deadline.model.Deadline; import ru.ulstu.tags.model.Tag; +import javax.validation.constraints.NotEmpty; import java.util.ArrayList; import java.util.Date; import java.util.List; diff --git a/src/main/java/ru/ulstu/tags/model/Tag.java b/src/main/java/ru/ulstu/tags/model/Tag.java index aed000f..460e9b0 100644 --- a/src/main/java/ru/ulstu/tags/model/Tag.java +++ b/src/main/java/ru/ulstu/tags/model/Tag.java @@ -2,12 +2,12 @@ package ru.ulstu.tags.model; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; -import org.hibernate.validator.constraints.NotEmpty; 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; @Entity diff --git a/src/main/java/ru/ulstu/timeline/model/Event.java b/src/main/java/ru/ulstu/timeline/model/Event.java index ef0a4b8..f8fd179 100644 --- a/src/main/java/ru/ulstu/timeline/model/Event.java +++ b/src/main/java/ru/ulstu/timeline/model/Event.java @@ -1,6 +1,5 @@ package ru.ulstu.timeline.model; -import org.hibernate.validator.constraints.NotBlank; import ru.ulstu.core.model.BaseEntity; import ru.ulstu.paper.model.Paper; import ru.ulstu.user.model.User; @@ -17,6 +16,7 @@ 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.Date; import java.util.List; From 4d2d7fa1133834c574ab616ebbb5d55b2bc49d60 Mon Sep 17 00:00:00 2001 From: Anton Romanov Date: Fri, 26 Apr 2019 09:47:41 +0400 Subject: [PATCH 10/15] fix lambda --- src/main/java/ru/ulstu/conference/model/ConferenceDto.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/ru/ulstu/conference/model/ConferenceDto.java b/src/main/java/ru/ulstu/conference/model/ConferenceDto.java index 5eca110..6264f62 100644 --- a/src/main/java/ru/ulstu/conference/model/ConferenceDto.java +++ b/src/main/java/ru/ulstu/conference/model/ConferenceDto.java @@ -3,6 +3,7 @@ package ru.ulstu.conference.model; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import org.springframework.format.annotation.DateTimeFormat; +import ru.ulstu.core.model.BaseEntity; import ru.ulstu.deadline.model.Deadline; import ru.ulstu.paper.model.Paper; @@ -88,8 +89,8 @@ public class ConferenceDto { this.beginDate = conference.getBeginDate(); this.endDate = conference.getEndDate(); this.deadlines = conference.getDeadlines(); - this.userIds = convert(conference.getUsers(), user -> user.getId()); - this.paperIds = convert(conference.getPapers(), paper -> paper.getId()); + this.userIds = convert(conference.getUsers(), BaseEntity::getId); + this.paperIds = convert(conference.getPapers(), BaseEntity::getId); this.users = conference.getUsers(); this.papers = conference.getPapers(); } From 24f447aed7bf7eab09b80b6d9b03b8b794b68761 Mon Sep 17 00:00:00 2001 From: Anton Romanov Date: Sat, 22 Jun 2019 11:58:01 +0400 Subject: [PATCH 11/15] fix tests --- build.gradle | 4 ++-- .../conference/service/ConferenceServiceTest.java | 10 +++++----- .../ru/ulstu/grant/service/GrantServiceTest.java | 14 +++++++------- .../ulstu/project/service/ProjectServiceTest.java | 10 +++++----- .../ru/ulstu/students/service/TaskServiceTest.java | 9 ++++----- 5 files changed, 23 insertions(+), 24 deletions(-) diff --git a/build.gradle b/build.gradle index 0373cfc..959c4a2 100644 --- a/build.gradle +++ b/build.gradle @@ -130,6 +130,6 @@ dependencies { testCompile group: 'org.springframework.boot', name: 'spring-boot-starter-test' compile group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '3.3.1' testCompile group: 'org.seleniumhq.selenium', name: 'selenium-support', version: '3.3.1' - testCompile group: 'com.google.guava', name: 'guava', version: '21.0' - + //testCompile group: 'com.google.guava', name: 'guava', version: '21.0' + testCompile group: 'org.mockito', name: 'mockito-all', version: '1.10.19' } \ No newline at end of file diff --git a/src/test/java/ru/ulstu/conference/service/ConferenceServiceTest.java b/src/test/java/ru/ulstu/conference/service/ConferenceServiceTest.java index d4640b1..56756a3 100644 --- a/src/test/java/ru/ulstu/conference/service/ConferenceServiceTest.java +++ b/src/test/java/ru/ulstu/conference/service/ConferenceServiceTest.java @@ -5,8 +5,8 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InjectMocks; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; import org.springframework.data.domain.Sort; +import org.springframework.test.context.junit4.SpringRunner; import ru.ulstu.conference.model.Conference; import ru.ulstu.conference.model.ConferenceDto; import ru.ulstu.conference.model.ConferenceFilterDto; @@ -31,7 +31,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.when; -@RunWith(MockitoJUnitRunner.class) +@RunWith(SpringRunner.class) public class ConferenceServiceTest { @Mock @@ -124,7 +124,7 @@ public class ConferenceServiceTest { @Test public void getExistConferenceById() { - when(conferenceRepository.findOne(ID)).thenReturn(conferenceWithId); + when(conferenceRepository.getOne(ID)).thenReturn(conferenceWithId); when(paperService.findAllNotSelect(new ArrayList<>())).thenReturn(papers); when(userService.getCurrentUser()).thenReturn(user); @@ -185,8 +185,8 @@ public class ConferenceServiceTest { @Test public void delete() { - when(conferenceRepository.exists(ID)).thenReturn(true); - when(conferenceRepository.findOne(ID)).thenReturn(conferenceWithId); + when(conferenceRepository.existsById(ID)).thenReturn(true); + when(conferenceRepository.getOne(ID)).thenReturn(conferenceWithId); assertTrue(conferenceService.delete(ID)); } diff --git a/src/test/java/ru/ulstu/grant/service/GrantServiceTest.java b/src/test/java/ru/ulstu/grant/service/GrantServiceTest.java index 99d7ef6..98f39e1 100644 --- a/src/test/java/ru/ulstu/grant/service/GrantServiceTest.java +++ b/src/test/java/ru/ulstu/grant/service/GrantServiceTest.java @@ -7,7 +7,7 @@ import org.junit.runner.RunWith; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.runners.MockitoJUnitRunner; +import org.springframework.test.context.junit4.SpringRunner; import ru.ulstu.deadline.model.Deadline; import ru.ulstu.deadline.service.DeadlineService; import ru.ulstu.grant.model.Grant; @@ -34,7 +34,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.when; -@RunWith(MockitoJUnitRunner.class) +@RunWith(SpringRunner.class) public class GrantServiceTest { @Mock @@ -123,7 +123,7 @@ public class GrantServiceTest { @Test public void getExistGrantById() { - when(grantRepository.findOne(ID)).thenReturn(grantWithId); + when(grantRepository.getOne(ID)).thenReturn(grantWithId); GrantDto newGrantDto = new GrantDto(grantWithId); GrantDto result = grantService.getExistGrantById(ID); @@ -179,7 +179,7 @@ public class GrantServiceTest { @Test public void delete() throws IOException { - when(grantRepository.findOne(ID)).thenReturn(grantWithId); + when(grantRepository.getOne(ID)).thenReturn(grantWithId); assertTrue(grantService.delete(grantWithId.getId())); } @@ -195,7 +195,7 @@ public class GrantServiceTest { @Test public void findById() { - when(grantRepository.findOne(ID)).thenReturn(grantWithId); + when(grantRepository.getOne(ID)).thenReturn(grantWithId); Grant findGrant = grantService.findById(ID); assertEquals(grantWithId.getId(), findGrant.getId()); @@ -203,7 +203,7 @@ public class GrantServiceTest { @Test public void attachPaper() { - when(grantRepository.findOne(ID)).thenReturn(grantWithId); + when(grantRepository.getOne(ID)).thenReturn(grantWithId); when(paperService.findAllSelect(Collections.singletonList(ID))).thenReturn(paperDtos); GrantDto newGrantDto = new GrantDto(grantWithId); @@ -219,7 +219,7 @@ public class GrantServiceTest { @Test public void filterEmptyDeadlines() { - when(grantRepository.findOne(ID)).thenReturn(grantWithId); + when(grantRepository.getOne(ID)).thenReturn(grantWithId); GrantDto newGrantDto = new GrantDto(grantWithId); newGrantDto.setDeadlines(newGrantDto.getDeadlines().stream() diff --git a/src/test/java/ru/ulstu/project/service/ProjectServiceTest.java b/src/test/java/ru/ulstu/project/service/ProjectServiceTest.java index 25a201b..878fcda 100644 --- a/src/test/java/ru/ulstu/project/service/ProjectServiceTest.java +++ b/src/test/java/ru/ulstu/project/service/ProjectServiceTest.java @@ -5,7 +5,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InjectMocks; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; +import org.springframework.test.context.junit4.SpringRunner; import ru.ulstu.deadline.model.Deadline; import ru.ulstu.deadline.service.DeadlineService; import ru.ulstu.file.model.FileData; @@ -29,7 +29,7 @@ import static junit.framework.TestCase.assertTrue; import static org.junit.Assert.assertEquals; import static org.mockito.Mockito.when; -@RunWith(MockitoJUnitRunner.class) +@RunWith(SpringRunner.class) public class ProjectServiceTest { @Mock @@ -118,8 +118,8 @@ public class ProjectServiceTest { @Test public void delete() throws IOException { - when(projectRepository.exists(ID)).thenReturn(true); - when(projectRepository.findOne(ID)).thenReturn(project); + when(projectRepository.existsById(ID)).thenReturn(true); + when(projectRepository.getOne(ID)).thenReturn(project); assertTrue(projectService.delete(ID)); } @@ -134,7 +134,7 @@ public class ProjectServiceTest { @Test public void findById() { - when(projectRepository.findOne(ID)).thenReturn(project); + when(projectRepository.getOne(ID)).thenReturn(project); assertEquals(project, projectService.findById(ID)); } diff --git a/src/test/java/ru/ulstu/students/service/TaskServiceTest.java b/src/test/java/ru/ulstu/students/service/TaskServiceTest.java index d3db954..97b9990 100644 --- a/src/test/java/ru/ulstu/students/service/TaskServiceTest.java +++ b/src/test/java/ru/ulstu/students/service/TaskServiceTest.java @@ -5,8 +5,8 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InjectMocks; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; import org.springframework.data.domain.Sort; +import org.springframework.test.context.junit4.SpringRunner; import ru.ulstu.core.util.DateUtils; import ru.ulstu.deadline.model.Deadline; import ru.ulstu.deadline.service.DeadlineService; @@ -32,7 +32,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.when; -@RunWith(MockitoJUnitRunner.class) +@RunWith(SpringRunner.class) public class TaskServiceTest { @Mock @@ -113,7 +113,6 @@ public class TaskServiceTest { @Test public void findAll() { - when(taskRepository.findAll(SORT)).thenReturn(tasks); assertEquals(Collections.singletonList(task), taskService.findAll()); } @@ -153,8 +152,8 @@ public class TaskServiceTest { @Test public void delete() throws IOException { - when(taskRepository.exists(ID)).thenReturn(true); - when(taskRepository.findOne(ID)).thenReturn(task); + when(taskRepository.existsById(ID)).thenReturn(true); + when(taskRepository.getOne(ID)).thenReturn(task); when(schedulerRepository.findOneByTask(task)).thenReturn(null); assertTrue(taskService.delete(ID)); From df1bf873ff5b6ac212f1d8b6ff631c540de5f7d2 Mon Sep 17 00:00:00 2001 From: Anton Romanov Date: Sat, 22 Jun 2019 13:31:53 +0400 Subject: [PATCH 12/15] fix warnings --- .../commit/controller/CommitController.java | 9 +- .../conference/model/ConferenceUser.java | 4 +- .../ConferenceNotificationService.java | 6 +- .../conference/service/ConferenceService.java | 5 +- .../service/ConferenceUserService.java | 4 +- .../MailTemplateConfiguration.java | 2 +- .../core/controller/AdviceController.java | 5 + .../ulstu/core/jpa/OffsetablePageRequest.java | 2 +- .../java/ru/ulstu/core/model/BaseEntity.java | 11 +- .../ru/ulstu/core/model/ErrorConstants.java | 4 +- .../java/ru/ulstu/core/model/TreeDto.java | 34 ------ .../java/ru/ulstu/core/model/TreeEntity.java | 16 --- .../model/response/ControllerResponse.java | 4 +- .../response/ControllerResponseError.java | 4 +- .../JpaDetachableRepositoryImpl.java | 2 +- .../java/ru/ulstu/core/util/NumberUtils.java | 17 --- .../ru/ulstu/core/util/StreamApiUtils.java | 4 +- .../deadline/service/DeadlineService.java | 2 +- .../java/ru/ulstu/file/FileController.java | 7 +- .../ru/ulstu/file/service/FileService.java | 14 +-- src/main/java/ru/ulstu/grant/model/Grant.java | 2 +- .../ru/ulstu/grant/service/GrantService.java | 9 +- .../ru/ulstu/grant/service/KiasService.java | 4 +- src/main/java/ru/ulstu/name/BaseService.java | 6 +- .../ulstu/odin/controller/OdinController.java | 6 +- .../ulstu/odin/model/OdinCollectionField.java | 5 +- .../java/ru/ulstu/odin/model/OdinField.java | 19 ++-- .../ru/ulstu/odin/model/OdinObjectField.java | 5 +- .../controller/OdinExampleController.java | 4 - .../odinexample/model/OdinExampleDto.java | 4 - .../odinexample/model/OdinExampleListDto.java | 103 ------------------ .../service/OdinExampleService.java | 4 - .../paper/controller/PaperRestController.java | 4 +- ...PaperConferenceRelationExistException.java | 7 -- src/main/java/ru/ulstu/paper/model/Paper.java | 6 +- .../ru/ulstu/paper/model/ReferenceDto.java | 4 +- .../ru/ulstu/paper/service/LatexService.java | 12 +- .../ru/ulstu/paper/service/PaperService.java | 12 +- .../ru/ulstu/ping/service/PingService.java | 2 - .../java/ru/ulstu/project/model/Project.java | 2 +- .../ulstu/project/service/ProjectService.java | 10 +- .../strategy/api/EntityCreateStrategy.java | 2 +- .../ulstu/students/controller/Navigation.java | 2 +- .../java/ru/ulstu/students/model/Task.java | 11 +- .../ulstu/students/service/TaskService.java | 2 +- .../ru/ulstu/tags/service/TagService.java | 6 +- .../timeline/controller/EventController.java | 17 ++- .../java/ru/ulstu/timeline/model/Event.java | 2 +- .../ulstu/timeline/model/EventStatusDto.java | 19 ---- .../ru/ulstu/timeline/model/PeriodEvent.java | 4 +- .../ulstu/timeline/service/EventService.java | 4 +- .../user/component/IpAddressResolver.java | 2 +- .../ulstu/user/controller/UserController.java | 6 +- .../user/controller/UserMvcController.java | 7 -- src/main/java/ru/ulstu/user/model/User.java | 2 +- .../java/ru/ulstu/user/model/UserDto.java | 6 +- .../java/ru/ulstu/user/model/UserListDto.java | 14 +-- .../ulstu/user/model/UserSessionListDto.java | 12 +- .../ru/ulstu/user/service/MailService.java | 6 +- .../ru/ulstu/user/service/UserMapper.java | 2 +- .../ru/ulstu/user/service/UserService.java | 4 +- .../utils/timetable/TimetableService.java | 4 +- src/main/resources/public/css/agency.css | 2 +- src/main/resources/public/css/conference.css | 8 +- src/main/resources/public/css/grant.css | 4 +- src/main/resources/public/css/odin.css | 3 +- src/main/resources/public/css/tasks.css | 2 +- src/main/resources/public/js/core.js | 5 - src/main/resources/public/templates/odin.html | 2 +- src/test/java/PaperTest.java | 12 +- src/test/java/conference/ConferencePage.java | 2 +- src/test/java/context/Context.java | 8 +- src/test/java/core/TestTemplate.java | 2 +- src/test/java/grant/GrantPage.java | 2 +- src/test/java/project/ProjectPage.java | 6 +- src/test/java/project/ProjectsPage.java | 2 +- .../ulstu/grant/service/GrantServiceTest.java | 18 +-- .../project/service/ProjectServiceTest.java | 6 +- src/test/java/students/TaskPage.java | 2 +- src/test/java/students/TasksPage.java | 2 +- 80 files changed, 177 insertions(+), 431 deletions(-) delete mode 100644 src/main/java/ru/ulstu/core/model/TreeDto.java delete mode 100644 src/main/java/ru/ulstu/core/model/TreeEntity.java delete mode 100644 src/main/java/ru/ulstu/core/util/NumberUtils.java delete mode 100644 src/main/java/ru/ulstu/odinexample/controller/OdinExampleController.java delete mode 100644 src/main/java/ru/ulstu/odinexample/model/OdinExampleDto.java delete mode 100644 src/main/java/ru/ulstu/odinexample/model/OdinExampleListDto.java delete mode 100644 src/main/java/ru/ulstu/odinexample/service/OdinExampleService.java delete mode 100644 src/main/java/ru/ulstu/paper/error/PaperConferenceRelationExistException.java delete mode 100644 src/main/java/ru/ulstu/timeline/model/EventStatusDto.java diff --git a/src/main/java/ru/ulstu/commit/controller/CommitController.java b/src/main/java/ru/ulstu/commit/controller/CommitController.java index 44f99cb..3d929a4 100644 --- a/src/main/java/ru/ulstu/commit/controller/CommitController.java +++ b/src/main/java/ru/ulstu/commit/controller/CommitController.java @@ -4,20 +4,17 @@ import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -import ru.ulstu.configuration.Constants; -import ru.ulstu.core.model.response.PageableItems; import ru.ulstu.commit.model.CommitListDto; import ru.ulstu.commit.service.CommitService; +import ru.ulstu.configuration.Constants; +import ru.ulstu.core.model.response.PageableItems; import ru.ulstu.core.model.response.Response; import ru.ulstu.odin.controller.OdinController; import ru.ulstu.odin.model.OdinVoid; -import static ru.ulstu.commit.controller.CommitController.URL; - @RestController -@RequestMapping(URL) +@RequestMapping(Constants.API_1_0 + "commits") public class CommitController extends OdinController { - public static final String URL = Constants.API_1_0 + "commits"; private final CommitService commitService; public CommitController(CommitService commitService) { diff --git a/src/main/java/ru/ulstu/conference/model/ConferenceUser.java b/src/main/java/ru/ulstu/conference/model/ConferenceUser.java index 63eeb6d..f00b9fa 100644 --- a/src/main/java/ru/ulstu/conference/model/ConferenceUser.java +++ b/src/main/java/ru/ulstu/conference/model/ConferenceUser.java @@ -22,7 +22,7 @@ public class ConferenceUser extends BaseEntity { INTRAMURAL("Очная"), EXTRAMURAL("Заочная"); - private String participationName; + private final String participationName; Participation(String name) { this.participationName = name; @@ -38,7 +38,7 @@ public class ConferenceUser extends BaseEntity { REPORT("Доклад"), PRESENTATION("Презентация"); - private String depositName; + private final String depositName; Deposit(String name) { this.depositName = name; diff --git a/src/main/java/ru/ulstu/conference/service/ConferenceNotificationService.java b/src/main/java/ru/ulstu/conference/service/ConferenceNotificationService.java index ddb8130..961d369 100644 --- a/src/main/java/ru/ulstu/conference/service/ConferenceNotificationService.java +++ b/src/main/java/ru/ulstu/conference/service/ConferenceNotificationService.java @@ -63,7 +63,7 @@ public class ConferenceNotificationService { public void sendCreateNotification(Conference conference) { Map variables = ImmutableMap.of("conference", conference); - sendForAllUsers(variables, TEMPLATE_CREATE, String.format(TITLE_CREATE, conference.getTitle())); + sendForAllUsers(variables, String.format(TITLE_CREATE, conference.getTitle())); } public void updateDeadlineNotification(Conference conference) { @@ -76,8 +76,8 @@ public class ConferenceNotificationService { sendForAllParticipants(variables, conference, TEMPLATE_UPDATE_DATES, String.format(TITLE_UPDATE_DATES, conference.getTitle())); } - private void sendForAllUsers(Map variables, String template, String title) { - userService.findAll().forEach(user -> mailService.sendEmailFromTemplate(variables, user, template, title)); + private void sendForAllUsers(Map variables, String title) { + userService.findAll().forEach(user -> mailService.sendEmailFromTemplate(variables, user, ConferenceNotificationService.TEMPLATE_CREATE, title)); } private void sendForAllParticipants(Map variables, Conference conference, String template, String title) { diff --git a/src/main/java/ru/ulstu/conference/service/ConferenceService.java b/src/main/java/ru/ulstu/conference/service/ConferenceService.java index c605378..470e712 100644 --- a/src/main/java/ru/ulstu/conference/service/ConferenceService.java +++ b/src/main/java/ru/ulstu/conference/service/ConferenceService.java @@ -96,7 +96,6 @@ public class ConferenceService extends BaseService { checkUniqueName(conferenceDto, errors, conferenceDto.getId(), - "title", "Конференция с таким именем уже существует"); if (errors.hasErrors()) { return false; @@ -121,7 +120,7 @@ public class ConferenceService extends BaseService { } @Transactional - public Conference update(ConferenceDto conferenceDto) throws IOException { + private Conference update(ConferenceDto conferenceDto) throws IOException { Conference conference = conferenceRepository.getOne(conferenceDto.getId()); List oldDeadlines = conference.getDeadlines().stream() .map(this::copyDeadline) @@ -293,7 +292,7 @@ public class ConferenceService extends BaseService { return newDeadline; } - public void checkEmptyFieldsOfDeadline(ConferenceDto conferenceDto, Errors errors) { + private void checkEmptyFieldsOfDeadline(ConferenceDto conferenceDto, Errors errors) { for (Deadline deadline : conferenceDto.getDeadlines()) { if (deadline.getDate() == null || deadline.getDescription().isEmpty()) { errors.rejectValue("deadlines", "errorCode", "Все поля дедлайна должны быть заполнены"); diff --git a/src/main/java/ru/ulstu/conference/service/ConferenceUserService.java b/src/main/java/ru/ulstu/conference/service/ConferenceUserService.java index bd1b719..01d02d6 100644 --- a/src/main/java/ru/ulstu/conference/service/ConferenceUserService.java +++ b/src/main/java/ru/ulstu/conference/service/ConferenceUserService.java @@ -26,7 +26,7 @@ public class ConferenceUserService { } @Transactional - public ConferenceUser update(ConferenceUser user) { + private ConferenceUser update(ConferenceUser user) { ConferenceUser updateUser = conferenceUserRepository.getOne(user.getId()); updateUser.setDeposit(user.getDeposit()); updateUser.setParticipation(user.getParticipation()); @@ -35,7 +35,7 @@ public class ConferenceUserService { } @Transactional - public ConferenceUser create(ConferenceUser user) { + private ConferenceUser create(ConferenceUser user) { ConferenceUser newUser = new ConferenceUser(); newUser.setDeposit(user.getDeposit()); newUser.setParticipation(user.getParticipation()); diff --git a/src/main/java/ru/ulstu/configuration/MailTemplateConfiguration.java b/src/main/java/ru/ulstu/configuration/MailTemplateConfiguration.java index 31de65c..5df2377 100644 --- a/src/main/java/ru/ulstu/configuration/MailTemplateConfiguration.java +++ b/src/main/java/ru/ulstu/configuration/MailTemplateConfiguration.java @@ -22,7 +22,7 @@ public class MailTemplateConfiguration { return templateEngine; } - public ClassLoaderTemplateResolver emailTemplateResolver() { + private ClassLoaderTemplateResolver emailTemplateResolver() { ClassLoaderTemplateResolver emailTemplateResolver = new ClassLoaderTemplateResolver(); emailTemplateResolver.setPrefix("/mail_templates/"); emailTemplateResolver.setTemplateMode("HTML"); diff --git a/src/main/java/ru/ulstu/core/controller/AdviceController.java b/src/main/java/ru/ulstu/core/controller/AdviceController.java index f89001a..27c9d5b 100644 --- a/src/main/java/ru/ulstu/core/controller/AdviceController.java +++ b/src/main/java/ru/ulstu/core/controller/AdviceController.java @@ -35,6 +35,11 @@ public class AdviceController { this.userService = userService; } + @ModelAttribute("currentUser") + public String getCurrentUser() { + return userService.getCurrentUser().getUserAbbreviate(); + } + @ModelAttribute("flashMessage") public String getFlashMessage() { return null; diff --git a/src/main/java/ru/ulstu/core/jpa/OffsetablePageRequest.java b/src/main/java/ru/ulstu/core/jpa/OffsetablePageRequest.java index af3be5c..148a931 100644 --- a/src/main/java/ru/ulstu/core/jpa/OffsetablePageRequest.java +++ b/src/main/java/ru/ulstu/core/jpa/OffsetablePageRequest.java @@ -65,7 +65,7 @@ public class OffsetablePageRequest implements Pageable, Serializable { return hasPrevious() ? previous() : first(); } - public Pageable previous() { + private Pageable previous() { return getOffset() == 0 ? this : new OffsetablePageRequest(getOffset() - getPageSize(), getPageSize(), getSort()); } diff --git a/src/main/java/ru/ulstu/core/model/BaseEntity.java b/src/main/java/ru/ulstu/core/model/BaseEntity.java index d3dfa76..6a68e91 100644 --- a/src/main/java/ru/ulstu/core/model/BaseEntity.java +++ b/src/main/java/ru/ulstu/core/model/BaseEntity.java @@ -16,7 +16,7 @@ public abstract class BaseEntity implements Serializable, Comparable { @Version private Integer version; - public BaseEntity() { + protected BaseEntity() { } public BaseEntity(Integer id, Integer version) { @@ -49,13 +49,8 @@ public abstract class BaseEntity implements Serializable, Comparable { } BaseEntity other = (BaseEntity) obj; if (id == null) { - if (other.id != null) { - return false; - } - } else if (!id.equals(other.id)) { - return false; - } - return true; + return other.id == null; + } else return id.equals(other.id); } @Override diff --git a/src/main/java/ru/ulstu/core/model/ErrorConstants.java b/src/main/java/ru/ulstu/core/model/ErrorConstants.java index 017725a..59f34fa 100644 --- a/src/main/java/ru/ulstu/core/model/ErrorConstants.java +++ b/src/main/java/ru/ulstu/core/model/ErrorConstants.java @@ -16,8 +16,8 @@ public enum ErrorConstants { FILE_UPLOAD_ERROR(110, "File upload error"), USER_SENDING_MAIL_EXCEPTION(111, "Во время отправки приглашения пользователю произошла ошибка"); - private int code; - private String message; + private final int code; + private final String message; ErrorConstants(int code, String message) { this.code = code; diff --git a/src/main/java/ru/ulstu/core/model/TreeDto.java b/src/main/java/ru/ulstu/core/model/TreeDto.java deleted file mode 100644 index 491553c..0000000 --- a/src/main/java/ru/ulstu/core/model/TreeDto.java +++ /dev/null @@ -1,34 +0,0 @@ -package ru.ulstu.core.model; - -import java.util.ArrayList; -import java.util.List; - -public class TreeDto { - private Integer id; - private String text; - private List children = new ArrayList<>(); - - public TreeDto() { - } - - public TreeDto(TreeEntity item) { - this.text = item.toString(); - this.id = item.getId(); - } - - public TreeDto(String rootName) { - this.text = rootName; - } - - public String getText() { - return text; - } - - public List getChildren() { - return children; - } - - public Integer getId() { - return id; - } -} diff --git a/src/main/java/ru/ulstu/core/model/TreeEntity.java b/src/main/java/ru/ulstu/core/model/TreeEntity.java deleted file mode 100644 index 48f1202..0000000 --- a/src/main/java/ru/ulstu/core/model/TreeEntity.java +++ /dev/null @@ -1,16 +0,0 @@ -package ru.ulstu.core.model; - -import java.util.List; - -public interface TreeEntity { - - Integer getId(); - - List getChildren(); - - void setChildren(List children); - - T getParent(); - - void setParent(T parent); -} diff --git a/src/main/java/ru/ulstu/core/model/response/ControllerResponse.java b/src/main/java/ru/ulstu/core/model/response/ControllerResponse.java index 72c5ebf..52ede55 100644 --- a/src/main/java/ru/ulstu/core/model/response/ControllerResponse.java +++ b/src/main/java/ru/ulstu/core/model/response/ControllerResponse.java @@ -1,8 +1,8 @@ package ru.ulstu.core.model.response; class ControllerResponse { - private D data; - private ControllerResponseError error; + private final D data; + private final ControllerResponseError error; ControllerResponse(D data) { this.data = data; diff --git a/src/main/java/ru/ulstu/core/model/response/ControllerResponseError.java b/src/main/java/ru/ulstu/core/model/response/ControllerResponseError.java index a26b088..48661b6 100644 --- a/src/main/java/ru/ulstu/core/model/response/ControllerResponseError.java +++ b/src/main/java/ru/ulstu/core/model/response/ControllerResponseError.java @@ -3,8 +3,8 @@ package ru.ulstu.core.model.response; import ru.ulstu.core.model.ErrorConstants; class ControllerResponseError { - private ErrorConstants description; - private D data; + private final ErrorConstants description; + private final D data; ControllerResponseError(ErrorConstants description, D data) { this.description = description; diff --git a/src/main/java/ru/ulstu/core/repository/JpaDetachableRepositoryImpl.java b/src/main/java/ru/ulstu/core/repository/JpaDetachableRepositoryImpl.java index 097a2a5..facc071 100644 --- a/src/main/java/ru/ulstu/core/repository/JpaDetachableRepositoryImpl.java +++ b/src/main/java/ru/ulstu/core/repository/JpaDetachableRepositoryImpl.java @@ -8,7 +8,7 @@ import java.io.Serializable; public class JpaDetachableRepositoryImpl extends SimpleJpaRepository implements JpaDetachableRepository { - private EntityManager entityManager; + private final EntityManager entityManager; public JpaDetachableRepositoryImpl(JpaEntityInformation entityInformation, EntityManager entityManager) { super(entityInformation, entityManager); diff --git a/src/main/java/ru/ulstu/core/util/NumberUtils.java b/src/main/java/ru/ulstu/core/util/NumberUtils.java deleted file mode 100644 index 5e002cd..0000000 --- a/src/main/java/ru/ulstu/core/util/NumberUtils.java +++ /dev/null @@ -1,17 +0,0 @@ -package ru.ulstu.core.util; - -public class NumberUtils { - public static Double ceil(Double number) { - if (number == null) { - return 0.0; - } - return Double.valueOf(Math.ceil(number)); - } - - public static Double round(Double number) { - if (number == null) { - return 0.0; - } - return Double.valueOf(Math.ceil(number * 100)) / 100; - } -} diff --git a/src/main/java/ru/ulstu/core/util/StreamApiUtils.java b/src/main/java/ru/ulstu/core/util/StreamApiUtils.java index ab8d66f..9a6e58d 100644 --- a/src/main/java/ru/ulstu/core/util/StreamApiUtils.java +++ b/src/main/java/ru/ulstu/core/util/StreamApiUtils.java @@ -11,12 +11,12 @@ public class StreamApiUtils { public static List convert(List entities, Function converter) { return entities == null ? Collections.emptyList() - : entities.stream().map(e -> converter.apply(e)).collect(Collectors.toList()); + : entities.stream().map(converter).collect(Collectors.toList()); } public static Set convert(Set entities, Function converter) { return entities == null ? Collections.emptySet() - : entities.stream().map(e -> converter.apply(e)).collect(Collectors.toSet()); + : entities.stream().map(converter).collect(Collectors.toSet()); } } diff --git a/src/main/java/ru/ulstu/deadline/service/DeadlineService.java b/src/main/java/ru/ulstu/deadline/service/DeadlineService.java index 4bd3b0c..039ddbf 100644 --- a/src/main/java/ru/ulstu/deadline/service/DeadlineService.java +++ b/src/main/java/ru/ulstu/deadline/service/DeadlineService.java @@ -26,7 +26,7 @@ public class DeadlineService { } @Transactional - public Deadline update(Deadline deadline) { + private Deadline update(Deadline deadline) { Deadline updateDeadline = deadlineRepository.getOne(deadline.getId()); updateDeadline.setDate(deadline.getDate()); updateDeadline.setDescription(deadline.getDescription()); diff --git a/src/main/java/ru/ulstu/file/FileController.java b/src/main/java/ru/ulstu/file/FileController.java index ac08ac1..02421aa 100644 --- a/src/main/java/ru/ulstu/file/FileController.java +++ b/src/main/java/ru/ulstu/file/FileController.java @@ -21,13 +21,10 @@ import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import static java.nio.charset.StandardCharsets.UTF_8; -import static ru.ulstu.file.FileController.URL; @RestController -@RequestMapping(URL) +@RequestMapping(Constants.API_1_0 + "files") public class FileController { - public static final String URL = Constants.API_1_0 + "files"; - private final FileService fileService; public FileController(FileService fileService) { @@ -53,6 +50,6 @@ public class FileController { @PostMapping("/uploadTmpFile") public Response upload(@RequestParam("file") MultipartFile multipartFile) throws IOException { - return new Response(fileService.createFromMultipartFile(multipartFile)); + return new Response<>(fileService.createFromMultipartFile(multipartFile)); } } diff --git a/src/main/java/ru/ulstu/file/service/FileService.java b/src/main/java/ru/ulstu/file/service/FileService.java index a8e705a..c7d7dc2 100644 --- a/src/main/java/ru/ulstu/file/service/FileService.java +++ b/src/main/java/ru/ulstu/file/service/FileService.java @@ -27,15 +27,15 @@ public class FileService { private final static int META_FILE_NAME_INDEX = 0; private final static int META_FILE_SIZE_INDEX = 1; - private String tmpDir; - private FileRepository fileRepository; + private final String tmpDir; + private final FileRepository fileRepository; public FileService(FileRepository fileRepository) { tmpDir = System.getProperty("java.io.tmpdir"); this.fileRepository = fileRepository; } - public FileData createFileFromTmp(String tmpFileName) throws IOException { + private FileData createFileFromTmp(String tmpFileName) throws IOException { FileData fileData = new FileData(); fileData.setData(getTmpFile(tmpFileName)); fileData.setSize(getTmpFileSize(tmpFileName)); @@ -43,7 +43,7 @@ public class FileService { return fileRepository.save(fileData); } - public String uploadToTmpDir(MultipartFile multipartFile) throws IOException { + private String uploadToTmpDir(MultipartFile multipartFile) throws IOException { String tmpFileName = String.valueOf(System.currentTimeMillis()) + UUID.randomUUID(); Files.write(getTmpFilePath(tmpFileName), multipartFile.getBytes()); String meta = multipartFile.getOriginalFilename() + "\n" + multipartFile.getSize(); @@ -56,7 +56,7 @@ public class FileService { .split("\n"); } - public long getTmpFileSize(String tmpFileName) throws IOException { + private long getTmpFileSize(String tmpFileName) throws IOException { return Long.valueOf(getMeta(tmpFileName)[META_FILE_SIZE_INDEX]).longValue(); } @@ -97,13 +97,13 @@ public class FileService { } @Transactional - public FileData update(FileDataDto fileDataDto) { + private FileData update(FileDataDto fileDataDto) { FileData file = fileRepository.getOne(fileDataDto.getId()); return fileRepository.save(copyFromDto(file, fileDataDto)); } @Transactional - public FileData create(FileDataDto fileDataDto) throws IOException { + private FileData create(FileDataDto fileDataDto) throws IOException { FileData newFile = createFileFromTmp(fileDataDto.getTmpFileName()); copyFromDto(newFile, fileDataDto); return fileRepository.save(newFile); diff --git a/src/main/java/ru/ulstu/grant/model/Grant.java b/src/main/java/ru/ulstu/grant/model/Grant.java index becee63..0d16f77 100644 --- a/src/main/java/ru/ulstu/grant/model/Grant.java +++ b/src/main/java/ru/ulstu/grant/model/Grant.java @@ -50,7 +50,7 @@ public class Grant extends BaseEntity implements UserActivity, EventSource { LOADED_FROM_KIAS("Загружен автоматически"), SKIPPED("Не интересует"); - private String statusName; + private final String statusName; GrantStatus(String statusName) { this.statusName = statusName; diff --git a/src/main/java/ru/ulstu/grant/service/GrantService.java b/src/main/java/ru/ulstu/grant/service/GrantService.java index 6a81aa4..28d3f8c 100644 --- a/src/main/java/ru/ulstu/grant/service/GrantService.java +++ b/src/main/java/ru/ulstu/grant/service/GrantService.java @@ -79,8 +79,7 @@ public class GrantService extends BaseService { } public GrantDto getExistGrantById(Integer id) { - GrantDto grantDto = new GrantDto(findById(id)); - return grantDto; + return new GrantDto(findById(id)); } public List findAll() { @@ -134,7 +133,7 @@ public class GrantService extends BaseService { } @Transactional - public Integer update(GrantDto grantDto) throws IOException { + private Integer update(GrantDto grantDto) throws IOException { Grant grant = findById(grantDto.getId()); Set oldAuthors = new HashSet<>(grant.getAuthors()); User oldLeader = grant.getLeader(); @@ -182,7 +181,7 @@ public class GrantService extends BaseService { filterEmptyDeadlines(grantDto); checkEmptyDeadlines(grantDto, errors); checkEmptyLeader(grantDto, errors); - checkUniqueName(grantDto, errors, grantDto.getId(), "title", "Грант с таким именем уже существует"); + checkUniqueName(grantDto, errors, grantDto.getId(), "Грант с таким именем уже существует"); if (errors.hasErrors()) { return false; } @@ -194,7 +193,7 @@ public class GrantService extends BaseService { return true; } - public boolean saveFromKias(GrantDto grantDto) throws IOException { + private boolean saveFromKias(GrantDto grantDto) throws IOException { grantDto.setName(grantDto.getTitle()); String title = checkUniqueName(grantDto, grantDto.getId()); //проверка уникальности имени if (title != null) { diff --git a/src/main/java/ru/ulstu/grant/service/KiasService.java b/src/main/java/ru/ulstu/grant/service/KiasService.java index b5ddd36..dea6f55 100644 --- a/src/main/java/ru/ulstu/grant/service/KiasService.java +++ b/src/main/java/ru/ulstu/grant/service/KiasService.java @@ -23,12 +23,10 @@ public class KiasService { private final static String CONTEST_TYPE = "-1"; private final UserService userService; - private final ApplicationProperties applicationProperties; public KiasService(UserService userService, ApplicationProperties applicationProperties) { this.userService = userService; - this.applicationProperties = applicationProperties; } public List getNewGrantsDto() throws ParseException, IOException { @@ -44,7 +42,7 @@ public class KiasService { return grants; } - public List getKiasGrants(HtmlPage page) throws ParseException { + private List getKiasGrants(HtmlPage page) throws ParseException { List newGrants = new ArrayList<>(); KiasPage kiasPage = new KiasPage(page); do { diff --git a/src/main/java/ru/ulstu/name/BaseService.java b/src/main/java/ru/ulstu/name/BaseService.java index fd63cbf..adcdc74 100644 --- a/src/main/java/ru/ulstu/name/BaseService.java +++ b/src/main/java/ru/ulstu/name/BaseService.java @@ -8,13 +8,13 @@ public abstract class BaseService { public BaseRepository baseRepository; - public void checkUniqueName(NameContainer nameContainer, Errors errors, Integer id, String checkField, String errorMessage) { + protected void checkUniqueName(NameContainer nameContainer, Errors errors, Integer id, String errorMessage) { if (nameContainer.getName().equals(baseRepository.findByNameAndNotId(nameContainer.getName(), id))) { - errors.rejectValue(checkField, "errorCode", errorMessage); + errors.rejectValue("title", "errorCode", errorMessage); } } - public String checkUniqueName(NameContainer nameContainer, Integer id) { + protected String checkUniqueName(NameContainer nameContainer, Integer id) { if (nameContainer.getName().equals(baseRepository.findByNameAndNotId(nameContainer.getName(), id))) { return baseRepository.findByNameAndNotId(nameContainer.getName(), id); } diff --git a/src/main/java/ru/ulstu/odin/controller/OdinController.java b/src/main/java/ru/ulstu/odin/controller/OdinController.java index 8d4fcf4..90b0a2b 100644 --- a/src/main/java/ru/ulstu/odin/controller/OdinController.java +++ b/src/main/java/ru/ulstu/odin/controller/OdinController.java @@ -9,10 +9,10 @@ import ru.ulstu.odin.service.OdinService; public abstract class OdinController { public static final String META_LIST_URL = "/meta/list"; - public static final String META_ELEMENT_URL = "/meta/element"; + private static final String META_ELEMENT_URL = "/meta/element"; - private Class listDtoClass; - private Class elementDtoClass; + private final Class listDtoClass; + private final Class elementDtoClass; @Autowired private OdinService odinService; diff --git a/src/main/java/ru/ulstu/odin/model/OdinCollectionField.java b/src/main/java/ru/ulstu/odin/model/OdinCollectionField.java index 171e78c..f8299cf 100644 --- a/src/main/java/ru/ulstu/odin/model/OdinCollectionField.java +++ b/src/main/java/ru/ulstu/odin/model/OdinCollectionField.java @@ -3,6 +3,7 @@ package ru.ulstu.odin.model; import ru.ulstu.core.error.OdinException; import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; @@ -14,9 +15,9 @@ public class OdinCollectionField extends OdinField { ParameterizedType genericType = (ParameterizedType) field.getGenericType(); Type fieldElementClass = genericType.getActualTypeArguments()[0]; try { - OdinDto someInstance = (OdinDto) ((Class) (fieldElementClass)).newInstance(); + OdinDto someInstance = (OdinDto) ((Class) (fieldElementClass)).getDeclaredConstructor().newInstance(); this.path = someInstance.getControllerPath(); - } catch (IllegalAccessException | InstantiationException e) { + } catch (IllegalAccessException | InstantiationException | NoSuchMethodException | InvocationTargetException e) { throw new OdinException(String.format("Can't create new instance, check default constructor of %s", fieldElementClass.getTypeName())); } diff --git a/src/main/java/ru/ulstu/odin/model/OdinField.java b/src/main/java/ru/ulstu/odin/model/OdinField.java index 6beb7d9..b0d99c9 100644 --- a/src/main/java/ru/ulstu/odin/model/OdinField.java +++ b/src/main/java/ru/ulstu/odin/model/OdinField.java @@ -31,15 +31,16 @@ public abstract class OdinField implements Comparable { return this.name().toLowerCase(); } } - protected final OdinFieldType fieldType; - protected final String fieldName; - protected final String caption; - protected final OdinVisible.OdinVisibleType visible; - protected final boolean readOnly; - protected final boolean notEmpty; - private Field field; - public OdinField(Field field, OdinFieldType fieldType) { + private final OdinFieldType fieldType; + private final String fieldName; + private final String caption; + private final OdinVisible.OdinVisibleType visible; + private final boolean readOnly; + private final boolean notEmpty; + private final Field field; + + OdinField(Field field, OdinFieldType fieldType) { this.field = field; this.fieldName = getFieldName(field); this.caption = Optional.ofNullable(getValueFromAnnotation(OdinCaption.class, "value")) @@ -92,7 +93,7 @@ public abstract class OdinField implements Comparable { } } - protected T getValue(Class annotationClass, String valueName, Class clazz) { + T getValue(Class annotationClass, String valueName, Class clazz) { if (field.isAnnotationPresent(annotationClass)) { return cast(getValueFromAnnotation(annotationClass, valueName), clazz); } diff --git a/src/main/java/ru/ulstu/odin/model/OdinObjectField.java b/src/main/java/ru/ulstu/odin/model/OdinObjectField.java index d19e748..10d3606 100644 --- a/src/main/java/ru/ulstu/odin/model/OdinObjectField.java +++ b/src/main/java/ru/ulstu/odin/model/OdinObjectField.java @@ -3,6 +3,7 @@ package ru.ulstu.odin.model; import ru.ulstu.core.error.OdinException; import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Type; public class OdinObjectField extends OdinField { @@ -12,9 +13,9 @@ public class OdinObjectField extends OdinField { super(field, OdinFieldType.OBJECT); Type fieldElementClass = field.getType(); try { - OdinDto someInstance = (OdinDto) ((Class) (fieldElementClass)).newInstance(); + OdinDto someInstance = (OdinDto) ((Class) (fieldElementClass)).getDeclaredConstructor().newInstance(); this.path = someInstance.getControllerPath(); - } catch (IllegalAccessException | InstantiationException e) { + } catch (IllegalAccessException | InstantiationException | NoSuchMethodException | InvocationTargetException e) { throw new OdinException(String.format("Can't create new instance, check default constructor of %s", fieldElementClass.getTypeName())); } diff --git a/src/main/java/ru/ulstu/odinexample/controller/OdinExampleController.java b/src/main/java/ru/ulstu/odinexample/controller/OdinExampleController.java deleted file mode 100644 index 0101531..0000000 --- a/src/main/java/ru/ulstu/odinexample/controller/OdinExampleController.java +++ /dev/null @@ -1,4 +0,0 @@ -package ru.ulstu.odinexample.controller; - -public class OdinExampleController { -} diff --git a/src/main/java/ru/ulstu/odinexample/model/OdinExampleDto.java b/src/main/java/ru/ulstu/odinexample/model/OdinExampleDto.java deleted file mode 100644 index 027d96f..0000000 --- a/src/main/java/ru/ulstu/odinexample/model/OdinExampleDto.java +++ /dev/null @@ -1,4 +0,0 @@ -package ru.ulstu.odinexample.model; - -public class OdinExampleDto { -} diff --git a/src/main/java/ru/ulstu/odinexample/model/OdinExampleListDto.java b/src/main/java/ru/ulstu/odinexample/model/OdinExampleListDto.java deleted file mode 100644 index 6924519..0000000 --- a/src/main/java/ru/ulstu/odinexample/model/OdinExampleListDto.java +++ /dev/null @@ -1,103 +0,0 @@ -package ru.ulstu.odinexample.model; - -import ru.ulstu.core.util.DateUtils; -import ru.ulstu.odin.model.annotation.OdinCaption; -import ru.ulstu.odin.model.annotation.OdinDate; -import ru.ulstu.odin.model.annotation.OdinNumeric; - -import java.time.Instant; -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.time.LocalTime; -import java.util.Date; - -public class OdinExampleListDto { - @OdinCaption("instant") - @OdinDate(type = OdinDate.OdinDateType.DATETIME) - private Instant instant; - @OdinCaption("date") - private Date date; - @OdinCaption("localdate") - private LocalDate localDate; - @OdinCaption("localtime") - @OdinDate(type = OdinDate.OdinDateType.TIME) - private LocalTime localTime; - @OdinCaption("localdatetime") - @OdinDate(type = OdinDate.OdinDateType.DATETIME) - private LocalDateTime localDateTime; - @OdinCaption("int") - private int intval; - @OdinCaption("int+settings") - @OdinNumeric(precision = 5, scale = 2) - private int intvalset; - @OdinCaption("float") - private float floatval; - @OdinCaption("double") - private double aDouble; - @OdinCaption("double+set") - @OdinNumeric(precision = 5, scale = 3) - private double aDoubles; - @OdinCaption("int+positive") - @OdinNumeric(positiveOnly = true, scale = 2) - private int invalpos; - - public OdinExampleListDto() { - this.instant = Instant.now(); - this.date = new Date(); - this.localDate = LocalDate.now(); - this.localTime = LocalTime.now(); - this.localDateTime = LocalDateTime.now(); - intval = -134; - intvalset = 1343423232; - floatval = 2323.44F; - aDouble = -232323.43434; - aDoubles = 0.456456456; - invalpos = -23232323; - } - - - public Date getInstant() { - return DateUtils.instantToDate(instant); - } - - public Date getDate() { - return date; - } - - public Date getLocalDate() { - return DateUtils.localDateToDate(localDate); - } - - public Date getLocalTime() { - return DateUtils.localTimeToDate(localTime); - } - - public Date getLocalDateTime() { - return DateUtils.localDateTimeToDate(localDateTime); - } - - public int getIntval() { - return intval; - } - - public int getIntvalset() { - return intvalset; - } - - public float getFloatval() { - return floatval; - } - - public double getaDouble() { - return aDouble; - } - - public double getaDoubles() { - return aDoubles; - } - - public int getInvalpos() { - return invalpos; - } - -} diff --git a/src/main/java/ru/ulstu/odinexample/service/OdinExampleService.java b/src/main/java/ru/ulstu/odinexample/service/OdinExampleService.java deleted file mode 100644 index 57cea21..0000000 --- a/src/main/java/ru/ulstu/odinexample/service/OdinExampleService.java +++ /dev/null @@ -1,4 +0,0 @@ -package ru.ulstu.odinexample.service; - -public class OdinExampleService { -} diff --git a/src/main/java/ru/ulstu/paper/controller/PaperRestController.java b/src/main/java/ru/ulstu/paper/controller/PaperRestController.java index 7c0d9c5..b6dd11d 100644 --- a/src/main/java/ru/ulstu/paper/controller/PaperRestController.java +++ b/src/main/java/ru/ulstu/paper/controller/PaperRestController.java @@ -40,7 +40,7 @@ public class PaperRestController { @GetMapping("/{paper-id}") public Response getPaper(@PathVariable("paper-id") Integer paperId) { - return new Response(paperService.findById(paperId)); + return new Response<>(paperService.findById(paperId)); } @PostMapping @@ -56,7 +56,7 @@ public class PaperRestController { @DeleteMapping("/{paper-id}") public Response delete(@PathVariable("paper-id") Integer paperId) throws IOException { paperService.delete(paperId); - return new Response<>(true); + return new Response<>(Boolean.TRUE); } @PostMapping("/filter") diff --git a/src/main/java/ru/ulstu/paper/error/PaperConferenceRelationExistException.java b/src/main/java/ru/ulstu/paper/error/PaperConferenceRelationExistException.java deleted file mode 100644 index ddb3b5e..0000000 --- a/src/main/java/ru/ulstu/paper/error/PaperConferenceRelationExistException.java +++ /dev/null @@ -1,7 +0,0 @@ -package ru.ulstu.paper.error; - -public class PaperConferenceRelationExistException extends RuntimeException { - public PaperConferenceRelationExistException(String message) { - super(message); - } -} diff --git a/src/main/java/ru/ulstu/paper/model/Paper.java b/src/main/java/ru/ulstu/paper/model/Paper.java index 79f5d3b..f7b851c 100644 --- a/src/main/java/ru/ulstu/paper/model/Paper.java +++ b/src/main/java/ru/ulstu/paper/model/Paper.java @@ -48,7 +48,7 @@ public class Paper extends BaseEntity implements UserActivity, EventSource { DRAFT("Черновик"), FAILED("Провалены сроки"); - private String statusName; + private final String statusName; PaperStatus(String name) { this.statusName = name; @@ -65,7 +65,7 @@ public class Paper extends BaseEntity implements UserActivity, EventSource { SCOPUS("Scopus"), WEB_OF_SCIENCE("Web Of Science"); - private String typeName; + private final String typeName; PaperType(String name) { this.typeName = name; @@ -201,7 +201,7 @@ public class Paper extends BaseEntity implements UserActivity, EventSource { @Override public List getRecipients() { - return new ArrayList(authors); + return new ArrayList<>(authors); } @Override diff --git a/src/main/java/ru/ulstu/paper/model/ReferenceDto.java b/src/main/java/ru/ulstu/paper/model/ReferenceDto.java index 1705e08..bf7fed2 100644 --- a/src/main/java/ru/ulstu/paper/model/ReferenceDto.java +++ b/src/main/java/ru/ulstu/paper/model/ReferenceDto.java @@ -8,7 +8,7 @@ public class ReferenceDto { ARTICLE("Статья"), BOOK("Книга"); - private String typeName; + private final String typeName; ReferenceType(String name) { this.typeName = name; @@ -23,7 +23,7 @@ public class ReferenceDto { GOST("ГОСТ"), SPRINGER("Springer"); - private String standardName; + private final String standardName; FormatStandard(String name) { this.standardName = name; diff --git a/src/main/java/ru/ulstu/paper/service/LatexService.java b/src/main/java/ru/ulstu/paper/service/LatexService.java index 9892e35..ea1bcfc 100644 --- a/src/main/java/ru/ulstu/paper/service/LatexService.java +++ b/src/main/java/ru/ulstu/paper/service/LatexService.java @@ -12,11 +12,11 @@ import java.nio.file.Files; @Service public class LatexService { - private final String pdfLatexError = "Errors occurred while executing pdfLaTeX."; - private final String bibtexError = "Errors occurred while executing bibtex."; + private static final String PDF_LATEX_ERROR = "Errors occurred while executing pdfLaTeX."; + private static final String BIBTEX_ERROR = "Errors occurred while executing bibtex."; private String errorMessage; private File pdfFile; - private FileService fileService; + private final FileService fileService; public LatexService(FileService fileService) { this.fileService = fileService; @@ -56,9 +56,9 @@ public class LatexService { } private boolean generate(String filename, File dir) throws IOException, InterruptedException { - startProcess(new String[]{"pdflatex", filename, "--interaction=nonstopmode"}, dir, pdfLatexError); - startProcess(new String[]{"bibtex", filename}, dir, bibtexError); - if (startProcess(new String[]{"pdflatex", filename, "--interaction=nonstopmode"}, dir, pdfLatexError) != 0) { + startProcess(new String[]{"pdflatex", filename, "--interaction=nonstopmode"}, dir, PDF_LATEX_ERROR); + startProcess(new String[]{"bibtex", filename}, dir, BIBTEX_ERROR); + if (startProcess(new String[]{"pdflatex", filename, "--interaction=nonstopmode"}, dir, PDF_LATEX_ERROR) != 0) { return false; } return checkPdf(filename, dir); diff --git a/src/main/java/ru/ulstu/paper/service/PaperService.java b/src/main/java/ru/ulstu/paper/service/PaperService.java index 1a1e2cb..2fee949 100644 --- a/src/main/java/ru/ulstu/paper/service/PaperService.java +++ b/src/main/java/ru/ulstu/paper/service/PaperService.java @@ -85,7 +85,7 @@ public class PaperService { return papers; } - public List findAllActive() { + private List findAllActive() { return findAll() .stream() .filter(paper -> paper.getStatus() != COMPLETED && paper.getStatus() != FAILED) @@ -139,7 +139,7 @@ public class PaperService { return paper; } - public List saveOrCreateReferences(List references) { + private List saveOrCreateReferences(List references) { return references .stream() .filter(reference -> !reference.getDeleted()) @@ -148,7 +148,7 @@ public class PaperService { } @Transactional - public Reference updateReference(ReferenceDto referenceDto) { + private Reference updateReference(ReferenceDto referenceDto) { Reference updateReference = referenceRepository.getOne(referenceDto.getId()); copyFromDto(updateReference, referenceDto); referenceRepository.save(updateReference); @@ -156,7 +156,7 @@ public class PaperService { } @Transactional - public Reference createReference(ReferenceDto referenceDto) { + private Reference createReference(ReferenceDto referenceDto) { Reference newReference = new Reference(); copyFromDto(newReference, referenceDto); newReference = referenceRepository.save(newReference); @@ -358,7 +358,7 @@ public class PaperService { .collect(Collectors.toList())); } - public String getGostReference(ReferenceDto referenceDto) { + private String getGostReference(ReferenceDto referenceDto) { return MessageFormat.format(referenceDto.getReferenceType() == BOOK ? "{0} {1} - {2}{3}. - {4}с." : "{0} {1}{5} {2}{3}. С. {4}.", referenceDto.getAuthors(), referenceDto.getPublicationTitle(), @@ -368,7 +368,7 @@ public class PaperService { StringUtils.isEmpty(referenceDto.getJournalOrCollectionTitle()) ? "." : " // " + referenceDto.getJournalOrCollectionTitle() + "."); } - public String getSpringerReference(ReferenceDto referenceDto) { + private String getSpringerReference(ReferenceDto referenceDto) { return MessageFormat.format("{0} ({1}) {2}.{3} {4}pp {5}", referenceDto.getAuthors(), referenceDto.getPublicationYear() != null ? referenceDto.getPublicationYear().toString() : "", diff --git a/src/main/java/ru/ulstu/ping/service/PingService.java b/src/main/java/ru/ulstu/ping/service/PingService.java index e1c0035..99ca26f 100644 --- a/src/main/java/ru/ulstu/ping/service/PingService.java +++ b/src/main/java/ru/ulstu/ping/service/PingService.java @@ -17,14 +17,12 @@ import java.util.List; public class PingService { private final PingRepository pingRepository; private final UserService userService; - private final PingScheduler pingScheduler; public PingService(PingRepository pingRepository, UserService userService, PingScheduler pingScheduler) { this.pingRepository = pingRepository; this.userService = userService; - this.pingScheduler = pingScheduler; } @Transactional diff --git a/src/main/java/ru/ulstu/project/model/Project.java b/src/main/java/ru/ulstu/project/model/Project.java index 25a7382..0ddb982 100644 --- a/src/main/java/ru/ulstu/project/model/Project.java +++ b/src/main/java/ru/ulstu/project/model/Project.java @@ -42,7 +42,7 @@ public class Project extends BaseEntity implements UserActivity, EventSource { CLOSED("Закрыт"), FAILED("Провалены сроки"); - private String statusName; + private final String statusName; ProjectStatus(String statusName) { this.statusName = statusName; diff --git a/src/main/java/ru/ulstu/project/service/ProjectService.java b/src/main/java/ru/ulstu/project/service/ProjectService.java index 7ce4861..07b07fa 100644 --- a/src/main/java/ru/ulstu/project/service/ProjectService.java +++ b/src/main/java/ru/ulstu/project/service/ProjectService.java @@ -81,7 +81,7 @@ public class ProjectService { } @Transactional - public Project update(ProjectDto projectDto) throws IOException { + private Project update(ProjectDto projectDto) throws IOException { Project project = projectRepository.getOne(projectDto.getId()); projectRepository.save(copyFromDto(project, projectDto)); eventService.updateProjectDeadlines(project); @@ -143,8 +143,7 @@ public class ProjectService { } public List getProjectExecutors(ProjectDto projectDto) { - List users = userService.findAll(); - return users; + return userService.findAll(); } @Transactional @@ -153,11 +152,10 @@ public class ProjectService { } public List getAllGrants() { - List grants = convert(grantRepository.findAll(), GrantDto::new); - return grants; + return convert(grantRepository.findAll(), GrantDto::new); } - public List getProjectGrants(List grantIds) { + private List getProjectGrants(List grantIds) { return convert(grantRepository.findAllById(grantIds), GrantDto::new); } diff --git a/src/main/java/ru/ulstu/strategy/api/EntityCreateStrategy.java b/src/main/java/ru/ulstu/strategy/api/EntityCreateStrategy.java index 8a14399..bf857a0 100644 --- a/src/main/java/ru/ulstu/strategy/api/EntityCreateStrategy.java +++ b/src/main/java/ru/ulstu/strategy/api/EntityCreateStrategy.java @@ -11,7 +11,7 @@ public abstract class EntityCreateStrategy { protected abstract void createEntity(User user); - protected void createDefaultEntityIfNeed(List allUsers, List entities) { + private void createDefaultEntityIfNeed(List allUsers, List entities) { allUsers.forEach(user -> { if (entities .stream() diff --git a/src/main/java/ru/ulstu/students/controller/Navigation.java b/src/main/java/ru/ulstu/students/controller/Navigation.java index 3804a8b..348f062 100644 --- a/src/main/java/ru/ulstu/students/controller/Navigation.java +++ b/src/main/java/ru/ulstu/students/controller/Navigation.java @@ -2,7 +2,7 @@ package ru.ulstu.students.controller; import org.springframework.validation.Errors; -public class Navigation { +class Navigation { public static final String REDIRECT_TO = "redirect:%s"; public static final String TASKS_PAGE = "/students/tasks"; public static final String TASK_PAGE = "/students/task"; diff --git a/src/main/java/ru/ulstu/students/model/Task.java b/src/main/java/ru/ulstu/students/model/Task.java index 9043387..4da0aa2 100644 --- a/src/main/java/ru/ulstu/students/model/Task.java +++ b/src/main/java/ru/ulstu/students/model/Task.java @@ -8,7 +8,6 @@ import ru.ulstu.deadline.model.Deadline; import ru.ulstu.tags.model.Tag; import ru.ulstu.timeline.model.Event; import ru.ulstu.user.model.User; -import ru.ulstu.user.service.UserService; import javax.persistence.CascadeType; import javax.persistence.Column; @@ -23,7 +22,6 @@ import javax.persistence.OneToMany; import javax.persistence.OrderBy; import javax.persistence.Temporal; import javax.persistence.TemporalType; -import javax.persistence.Transient; import javax.validation.constraints.NotBlank; import java.util.ArrayList; import java.util.Collections; @@ -39,7 +37,7 @@ public class Task extends BaseEntity implements EventSource { FAILED("Провалены сроки"), LOADED_FROM_KIAS("Загружен автоматически"); - private String statusName; + private final String statusName; TaskStatus(String name) { this.statusName = name; @@ -55,17 +53,10 @@ public class Task extends BaseEntity implements EventSource { private String description; - @Transient - private UserService userService; - public Task() { } - public Task(UserService userService) { - this.userService = userService; - } - @Enumerated(value = EnumType.STRING) private TaskStatus status = TaskStatus.IN_WORK; diff --git a/src/main/java/ru/ulstu/students/service/TaskService.java b/src/main/java/ru/ulstu/students/service/TaskService.java index a9b2505..c3b4f3a 100644 --- a/src/main/java/ru/ulstu/students/service/TaskService.java +++ b/src/main/java/ru/ulstu/students/service/TaskService.java @@ -101,7 +101,7 @@ public class TaskService { } @Transactional - public Integer update(TaskDto taskDto) throws IOException { + private Integer update(TaskDto taskDto) throws IOException { Task task = taskRepository.getOne(taskDto.getId()); taskRepository.save(copyFromDto(task, taskDto)); eventService.updateTaskDeadlines(task); diff --git a/src/main/java/ru/ulstu/tags/service/TagService.java b/src/main/java/ru/ulstu/tags/service/TagService.java index b84d492..f85889d 100644 --- a/src/main/java/ru/ulstu/tags/service/TagService.java +++ b/src/main/java/ru/ulstu/tags/service/TagService.java @@ -33,17 +33,17 @@ public class TagService { } @Transactional - public Tag getExistById(Tag tag) { + private Tag getExistById(Tag tag) { return tagRepository.getOne(tag.getId()); } @Transactional - public Tag isExistByName(String tagName) { + private Tag isExistByName(String tagName) { return tagRepository.findByName(tagName); } @Transactional - public Tag create(Tag tag) { + private Tag create(Tag tag) { Tag newTag = new Tag(); newTag.setTagName(tag.getTagName()); newTag = tagRepository.save(newTag); diff --git a/src/main/java/ru/ulstu/timeline/controller/EventController.java b/src/main/java/ru/ulstu/timeline/controller/EventController.java index 77cb118..2a9245c 100644 --- a/src/main/java/ru/ulstu/timeline/controller/EventController.java +++ b/src/main/java/ru/ulstu/timeline/controller/EventController.java @@ -16,12 +16,9 @@ import ru.ulstu.timeline.service.EventService; import javax.validation.Valid; import java.util.List; -import static ru.ulstu.timeline.controller.EventController.URL; - @RestController -@RequestMapping(URL) +@RequestMapping(Constants.API_1_0 + "events") public class EventController { - public static final String URL = Constants.API_1_0 + "events"; private final EventService eventService; @@ -40,18 +37,18 @@ public class EventController { } @PostMapping - public Response createEvent(@RequestBody @Valid EventDto timelineDto) { - return new Response(eventService.create(timelineDto)); + public Response createEvent(@RequestBody @Valid EventDto timelineDto) { + return new Response<>(eventService.create(timelineDto)); } @PutMapping - public Response updateEvent(@RequestBody @Valid EventDto eventDto) { - return new Response(eventService.update(eventDto)); + public Response updateEvent(@RequestBody @Valid EventDto eventDto) { + return new Response<>(eventService.update(eventDto)); } @DeleteMapping("/{event-id}") - public Response delete(@PathVariable("event-id") Integer eventId) { + public Response delete(@PathVariable("event-id") Integer eventId) { eventService.delete(eventId); - return new Response(true); + return new Response<>(Boolean.TRUE); } } diff --git a/src/main/java/ru/ulstu/timeline/model/Event.java b/src/main/java/ru/ulstu/timeline/model/Event.java index 2f714a3..bf69a70 100644 --- a/src/main/java/ru/ulstu/timeline/model/Event.java +++ b/src/main/java/ru/ulstu/timeline/model/Event.java @@ -31,7 +31,7 @@ public class Event extends BaseEntity { public enum EventStatus { POSSIBLE("Возможное"), NEW("Новое"), IN_PROGRESS("В процессе"), COMPLETED("Завершено"); - private String name; + private final String name; EventStatus(String name) { this.name = name; diff --git a/src/main/java/ru/ulstu/timeline/model/EventStatusDto.java b/src/main/java/ru/ulstu/timeline/model/EventStatusDto.java deleted file mode 100644 index 6bb4bbc..0000000 --- a/src/main/java/ru/ulstu/timeline/model/EventStatusDto.java +++ /dev/null @@ -1,19 +0,0 @@ -package ru.ulstu.timeline.model; - -public class EventStatusDto { - private final String id; - private final String name; - - public EventStatusDto(Event.EventStatus status) { - this.id = status.name(); - this.name = status.getName(); - } - - public String getId() { - return id; - } - - public String getName() { - return name; - } -} diff --git a/src/main/java/ru/ulstu/timeline/model/PeriodEvent.java b/src/main/java/ru/ulstu/timeline/model/PeriodEvent.java index c25528e..39eaffb 100644 --- a/src/main/java/ru/ulstu/timeline/model/PeriodEvent.java +++ b/src/main/java/ru/ulstu/timeline/model/PeriodEvent.java @@ -8,8 +8,8 @@ public enum PeriodEvent { EVERY_WEEK(Period.ofWeeks(1), "Каждую неделю"), EVERY_DAY(Period.ofDays(1), "Каждый день"); - private Period period; - private String message; + private final Period period; + private final String message; PeriodEvent(Period period, String message) { this.period = period; diff --git a/src/main/java/ru/ulstu/timeline/service/EventService.java b/src/main/java/ru/ulstu/timeline/service/EventService.java index 552b17c..c7639c2 100644 --- a/src/main/java/ru/ulstu/timeline/service/EventService.java +++ b/src/main/java/ru/ulstu/timeline/service/EventService.java @@ -49,7 +49,7 @@ public class EventService { } @Transactional - public int create(EventDto eventDto) { + public Integer create(EventDto eventDto) { return eventRepository.save(copyFromDto(new Event(), eventDto)).getId(); } @@ -145,7 +145,7 @@ public class EventService { return eventRepository.findByCurrentDate(); } - public List findAllFuture() { + private List findAllFuture() { return eventRepository.findAllFuture(); } diff --git a/src/main/java/ru/ulstu/user/component/IpAddressResolver.java b/src/main/java/ru/ulstu/user/component/IpAddressResolver.java index 4c74923..ede78de 100644 --- a/src/main/java/ru/ulstu/user/component/IpAddressResolver.java +++ b/src/main/java/ru/ulstu/user/component/IpAddressResolver.java @@ -4,7 +4,7 @@ import org.springframework.util.StringUtils; import javax.servlet.http.HttpServletRequest; -public final class IpAddressResolver { +final class IpAddressResolver { private static final String CLIENT_IP_HEADER = "Client-IP"; private static final String FORWARDED_FOR_HEADER = "X-Forwarded-For"; diff --git a/src/main/java/ru/ulstu/user/controller/UserController.java b/src/main/java/ru/ulstu/user/controller/UserController.java index d080d54..3e653fb 100644 --- a/src/main/java/ru/ulstu/user/controller/UserController.java +++ b/src/main/java/ru/ulstu/user/controller/UserController.java @@ -41,9 +41,9 @@ import static ru.ulstu.user.controller.UserController.URL; public class UserController extends OdinController { public static final String URL = Constants.API_1_0 + "users"; public static final String ROLES_URL = "/roles"; - public static final String ROLES_META_URL = ROLES_URL + OdinController.META_LIST_URL; - public static final String SESSIONS_URL = "/sessions"; - public static final String SESSIONS_META_URL = SESSIONS_URL + OdinController.META_LIST_URL; + private static final String ROLES_META_URL = ROLES_URL + OdinController.META_LIST_URL; + private static final String SESSIONS_URL = "/sessions"; + private static final String SESSIONS_META_URL = SESSIONS_URL + OdinController.META_LIST_URL; public static final String REGISTER_URL = "/register"; public static final String ACTIVATE_URL = "/activate"; public static final String PASSWORD_RESET_REQUEST_URL = "/password-reset-request"; diff --git a/src/main/java/ru/ulstu/user/controller/UserMvcController.java b/src/main/java/ru/ulstu/user/controller/UserMvcController.java index bf84176..1207219 100644 --- a/src/main/java/ru/ulstu/user/controller/UserMvcController.java +++ b/src/main/java/ru/ulstu/user/controller/UserMvcController.java @@ -71,11 +71,4 @@ public class UserMvcController extends OdinController { "CONFERENCE", "Конференции"); } - @GetMapping("/pings") - public void getPings() { - } - - @GetMapping("/block") - public void getBlock() { - } } diff --git a/src/main/java/ru/ulstu/user/model/User.java b/src/main/java/ru/ulstu/user/model/User.java index 6507534..e4461d5 100644 --- a/src/main/java/ru/ulstu/user/model/User.java +++ b/src/main/java/ru/ulstu/user/model/User.java @@ -100,7 +100,7 @@ public class User extends BaseEntity { CANDIDATE("Кандидат технических наук"), DOCTOR("Доктор технических наук"); - private String degreeName; + private final String degreeName; UserDegree(String degreeName) { this.degreeName = degreeName; diff --git a/src/main/java/ru/ulstu/user/model/UserDto.java b/src/main/java/ru/ulstu/user/model/UserDto.java index c3f8502..a2f33f6 100644 --- a/src/main/java/ru/ulstu/user/model/UserDto.java +++ b/src/main/java/ru/ulstu/user/model/UserDto.java @@ -53,7 +53,7 @@ public class UserDto implements OdinDto { private boolean activated; @OdinCaption("Роли") - private LinkedHashSet roles; + private final LinkedHashSet roles; @OdinString(type = PASSWORD) @OdinVisible(type = OdinVisible.OdinVisibleType.ON_UPDATE) @@ -189,9 +189,9 @@ public class UserDto implements OdinDto { @JsonIgnore public boolean isPasswordsValid() { if (StringUtils.isEmpty(password) || StringUtils.isEmpty(passwordConfirm)) { - return false; + return true; } - return Objects.equals(password, passwordConfirm); + return !Objects.equals(password, passwordConfirm); } @JsonIgnore diff --git a/src/main/java/ru/ulstu/user/model/UserListDto.java b/src/main/java/ru/ulstu/user/model/UserListDto.java index 2df2174..4f108dc 100644 --- a/src/main/java/ru/ulstu/user/model/UserListDto.java +++ b/src/main/java/ru/ulstu/user/model/UserListDto.java @@ -11,19 +11,19 @@ import java.util.Optional; public class UserListDto implements OdinDto { @OdinVisible(type = OdinVisible.OdinVisibleType.NONE) - private int id; + private final int id; @OdinCaption("Логин") - private String login; + private final String login; @OdinCaption("Имя") - private String firstName; + private final String firstName; @OdinCaption("Фамилия") - private String lastName; + private final String lastName; @OdinCaption("E-Mail") - private String email; + private final String email; @OdinCaption("Аккаунт активен") - private boolean activated; + private final boolean activated; @OdinCaption("Права администратора") - private boolean admin; + private final boolean admin; public UserListDto(User user) { this.id = user.getId(); diff --git a/src/main/java/ru/ulstu/user/model/UserSessionListDto.java b/src/main/java/ru/ulstu/user/model/UserSessionListDto.java index ebfd653..5325762 100644 --- a/src/main/java/ru/ulstu/user/model/UserSessionListDto.java +++ b/src/main/java/ru/ulstu/user/model/UserSessionListDto.java @@ -7,19 +7,19 @@ import java.util.Date; public class UserSessionListDto { @OdinCaption("Сессия") - private String sessionId; + private final String sessionId; @OdinCaption("Пользователь") - private String login; + private final String login; @OdinCaption("IP адрес") - private String ipAddress; + private final String ipAddress; @OdinCaption("Хост") - private String host; + private final String host; @OdinCaption("Вход") @OdinDate(type = OdinDate.OdinDateType.DATETIME) - private Date loginTime; + private final Date loginTime; @OdinCaption("Выход") @OdinDate(type = OdinDate.OdinDateType.DATETIME) - private Date logoutTime; + private final Date logoutTime; public UserSessionListDto(UserSession userSession) { this.sessionId = userSession.getSessionId(); diff --git a/src/main/java/ru/ulstu/user/service/MailService.java b/src/main/java/ru/ulstu/user/service/MailService.java index 7c83bfb..369b459 100644 --- a/src/main/java/ru/ulstu/user/service/MailService.java +++ b/src/main/java/ru/ulstu/user/service/MailService.java @@ -39,7 +39,7 @@ public class MailService { } @Async - public void sendEmail(String to, String subject, String content) throws MessagingException, MailException { + private void sendEmail(String to, String subject, String content) throws MessagingException, MailException { log.debug("Send email to '{}' with subject '{}'", to, subject); MimeMessage mimeMessage = javaMailSender.createMimeMessage(); MimeMessageHelper message = new MimeMessageHelper(mimeMessage, false, StandardCharsets.UTF_8.name()); @@ -60,7 +60,7 @@ public class MailService { } @Async - public void sendEmailFromTemplate(User user, String templateName, String subject) { + private void sendEmailFromTemplate(User user, String templateName, String subject) { Context context = new Context(); context.setVariable(USER, user); context.setVariable(BASE_URL, applicationProperties.getBaseUrl()); @@ -99,7 +99,7 @@ public class MailService { } @Async - public void sendEmailFromTemplate(Map variables, String templateName, String subject, String email) + private void sendEmailFromTemplate(Map variables, String templateName, String subject, String email) throws MessagingException { Context context = new Context(); variables.entrySet().forEach(entry -> context.setVariable(entry.getKey(), entry.getValue())); diff --git a/src/main/java/ru/ulstu/user/service/UserMapper.java b/src/main/java/ru/ulstu/user/service/UserMapper.java index 647754b..7a195ae 100644 --- a/src/main/java/ru/ulstu/user/service/UserMapper.java +++ b/src/main/java/ru/ulstu/user/service/UserMapper.java @@ -38,7 +38,7 @@ public class UserMapper { return new UserDto(userEntity); } - public UserListDto userEntityToUserListDto(User userEntity) { + private UserListDto userEntityToUserListDto(User userEntity) { if (userEntity == null) { return null; } diff --git a/src/main/java/ru/ulstu/user/service/UserService.java b/src/main/java/ru/ulstu/user/service/UserService.java index 8bad06e..0f69c8e 100644 --- a/src/main/java/ru/ulstu/user/service/UserService.java +++ b/src/main/java/ru/ulstu/user/service/UserService.java @@ -153,7 +153,7 @@ public class UserService implements UserDetailsService { if (getUserByEmail(userDto.getEmail()) != null) { throw new UserEmailExistsException(userDto.getEmail()); } - if (!userDto.isPasswordsValid()) { + if (userDto.isPasswordsValid()) { throw new UserPasswordsNotValidOrNotMatchException(""); } User user = userMapper.userDtoToUserEntity(userDto); @@ -223,7 +223,7 @@ public class UserService implements UserDetailsService { ? Collections.singleton(new UserRole(UserRoleConstants.USER)) : roles); if (!StringUtils.isEmpty(userDto.getOldPassword())) { - if (!userDto.isPasswordsValid() || !userDto.isOldPasswordValid()) { + if (userDto.isPasswordsValid() || !userDto.isOldPasswordValid()) { throw new UserPasswordsNotValidOrNotMatchException(""); } if (!passwordEncoder.matches(userDto.getOldPassword(), user.getPassword())) { diff --git a/src/main/java/ru/ulstu/utils/timetable/TimetableService.java b/src/main/java/ru/ulstu/utils/timetable/TimetableService.java index 78a1c66..b2a7874 100644 --- a/src/main/java/ru/ulstu/utils/timetable/TimetableService.java +++ b/src/main/java/ru/ulstu/utils/timetable/TimetableService.java @@ -16,9 +16,9 @@ import java.util.List; public class TimetableService { private static final String TIMETABLE_URL = "http://timetable.athene.tech/api/1.0/timetable?filter=%s"; - private SimpleDateFormat lessonTimeFormat = new SimpleDateFormat("hh:mm"); + private final SimpleDateFormat lessonTimeFormat = new SimpleDateFormat("hh:mm"); - private long[] lessonsStarts = new long[]{ + private final long[] lessonsStarts = new long[]{ lessonTimeFormat.parse("8:00:00").getTime(), lessonTimeFormat.parse("9:40:00").getTime(), lessonTimeFormat.parse("11:30:00").getTime(), diff --git a/src/main/resources/public/css/agency.css b/src/main/resources/public/css/agency.css index 82a36d2..a846fa8 100644 --- a/src/main/resources/public/css/agency.css +++ b/src/main/resources/public/css/agency.css @@ -365,7 +365,7 @@ header.masthead .intro-text .intro-heading { } .portfolio-modal { - padding-right: 0px !important; + padding-right: 0 !important; } .portfolio-modal .modal-dialog { diff --git a/src/main/resources/public/css/conference.css b/src/main/resources/public/css/conference.css index 7a4784b..3b23ba0 100644 --- a/src/main/resources/public/css/conference.css +++ b/src/main/resources/public/css/conference.css @@ -57,7 +57,7 @@ body { .deadline-list { height: 200px; - padding: 0px; + padding: 0; overflow-y: scroll; } @@ -73,7 +73,7 @@ body { .member-list { height: 200px; - padding: 0px; + padding: 0; overflow-y: scroll; } @@ -135,7 +135,7 @@ body { .paper-list { height: 200px; - padding: 0px; + padding: 0; overflow-y: scroll; } @@ -160,7 +160,7 @@ body { } .paper-name span:nth-child(1) { - margin: 3px 0px 3px 10px; + margin: 3px 0 3px 10px; float: left; } diff --git a/src/main/resources/public/css/grant.css b/src/main/resources/public/css/grant.css index d4c7976..d80377d 100644 --- a/src/main/resources/public/css/grant.css +++ b/src/main/resources/public/css/grant.css @@ -1,5 +1,5 @@ .div-deadline-date { - padding-right: 0px; + padding-right: 0; } .form-deadline-date { @@ -16,7 +16,7 @@ } .div-selected-papers { - border: 0px; + border: 0; padding-left: 12px; } diff --git a/src/main/resources/public/css/odin.css b/src/main/resources/public/css/odin.css index 2bfeb75..0c2b7c4 100644 --- a/src/main/resources/public/css/odin.css +++ b/src/main/resources/public/css/odin.css @@ -52,8 +52,7 @@ Odin Paginator */ .odin-paginator { - margin: 0; - margin-top: 5px; + margin: 5px 0 0; text-align: center; } diff --git a/src/main/resources/public/css/tasks.css b/src/main/resources/public/css/tasks.css index 709756e..6098550 100644 --- a/src/main/resources/public/css/tasks.css +++ b/src/main/resources/public/css/tasks.css @@ -120,7 +120,7 @@ .tag-name span[data-role="remove"]:after { content: "x"; - padding: 0px 2px; + padding: 0 2px; } .tag-name input[type="text"] { diff --git a/src/main/resources/public/js/core.js b/src/main/resources/public/js/core.js index 23ed621..7f54023 100644 --- a/src/main/resources/public/js/core.js +++ b/src/main/resources/public/js/core.js @@ -89,11 +89,6 @@ function getFromRest(url, callBack, errorCallBack) { }); } -/* exported getFromRestWithVersion */ -function getFromRest(url, callBack, errorCallBack) { - getFromRestWithParams(url, "", callBack, errorCallBack); -} - /* exported getFromRestWithVersionAndParams */ function getFromRestWithParams(url, params, callBack, errorCallBack) { $.ajax({ diff --git a/src/main/resources/public/templates/odin.html b/src/main/resources/public/templates/odin.html index 1f9f9d9..ec4e36e 100644 --- a/src/main/resources/public/templates/odin.html +++ b/src/main/resources/public/templates/odin.html @@ -126,7 +126,7 @@