Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] master from kitodo:master #310

Merged
merged 11 commits into from
Oct 29, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,7 @@ public class StringConstants {
public static final String SEMICOLON_DELIMITER = "; ";
public static final String EDIT_FORM_SAVE = "editForm:save";

// patterns
public static final String DEFAULT_DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

package org.kitodo.data.elasticsearch.index.type;

import static org.kitodo.constants.StringConstants.DEFAULT_DATE_FORMAT;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
Expand Down Expand Up @@ -138,7 +140,7 @@ private void getAdditionalProperties(Map<String, Object> jsonObject, BaseBean pr
*/
String getFormattedDate(Date date) {
if (Objects.nonNull(date)) {
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
DateFormat dateFormat = new SimpleDateFormat(DEFAULT_DATE_FORMAT);
return dateFormat.format(date);
}
return "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.kitodo.constants.StringConstants.DEFAULT_DATE_FORMAT;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
Expand Down Expand Up @@ -260,7 +261,7 @@ public void shouldCreateDocuments() {
}

private String formatDate(Date date) {
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
DateFormat dateFormat = new SimpleDateFormat(DEFAULT_DATE_FORMAT);
return dateFormat.format(date);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.kitodo.constants.StringConstants.DEFAULT_DATE_FORMAT;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
Expand Down Expand Up @@ -338,7 +339,7 @@ public void shouldCreateSecondDocument() throws Exception {
@Test
public void shouldCreateThirdDocument() throws Exception {
ProjectType processType = new ProjectType();
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
DateFormat dateFormat = new SimpleDateFormat(DEFAULT_DATE_FORMAT);

Project project = prepareData().get(2);
Map<String, Object> actual = processType.createDocument(project);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.kitodo.constants.StringConstants.DEFAULT_DATE_FORMAT;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
Expand Down Expand Up @@ -195,7 +196,7 @@ public void shouldCreateDocuments() {
}

private String formatDate(Date date) {
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
DateFormat dateFormat = new SimpleDateFormat(DEFAULT_DATE_FORMAT);
return dateFormat.format(date);
}
}
2 changes: 1 addition & 1 deletion Kitodo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@
<dependency>
<groupId>org.apache.pdfbox</groupId>
<artifactId>pdfbox</artifactId>
<version>2.0.26</version>
<version>2.0.32</version>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

package org.kitodo.production.forms;

import static org.kitodo.constants.StringConstants.DEFAULT_DATE_FORMAT;

import java.io.Serializable;
import java.text.DateFormat;
import java.text.MessageFormat;
Expand Down Expand Up @@ -364,7 +366,7 @@ public void saveSelectedColumns() {
*/
public String getFormattedDate(Date date) {
if (Objects.nonNull(date)) {
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
DateFormat dateFormat = new SimpleDateFormat(DEFAULT_DATE_FORMAT);
return dateFormat.format(date);
}
return "";
Expand Down
8 changes: 5 additions & 3 deletions Kitodo/src/main/java/org/kitodo/production/helper/Helper.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

package org.kitodo.production.helper;

import static org.kitodo.constants.StringConstants.DEFAULT_DATE_FORMAT;

import java.io.PrintWriter;
import java.io.StringWriter;
import java.security.SecureRandom;
Expand Down Expand Up @@ -398,7 +400,7 @@ public static String getDateAsFormattedString(Date date) {
if (Objects.isNull(date)) {
return "-";
} else {
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
DateFormat dateFormat = new SimpleDateFormat(DEFAULT_DATE_FORMAT);
return dateFormat.format(date);
}
}
Expand All @@ -416,12 +418,12 @@ public static Date parseDateFromFormattedString(String date) {
return null;
}
try {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DEFAULT_DATE_FORMAT);
LocalDateTime localDate = LocalDateTime.parse(date, formatter);
Instant instant = localDate.toInstant(ZoneOffset.UTC);
return Date.from(instant);
} catch (DateTimeParseException e) {
logger.info("invalid date format (yyyy-MM-dd HH:mm:ss) for date string: '" + date + "'");
logger.info("invalid date format '{}' for date string: '{}'", DEFAULT_DATE_FORMAT, date);
return null;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

package org.kitodo.production.helper;

import static org.kitodo.constants.StringConstants.DEFAULT_DATE_FORMAT;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
Expand Down Expand Up @@ -131,7 +133,7 @@ private static Task getCurrentTask(Property property) throws DAOException {
}

private static Date getCreationDate(Property property) throws ParseException {
return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(property.getValue().substring(1, 20));
return new SimpleDateFormat(DEFAULT_DATE_FORMAT).parse(property.getValue().substring(1, 20));
}

private static String getWikiFieldMessage(String message) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

package org.kitodo.production.security;

import static org.kitodo.constants.StringConstants.DEFAULT_DATE_FORMAT;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

Expand Down Expand Up @@ -73,7 +75,7 @@ public LocalDateTime getLastRequest() {
* @return The lastRequest.
*/
public String getLastRequestAsString() {
return lastRequest.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
return lastRequest.format(DateTimeFormatter.ofPattern(DEFAULT_DATE_FORMAT));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import static org.elasticsearch.index.query.QueryBuilders.matchQuery;
import static org.elasticsearch.index.query.QueryBuilders.multiMatchQuery;
import static org.elasticsearch.index.query.QueryBuilders.nestedQuery;
import static org.kitodo.constants.StringConstants.DEFAULT_DATE_FORMAT;
import static org.kitodo.data.database.enums.CorrectionComments.NO_CORRECTION_COMMENTS;
import static org.kitodo.data.database.enums.CorrectionComments.NO_OPEN_CORRECTION_COMMENTS;
import static org.kitodo.data.database.enums.CorrectionComments.OPEN_CORRECTION_COMMENTS;
Expand Down Expand Up @@ -2223,7 +2224,7 @@ public static String getPropertyValue(ProcessDTO process, String propertyName) {
*/
public static String getProcessDuration(ProcessDTO process) {
String creationDateTimeString = process.getCreationDate();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DEFAULT_DATE_FORMAT);
LocalDateTime createLocalDate = LocalDateTime.parse(creationDateTimeString, formatter);
Duration duration = Duration.between(createLocalDate, LocalDateTime.now());
return String.format("%sd; %sh", duration.toDays(),
Expand Down
48 changes: 24 additions & 24 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,30 +42,30 @@
<maven.compiler.debuglevel>lines,vars,source</maven.compiler.debuglevel>
<maxAllowedViolations>0</maxAllowedViolations>
<tomcat.baseversion>9</tomcat.baseversion>
<tomcat.version>9.0.65</tomcat.version>
<awaitility.version>4.0.1</awaitility.version>
<tomcat.version>9.0.96</tomcat.version>
<awaitility.version>4.0.3</awaitility.version>
<com.h2database.h2.version>2.2.224</com.h2database.h2.version>
<commons-codec.version>1.15</commons-codec.version>
<commons-io.version>2.14.0</commons-io.version>
<commons-lang3.version>3.14.0</commons-lang3.version>
<commons-net.version>3.9.0</commons-net.version>
<org.apache.xmlgraphics.version>2.8</org.apache.xmlgraphics.version>
<org.apache.avalon.framework.version>4.3.1</org.apache.avalon.framework.version>
<hamcrest.version>2.2-rc1</hamcrest.version>
<hibernate.version>5.6.10.Final</hibernate.version>
<hamcrest.version>2.2</hamcrest.version>
<hibernate.version>5.6.15.Final</hibernate.version>
<jaxb.api.version>2.3.3</jaxb.api.version>
<jaxb.glassfish-runtime.version>2.3.9</jaxb.glassfish-runtime.version>
<jaxb2-basics-runtime.version>1.11.1</jaxb2-basics-runtime.version>
<jaxen.version>1.2.0</jaxen.version>
<jhove.version>1.20.1</jhove.version>
<myfaces.version>2.3.10</myfaces.version>
<mysql.version>8.0.31</mysql.version>
<poi.version>5.2.2</poi.version>
<mysql.version>8.0.33</mysql.version>
<poi.version>5.2.5</poi.version>
<primefaces.extensions.version>8.0.5</primefaces.extensions.version>
<saxon.version>9.9.1-8</saxon.version>
<log4j.version>2.19.0</log4j.version>
<junit.version>5.9.2</junit.version>
<elasticsearch.version>7.17.24</elasticsearch.version>
<junit.version>5.9.3</junit.version>
<elasticsearch.version>7.17.25</elasticsearch.version>
<maven-failsafe-plugin.version>2.22.2</maven-failsafe-plugin.version>

<!-- maven-resources-plugin versions greater 3.2.0 introduce changes that
Expand All @@ -77,11 +77,11 @@
<mockito.version>5.9.0</mockito.version>
<properties-maven-plugin.version>1.2.1</properties-maven-plugin.version>
<selenium.version>3.141.59</selenium.version>
<spring.security.version>5.7.11</spring.security.version>
<spring.security.version>5.7.13</spring.security.version>
<flyway-maven-plugin.version>8.4.4</flyway-maven-plugin.version>
<spotbugs-maven-plugin.version>4.3.0</spotbugs-maven-plugin.version>
<pitest.version>1.4.10</pitest.version>
<mariadb-java-client.version>2.7.6</mariadb-java-client.version>
<mariadb-java-client.version>2.7.12</mariadb-java-client.version>
<maven-javadoc-plugin.version>3.3.0</maven-javadoc-plugin.version>
</properties>

Expand Down Expand Up @@ -127,7 +127,7 @@
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>itextpdf</artifactId>
<version>5.5.13.3</version>
<version>5.5.13.4</version>
</dependency>
<dependency>
<groupId>com.opencsv</groupId>
Expand All @@ -137,7 +137,7 @@
<dependency>
<groupId>com.xebialabs.restito</groupId>
<artifactId>restito</artifactId>
<version>0.9.3</version>
<version>0.9.5</version>
<exclusions>
<exclusion>
<groupId>junit</groupId>
Expand Down Expand Up @@ -185,7 +185,7 @@
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.3.1</version>
<version>1.3.4</version>
</dependency>
<dependency>
<groupId>commons-net</groupId>
Expand Down Expand Up @@ -265,7 +265,7 @@ from system library in Java 11+ -->
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-client</artifactId>
<version>5.18.5</version>
<version>5.18.6</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
Expand All @@ -286,7 +286,7 @@ from system library in Java 11+ -->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.13</version>
<version>4.5.14</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
Expand Down Expand Up @@ -332,7 +332,7 @@ from system library in Java 11+ -->
<dependency>
<groupId>org.apache.pdfbox</groupId>
<artifactId>pdfbox</artifactId>
<version>3.0.0-RC1</version>
<version>3.0.3</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -414,7 +414,7 @@ from system library in Java 11+ -->
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk18on</artifactId>
<version>1.78</version>
<version>1.78.1</version>
</dependency>
<dependency>
<groupId>org.camunda.bpm.model</groupId>
Expand All @@ -424,12 +424,12 @@ from system library in Java 11+ -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.17.1</version>
<version>2.17.2</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.17.1</version>
<version>2.17.2</version>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
Expand Down Expand Up @@ -485,7 +485,7 @@ from system library in Java 11+ -->
<!-- hibernate caching dependency -->
<groupId>org.ehcache</groupId>
<artifactId>ehcache</artifactId>
<version>3.8.1</version>
<version>3.8.2.1</version>
<scope>runtime</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -529,7 +529,7 @@ from system library in Java 11+ -->
<dependency>
<groupId>org.hibernate.validator</groupId>
<artifactId>hibernate-validator</artifactId>
<version>6.2.4.Final</version>
<version>6.2.5.Final</version>
<exclusions>
<exclusion>
<groupId>org.jboss.logging</groupId>
Expand Down Expand Up @@ -613,7 +613,7 @@ from system library in Java 11+ -->
<dependency>
<groupId>org.omnifaces</groupId>
<artifactId>omnifaces</artifactId>
<version>3.13.3</version>
<version>3.13.4</version>
</dependency>
<dependency>
<groupId>org.openpreservation.jhove</groupId>
Expand All @@ -633,7 +633,7 @@ from system library in Java 11+ -->
<dependency>
<groupId>org.passay</groupId>
<artifactId>passay</artifactId>
<version>1.6.2</version>
<version>1.6.6</version>
</dependency>
<dependency>
<groupId>org.primefaces.extensions</groupId>
Expand Down Expand Up @@ -803,7 +803,7 @@ from system library in Java 11+ -->
<dependency>
<groupId>org.xmlunit</groupId>
<artifactId>xmlunit-matchers</artifactId>
<version>2.9.0</version>
<version>2.9.1</version>
</dependency>
<dependency>
<groupId>se.jiderhamn.classloader-leak-prevention</groupId>
Expand Down