diff --git a/.classpath b/.classpath index 46d8fda..3aa8237 100644 --- a/.classpath +++ b/.classpath @@ -2,25 +2,23 @@ - - + - - - - - - - - + + - - - + + + + + + + + diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs index 7ced310..cef5ca2 100644 --- a/.settings/org.eclipse.jdt.core.prefs +++ b/.settings/org.eclipse.jdt.core.prefs @@ -1,14 +1,14 @@ eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.compliance=1.8 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.6 +org.eclipse.jdt.core.compiler.source=1.8 org.eclipse.jdt.core.formatter.align_type_members_on_columns=false org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0 diff --git a/.settings/org.eclipse.wst.common.project.facet.core.xml b/.settings/org.eclipse.wst.common.project.facet.core.xml index fd68f7e..fd0227a 100644 --- a/.settings/org.eclipse.wst.common.project.facet.core.xml +++ b/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -2,6 +2,6 @@ - + diff --git a/lib/Logs/slf4j-api-1.7.25-sources.jar b/lib/Logs/slf4j-api-1.7.25-sources.jar new file mode 100644 index 0000000..b2a3d83 Binary files /dev/null and b/lib/Logs/slf4j-api-1.7.25-sources.jar differ diff --git a/lib/Logs/slf4j-api-1.7.25.jar b/lib/Logs/slf4j-api-1.7.25.jar new file mode 100644 index 0000000..7e62f13 Binary files /dev/null and b/lib/Logs/slf4j-api-1.7.25.jar differ diff --git a/lib/Logs/slf4j-api-1.7.5-sources.jar b/lib/Logs/slf4j-api-1.7.5-sources.jar deleted file mode 100644 index 51abe2b..0000000 Binary files a/lib/Logs/slf4j-api-1.7.5-sources.jar and /dev/null differ diff --git a/lib/Logs/slf4j-api-1.7.5.jar b/lib/Logs/slf4j-api-1.7.5.jar deleted file mode 100644 index 8766455..0000000 Binary files a/lib/Logs/slf4j-api-1.7.5.jar and /dev/null differ diff --git a/lib/Logs/slf4j-log4j12-1.7.25-sources.jar b/lib/Logs/slf4j-log4j12-1.7.25-sources.jar new file mode 100644 index 0000000..0cd5be7 Binary files /dev/null and b/lib/Logs/slf4j-log4j12-1.7.25-sources.jar differ diff --git a/lib/Logs/slf4j-log4j12-1.7.25.jar b/lib/Logs/slf4j-log4j12-1.7.25.jar new file mode 100644 index 0000000..4a44e06 Binary files /dev/null and b/lib/Logs/slf4j-log4j12-1.7.25.jar differ diff --git a/lib/Logs/slf4j-log4j12-1.7.5-sources.jar b/lib/Logs/slf4j-log4j12-1.7.5-sources.jar deleted file mode 100644 index ea1b93b..0000000 Binary files a/lib/Logs/slf4j-log4j12-1.7.5-sources.jar and /dev/null differ diff --git a/lib/Logs/slf4j-log4j12-1.7.5.jar b/lib/Logs/slf4j-log4j12-1.7.5.jar deleted file mode 100644 index afce5c2..0000000 Binary files a/lib/Logs/slf4j-log4j12-1.7.5.jar and /dev/null differ diff --git a/lib/UnitTesting/junit-4.11-sources.jar b/lib/UnitTesting/junit-4.11-sources.jar deleted file mode 100644 index bab4cdd..0000000 Binary files a/lib/UnitTesting/junit-4.11-sources.jar and /dev/null differ diff --git a/lib/UnitTesting/junit-4.11.jar b/lib/UnitTesting/junit-4.11.jar deleted file mode 100644 index aaf7444..0000000 Binary files a/lib/UnitTesting/junit-4.11.jar and /dev/null differ diff --git a/lib/UnitTesting/junit-4.12-sources.jar b/lib/UnitTesting/junit-4.12-sources.jar new file mode 100644 index 0000000..884f92f Binary files /dev/null and b/lib/UnitTesting/junit-4.12-sources.jar differ diff --git a/lib/UnitTesting/junit-4.12.jar b/lib/UnitTesting/junit-4.12.jar new file mode 100644 index 0000000..3a7fc26 Binary files /dev/null and b/lib/UnitTesting/junit-4.12.jar differ diff --git a/lib/commons-io-2.4-sources.jar b/lib/commons-io-2.4-sources.jar deleted file mode 100644 index f4ebc7b..0000000 Binary files a/lib/commons-io-2.4-sources.jar and /dev/null differ diff --git a/lib/commons-io-2.4.jar b/lib/commons-io-2.4.jar deleted file mode 100644 index 90035a4..0000000 Binary files a/lib/commons-io-2.4.jar and /dev/null differ diff --git a/lib/commons-io-2.6-sources.jar b/lib/commons-io-2.6-sources.jar new file mode 100644 index 0000000..231cbe4 Binary files /dev/null and b/lib/commons-io-2.6-sources.jar differ diff --git a/lib/commons-io-2.6.jar b/lib/commons-io-2.6.jar new file mode 100644 index 0000000..00556b1 Binary files /dev/null and b/lib/commons-io-2.6.jar differ diff --git a/lib/commons-lang3-3.1-sources.jar b/lib/commons-lang3-3.1-sources.jar deleted file mode 100644 index 02cd2f2..0000000 Binary files a/lib/commons-lang3-3.1-sources.jar and /dev/null differ diff --git a/lib/commons-lang3-3.1.jar b/lib/commons-lang3-3.1.jar deleted file mode 100644 index a85e539..0000000 Binary files a/lib/commons-lang3-3.1.jar and /dev/null differ diff --git a/lib/commons-lang3-3.7-sources.jar b/lib/commons-lang3-3.7-sources.jar new file mode 100644 index 0000000..a83c661 Binary files /dev/null and b/lib/commons-lang3-3.7-sources.jar differ diff --git a/lib/commons-lang3-3.7.jar b/lib/commons-lang3-3.7.jar new file mode 100644 index 0000000..f37ded6 Binary files /dev/null and b/lib/commons-lang3-3.7.jar differ diff --git a/lib/devinsy-strings-0.4.4-sources.zip b/lib/devinsy-strings-0.4.4-sources.zip deleted file mode 100644 index 8ccb845..0000000 Binary files a/lib/devinsy-strings-0.4.4-sources.zip and /dev/null differ diff --git a/lib/devinsy-strings-0.4.4.jar b/lib/devinsy-strings-0.4.4.jar deleted file mode 100644 index 01ced79..0000000 Binary files a/lib/devinsy-strings-0.4.4.jar and /dev/null differ diff --git a/lib/devinsy-strings-0.8.2-sources.zip b/lib/devinsy-strings-0.8.2-sources.zip new file mode 100644 index 0000000..815e0b8 Binary files /dev/null and b/lib/devinsy-strings-0.8.2-sources.zip differ diff --git a/lib/devinsy-strings-0.8.2.jar b/lib/devinsy-strings-0.8.2.jar new file mode 100644 index 0000000..1e95075 Binary files /dev/null and b/lib/devinsy-strings-0.8.2.jar differ diff --git a/lib/devinsy-xml-0.4.2-sources.zip b/lib/devinsy-xml-0.4.2-sources.zip deleted file mode 100644 index 97b2e14..0000000 Binary files a/lib/devinsy-xml-0.4.2-sources.zip and /dev/null differ diff --git a/lib/devinsy-xml-0.4.2.jar b/lib/devinsy-xml-0.4.2.jar deleted file mode 100644 index 98be2c0..0000000 Binary files a/lib/devinsy-xml-0.4.2.jar and /dev/null differ diff --git a/lib/devinsy-xml-0.8.2-sources.zip b/lib/devinsy-xml-0.8.2-sources.zip new file mode 100644 index 0000000..0f6e693 Binary files /dev/null and b/lib/devinsy-xml-0.8.2-sources.zip differ diff --git a/lib/devinsy-xml-0.8.2.jar b/lib/devinsy-xml-0.8.2.jar new file mode 100644 index 0000000..a50811b Binary files /dev/null and b/lib/devinsy-xml-0.8.2.jar differ diff --git a/lib/joda-time-2.3-sources.jar b/lib/joda-time-2.3-sources.jar deleted file mode 100644 index a2dda2e..0000000 Binary files a/lib/joda-time-2.3-sources.jar and /dev/null differ diff --git a/lib/joda-time-2.3.jar b/lib/joda-time-2.3.jar deleted file mode 100644 index 9dce4f9..0000000 Binary files a/lib/joda-time-2.3.jar and /dev/null differ diff --git a/src/fr/devinsy/sikevadb/cli/SikevaDBCLI.java b/src/fr/devinsy/sikevadb/cli/SikevaDBCLI.java index 1331485..b9979c9 100644 --- a/src/fr/devinsy/sikevadb/cli/SikevaDBCLI.java +++ b/src/fr/devinsy/sikevadb/cli/SikevaDBCLI.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013-2017 Christian Pierre MOMON + * Copyright (C) 2013-2018 Christian Pierre MOMON * * This file is part of SikevaDB, simple key value database. * @@ -27,9 +27,9 @@ import org.apache.log4j.PropertyConfigurator; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import utils.BuildInformation; import fr.devinsy.sikevadb.core.SikevaDBException; -import fr.devinsy.util.strings.StringList; +import fr.devinsy.strings.StringList; +import utils.BuildInformation; /** * The Class SikevaDBCLI manages a Command Line Interface for diff --git a/src/fr/devinsy/sikevadb/core/Element.java b/src/fr/devinsy/sikevadb/core/Element.java index c9b1e02..585571c 100644 --- a/src/fr/devinsy/sikevadb/core/Element.java +++ b/src/fr/devinsy/sikevadb/core/Element.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013-2017 Christian Pierre MOMON + * Copyright (C) 2013-2018 Christian Pierre MOMON * * This file is part of SikevaDB, simple key value database. * @@ -18,8 +18,9 @@ */ package fr.devinsy.sikevadb.core; +import java.time.LocalDateTime; + import org.apache.commons.codec.digest.DigestUtils; -import org.joda.time.DateTime; /** * The Class Element. @@ -31,10 +32,10 @@ public class Element public static final long NO_ID = -1; private long id; - private DateTime creationDate; - private DateTime editionDate; + private LocalDateTime creationDate; + private LocalDateTime editionDate; /* archiveDate field is reserved for journalizer. */ - private DateTime archiveDate; + private LocalDateTime archiveDate; private String key; private String subkey; private long size; @@ -72,7 +73,7 @@ public class Element */ public void archive() { - this.archiveDate = DateTime.now(); + this.archiveDate = LocalDateTime.now(); } /** @@ -80,7 +81,7 @@ public class Element * * @return the archive date */ - public DateTime getArchiveDate() + public LocalDateTime getArchiveDate() { return this.archiveDate; } @@ -90,7 +91,7 @@ public class Element * * @return the creation date */ - public DateTime getCreationDate() + public LocalDateTime getCreationDate() { return this.creationDate; } @@ -110,7 +111,7 @@ public class Element * * @return the edition date */ - public DateTime getEditionDate() + public LocalDateTime getEditionDate() { return this.editionDate; } @@ -171,7 +172,7 @@ public class Element * @param date * the new archive date */ - public void setArchiveDate(final DateTime date) + public void setArchiveDate(final LocalDateTime date) { this.archiveDate = date; } @@ -182,7 +183,7 @@ public class Element * @param date * the new creation date */ - public void setCreationDate(final DateTime date) + public void setCreationDate(final LocalDateTime date) { this.creationDate = date; } @@ -204,7 +205,7 @@ public class Element * @param date * the new edition date */ - public void setEditionDate(final DateTime date) + public void setEditionDate(final LocalDateTime date) { this.editionDate = date; } @@ -276,7 +277,7 @@ public class Element setValue(value); // - this.editionDate = DateTime.now(); + this.editionDate = LocalDateTime.now(); // if (value == null) diff --git a/src/fr/devinsy/sikevadb/core/SikevaDB.java b/src/fr/devinsy/sikevadb/core/SikevaDB.java index fa0f4ba..52b0ca6 100644 --- a/src/fr/devinsy/sikevadb/core/SikevaDB.java +++ b/src/fr/devinsy/sikevadb/core/SikevaDB.java @@ -18,7 +18,7 @@ */ package fr.devinsy.sikevadb.core; -import fr.devinsy.util.strings.StringList; +import fr.devinsy.strings.StringList; /** * The Interface SikevaDB. @@ -160,6 +160,15 @@ public interface SikevaDB */ public void destroy() throws SikevaDBException; + /** + * Checks if is created. + * + * @return true, if is created + * @throws SikevaDBException + * the SikevaDB exception + */ + public boolean exists() throws SikevaDBException; + /** * Gets an element by key. * @@ -217,15 +226,6 @@ public interface SikevaDB */ public Elements getElements(String key) throws SikevaDBException; - /** - * Gets all the top keys. - * - * @return the keys - * @throws SikevaDBException - * the SikevaDB exception - */ - public StringList getTopKeys() throws SikevaDBException; - /** * Gets all the sub keys of a key. * @@ -237,6 +237,15 @@ public interface SikevaDB */ public StringList getSubkeys(String key) throws SikevaDBException; + /** + * Gets all the top keys. + * + * @return the keys + * @throws SikevaDBException + * the SikevaDB exception + */ + public StringList getTopKeys() throws SikevaDBException; + /** * Gets the value of a key. * @@ -296,15 +305,6 @@ public interface SikevaDB */ public boolean isClosed(); - /** - * Checks if is created. - * - * @return true, if is created - * @throws SikevaDBException - * the SikevaDB exception - */ - public boolean exists() throws SikevaDBException; - /** * Checks if is opened. * diff --git a/src/fr/devinsy/sikevadb/core/XMLSikevaDB.java b/src/fr/devinsy/sikevadb/core/XMLSikevaDB.java index 6cc00a3..823928e 100644 --- a/src/fr/devinsy/sikevadb/core/XMLSikevaDB.java +++ b/src/fr/devinsy/sikevadb/core/XMLSikevaDB.java @@ -23,20 +23,21 @@ import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; import javax.xml.stream.XMLStreamException; import org.apache.commons.lang3.StringEscapeUtils; -import org.joda.time.DateTime; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import fr.devinsy.util.xml.XMLBadFormatException; -import fr.devinsy.util.xml.XMLReader; -import fr.devinsy.util.xml.XMLTag; -import fr.devinsy.util.xml.XMLTag.TagType; -import fr.devinsy.util.xml.XMLWriter; -import fr.devinsy.util.xml.XMLZipWriter; +import fr.devinsy.xml.XMLBadFormatException; +import fr.devinsy.xml.XMLReader; +import fr.devinsy.xml.XMLTag; +import fr.devinsy.xml.XMLTag.TagType; +import fr.devinsy.xml.XMLWriter; +import fr.devinsy.xml.XMLZipWriter; /** * The Class XMLSikevaDB represents a XML persister. @@ -77,7 +78,7 @@ public class XMLSikevaDB public static void export(final OutputStream out, final SikevaDB source) throws SikevaDBException { // - String fileName = "sikevadb-" + DateTime.now().toString("yyyy-MM-dd-HH'h'mm'mn'ss's'") + ".xml.zip"; + String fileName = "sikevadb-" + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd-HH'h'mm'mn'ss's'")) + ".xml.zip"; // export(out, source, fileName); @@ -196,10 +197,10 @@ public class XMLSikevaDB String value = StringEscapeUtils.unescapeXml(in.readContentTag("value").getContent()); int size = Integer.parseInt(tag.attributes().getByLabel("size").getValue()); String digest = in.readContentTag("digest").getContent(); - DateTime creationDate = DateTime.parse(in.readContentTag("creation_date").getContent()); - DateTime editionDate = DateTime.parse(in.readContentTag("edition_date").getContent()); + LocalDateTime creationDate = LocalDateTime.parse(in.readContentTag("creation_date").getContent()); + LocalDateTime editionDate = LocalDateTime.parse(in.readContentTag("edition_date").getContent()); - DateTime archiveDate; + LocalDateTime archiveDate; String archiveDateValue = in.readNullableContentTag("archive_date").getContent(); if (archiveDateValue == null) { @@ -207,7 +208,7 @@ public class XMLSikevaDB } else { - archiveDate = DateTime.parse(archiveDateValue); + archiveDate = LocalDateTime.parse(archiveDateValue); } // @@ -341,8 +342,8 @@ public class XMLSikevaDB } /** - * Write in an XML writer the elements of a database, sorting by keys and - * sub keys. + * Write in an XML writer the elements of a database, sorting by keys and sub + * keys. * * @param out * the out diff --git a/src/fr/devinsy/sikevadb/demo/SikevaDBDemo.java b/src/fr/devinsy/sikevadb/demo/SikevaDBDemo.java index 2d6d734..ef3bb64 100644 --- a/src/fr/devinsy/sikevadb/demo/SikevaDBDemo.java +++ b/src/fr/devinsy/sikevadb/demo/SikevaDBDemo.java @@ -27,11 +27,11 @@ import org.apache.log4j.PropertyConfigurator; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import utils.BuildInformation; import fr.devinsy.sikevadb.core.SikevaDB; import fr.devinsy.sikevadb.core.SikevaDBException; import fr.devinsy.sikevadb.core.SikevaDBFactory; -import fr.devinsy.util.strings.StringList; +import fr.devinsy.strings.StringList; +import utils.BuildInformation; /** * The Class SikevaDBDemo is a demo for SikevaDB. diff --git a/src/fr/devinsy/sikevadb/filetree/FileTreeSikevaDB.java b/src/fr/devinsy/sikevadb/filetree/FileTreeSikevaDB.java index 2b2086f..0ba2544 100644 --- a/src/fr/devinsy/sikevadb/filetree/FileTreeSikevaDB.java +++ b/src/fr/devinsy/sikevadb/filetree/FileTreeSikevaDB.java @@ -24,8 +24,6 @@ import java.io.IOException; import org.apache.commons.io.FileUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.SystemUtils; -import org.joda.time.format.DateTimeFormatter; -import org.joda.time.format.ISODateTimeFormat; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -36,8 +34,8 @@ import fr.devinsy.sikevadb.core.Elements; import fr.devinsy.sikevadb.core.OpenedDatabaseException; import fr.devinsy.sikevadb.core.SikevaDB; import fr.devinsy.sikevadb.core.SikevaDBException; -import fr.devinsy.util.strings.StringList; -import fr.devinsy.util.strings.StringsUtils; +import fr.devinsy.strings.StringList; +import fr.devinsy.strings.StringsUtils; /** * The Class FileTreeSikevaDB. @@ -58,15 +56,13 @@ import fr.devinsy.util.strings.StringsUtils; */ public class FileTreeSikevaDB implements SikevaDB { + private static final Logger logger = LoggerFactory.getLogger(FileTreeSikevaDB.class); + public enum Status { OPENED, CLOSED - }; - - private static final Logger logger = LoggerFactory.getLogger(FileTreeSikevaDB.class); - - private static final DateTimeFormatter ISOFormatter = ISODateTimeFormat.dateHourMinuteSecondMillis(); + } private Status status; private String login; diff --git a/src/fr/devinsy/sikevadb/filetree/FileTreeSikevaDBTools.java b/src/fr/devinsy/sikevadb/filetree/FileTreeSikevaDBTools.java index fd3ceea..0373c58 100644 --- a/src/fr/devinsy/sikevadb/filetree/FileTreeSikevaDBTools.java +++ b/src/fr/devinsy/sikevadb/filetree/FileTreeSikevaDBTools.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013-2017 Christian Pierre MOMON + * Copyright (C) 2013-2018 Christian Pierre MOMON * * This file is part of SikevaDB, simple key value database. * @@ -22,18 +22,18 @@ import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; import java.io.UnsupportedEncodingException; +import java.time.LocalDateTime; import javax.xml.stream.XMLStreamException; -import org.joda.time.DateTime; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import fr.devinsy.sikevadb.core.Element; import fr.devinsy.sikevadb.core.SikevaDBException; -import fr.devinsy.util.xml.XMLBadFormatException; -import fr.devinsy.util.xml.XMLReader; -import fr.devinsy.util.xml.XMLWriter; +import fr.devinsy.xml.XMLBadFormatException; +import fr.devinsy.xml.XMLReader; +import fr.devinsy.xml.XMLWriter; /** * The Class FileTreeSikevaDBTools. @@ -84,11 +84,11 @@ public class FileTreeSikevaDBTools result.setId(id); // private DateTime creationDate; IN - DateTime creationDate = DateTime.parse(in.readContentTag("creation_date").getContent()); + LocalDateTime creationDate = LocalDateTime.parse(in.readContentTag("creation_date").getContent()); result.setCreationDate(creationDate); // private DateTime editionDate; IN - DateTime editionDate = DateTime.parse(in.readContentTag("edition_date").getContent()); + LocalDateTime editionDate = LocalDateTime.parse(in.readContentTag("edition_date").getContent()); result.setEditionDate(editionDate); // private long size; IN diff --git a/src/fr/devinsy/sikevadb/sql/SQLSikevaDB.java b/src/fr/devinsy/sikevadb/sql/SQLSikevaDB.java index aaed024..2b4fae0 100644 --- a/src/fr/devinsy/sikevadb/sql/SQLSikevaDB.java +++ b/src/fr/devinsy/sikevadb/sql/SQLSikevaDB.java @@ -43,7 +43,7 @@ import fr.devinsy.sikevadb.core.Elements; import fr.devinsy.sikevadb.core.OpenedDatabaseException; import fr.devinsy.sikevadb.core.SikevaDB; import fr.devinsy.sikevadb.core.SikevaDBException; -import fr.devinsy.util.strings.StringList; +import fr.devinsy.strings.StringList; /** * The Class SQLSikevaDB. @@ -53,14 +53,14 @@ import fr.devinsy.util.strings.StringList; public class SQLSikevaDB implements SikevaDB { + private static final Logger logger = LoggerFactory.getLogger(SQLSikevaDB.class);; + public enum Status { OPENED, CLOSED }; - private static final Logger logger = LoggerFactory.getLogger(SQLSikevaDB.class);; - private Status status; private String driverClassname; private String url; @@ -938,8 +938,8 @@ public class SQLSikevaDB implements SikevaDB // connection = getConnection(); connection.setAutoCommit(true); - statement = connection - .prepareStatement("SELECT ID,TOPKEY,SUBKEY,VALUE,SIZE,DIGEST,CREATION_DATE,EDITION_DATE,ARCHIVE_DATE FROM sikevadb_elements WHERE ARCHIVE_DATE IS NULL AND TOPKEY=? AND SUBKEY IS NULL"); + statement = connection.prepareStatement( + "SELECT ID,TOPKEY,SUBKEY,VALUE,SIZE,DIGEST,CREATION_DATE,EDITION_DATE,ARCHIVE_DATE FROM sikevadb_elements WHERE ARCHIVE_DATE IS NULL AND TOPKEY=? AND SUBKEY IS NULL"); statement.setString(1, key); resultSet = statement.executeQuery(); @@ -1036,8 +1036,8 @@ public class SQLSikevaDB implements SikevaDB // connection = getConnection(); connection.setAutoCommit(true); - statement = connection - .prepareStatement("SELECT ID,TOPKEY,SUBKEY,VALUE,SIZE,DIGEST,CREATION_DATE,EDITION_DATE,ARCHIVE_DATE FROM sikevadb_elements WHERE ARCHIVE_DATE IS NULL AND TOPKEY=? AND SUBKEY=?"); + statement = connection.prepareStatement( + "SELECT ID,TOPKEY,SUBKEY,VALUE,SIZE,DIGEST,CREATION_DATE,EDITION_DATE,ARCHIVE_DATE FROM sikevadb_elements WHERE ARCHIVE_DATE IS NULL AND TOPKEY=? AND SUBKEY=?"); statement.setString(1, key); statement.setString(2, subkey); resultSet = statement.executeQuery(); @@ -1110,8 +1110,8 @@ public class SQLSikevaDB implements SikevaDB { connection = getConnection(); connection.setAutoCommit(true); - statement = connection - .prepareStatement("SELECT ID,TOPKEY,SUBKEY,VALUE,SIZE,DIGEST,CREATION_DATE,EDITION_DATE,ARCHIVE_DATE FROM sikevadb_elements WHERE ARCHIVE_DATE IS NULL ORDER BY TOPKEY,SUBKEY ASC"); + statement = connection.prepareStatement( + "SELECT ID,TOPKEY,SUBKEY,VALUE,SIZE,DIGEST,CREATION_DATE,EDITION_DATE,ARCHIVE_DATE FROM sikevadb_elements WHERE ARCHIVE_DATE IS NULL ORDER BY TOPKEY,SUBKEY ASC"); resultSet = statement.executeQuery(); while (resultSet.next()) @@ -1177,8 +1177,8 @@ public class SQLSikevaDB implements SikevaDB { connection = getConnection(); connection.setAutoCommit(true); - statement = connection - .prepareStatement("SELECT ID,TOPKEY,SUBKEY,VALUE,SIZE,DIGEST,CREATION_DATE,EDITION_DATE,ARCHIVE_DATE FROM sikevadb_elements WHERE ARCHIVE_DATE IS NULL AND TOPKEY=? AND SUBKEY IS NULL ORDER BY CREATION_DATE ASC"); + statement = connection.prepareStatement( + "SELECT ID,TOPKEY,SUBKEY,VALUE,SIZE,DIGEST,CREATION_DATE,EDITION_DATE,ARCHIVE_DATE FROM sikevadb_elements WHERE ARCHIVE_DATE IS NULL AND TOPKEY=? AND SUBKEY IS NULL ORDER BY CREATION_DATE ASC"); statement.setString(1, key); resultSet = statement.executeQuery(); diff --git a/src/fr/devinsy/sikevadb/sql/SQLSikevaDBTools.java b/src/fr/devinsy/sikevadb/sql/SQLSikevaDBTools.java index 2f8b4d5..f6bf3d3 100644 --- a/src/fr/devinsy/sikevadb/sql/SQLSikevaDBTools.java +++ b/src/fr/devinsy/sikevadb/sql/SQLSikevaDBTools.java @@ -22,15 +22,16 @@ import java.io.BufferedReader; import java.io.IOException; import java.io.StringReader; import java.net.URL; +import java.time.LocalDateTime; +import java.time.ZoneOffset; import java.util.Date; import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.StringUtils; -import org.joda.time.DateTime; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import fr.devinsy.util.strings.StringList; +import fr.devinsy.strings.StringList; /** * The Class SQLSikevaDBTools. @@ -129,9 +130,9 @@ public class SQLSikevaDBTools * the source * @return the date time */ - public static DateTime toDateTime(final java.sql.Timestamp source) + public static LocalDateTime toDateTime(final java.sql.Timestamp source) { - DateTime result; + LocalDateTime result; if (source == null) { @@ -139,7 +140,7 @@ public class SQLSikevaDBTools } else { - result = new DateTime(source.getTime()); + result = LocalDateTime.ofEpochSecond(source.getTime(), 0, ZoneOffset.UTC); } // @@ -177,7 +178,7 @@ public class SQLSikevaDBTools * the source * @return the java.sql. timestamp */ - public static java.sql.Timestamp toTimestamp(final DateTime source) + public static java.sql.Timestamp toTimestamp(final LocalDateTime source) { java.sql.Timestamp result; @@ -187,7 +188,7 @@ public class SQLSikevaDBTools } else { - result = new java.sql.Timestamp(source.getMillis()); + result = new java.sql.Timestamp(source.toEpochSecond(ZoneOffset.UTC)); } // diff --git a/test/fr/devinsy/sikevadb/filetree/TreeFileSikevaDBTest.java b/test/fr/devinsy/sikevadb/filetree/TreeFileSikevaDBTest.java index 5008a9c..cf8746e 100644 --- a/test/fr/devinsy/sikevadb/filetree/TreeFileSikevaDBTest.java +++ b/test/fr/devinsy/sikevadb/filetree/TreeFileSikevaDBTest.java @@ -19,13 +19,13 @@ package fr.devinsy.sikevadb.filetree; import java.io.File; +import java.time.LocalDateTime; import org.apache.commons.codec.binary.Base64; import org.apache.commons.lang3.RandomStringUtils; import org.apache.log4j.BasicConfigurator; import org.apache.log4j.Level; import org.apache.log4j.Logger; -import org.joda.time.DateTime; import org.junit.AfterClass; import org.junit.Assert; import org.junit.BeforeClass; @@ -35,7 +35,7 @@ import fr.devinsy.sikevadb.core.Element; import fr.devinsy.sikevadb.core.Elements; import fr.devinsy.sikevadb.core.SikevaDBException; import fr.devinsy.sikevadb.core.XMLSikevaDB; -import fr.devinsy.util.strings.StringList; +import fr.devinsy.strings.StringList; /** * The Class TreeFileSikevaDBTest. @@ -372,9 +372,9 @@ public class TreeFileSikevaDBTest element.setSubkey(null); element.setSize(10); element.setDigest("qsdkfqskjf"); - element.setCreationDate(DateTime.now().minusDays(11)); - element.setEditionDate(DateTime.now().minusDays(11)); - element.setArchiveDate(DateTime.now().minusDays(10)); + element.setCreationDate(LocalDateTime.now().minusDays(11)); + element.setEditionDate(LocalDateTime.now().minusDays(11)); + element.setArchiveDate(LocalDateTime.now().minusDays(10)); element.setValue("bonjour"); database.put(element); @@ -409,9 +409,9 @@ public class TreeFileSikevaDBTest element.setSubkey(null); element.setSize(10); element.setDigest("qsdkfqskjf"); - element.setCreationDate(DateTime.now().minusDays(11)); - element.setEditionDate(DateTime.now().minusDays(11)); - element.setArchiveDate(DateTime.now().minusDays(10)); + element.setCreationDate(LocalDateTime.now().minusDays(11)); + element.setEditionDate(LocalDateTime.now().minusDays(11)); + element.setArchiveDate(LocalDateTime.now().minusDays(10)); element.setValue("bonjour"); database.put(element); @@ -446,9 +446,9 @@ public class TreeFileSikevaDBTest element.setSubkey(null); element.setSize(10); element.setDigest("qsdkfqskjf"); - element.setCreationDate(DateTime.now().minusDays(11)); - element.setEditionDate(DateTime.now().minusDays(11)); - element.setArchiveDate(DateTime.now().minusDays(10)); + element.setCreationDate(LocalDateTime.now().minusDays(11)); + element.setEditionDate(LocalDateTime.now().minusDays(11)); + element.setArchiveDate(LocalDateTime.now().minusDays(10)); element.setValue("bonjour"); database.put(element); @@ -461,9 +461,9 @@ public class TreeFileSikevaDBTest element.setSubkey(null); element.setSize(10); element.setDigest("qsdkfqskjf"); - element.setCreationDate(DateTime.now().minusDays(11)); - element.setEditionDate(DateTime.now().minusDays(11)); - element.setArchiveDate(DateTime.now().minusDays(10)); + element.setCreationDate(LocalDateTime.now().minusDays(11)); + element.setEditionDate(LocalDateTime.now().minusDays(11)); + element.setArchiveDate(LocalDateTime.now().minusDays(10)); element.setValue("bonjour"); database.put(element); diff --git a/test/fr/devinsy/sikevadb/sql/SQLSikevaDBTest.java b/test/fr/devinsy/sikevadb/sql/SQLSikevaDBTest.java index 171869b..ee42ecc 100644 --- a/test/fr/devinsy/sikevadb/sql/SQLSikevaDBTest.java +++ b/test/fr/devinsy/sikevadb/sql/SQLSikevaDBTest.java @@ -18,12 +18,13 @@ */ package fr.devinsy.sikevadb.sql; +import java.time.LocalDateTime; + import org.apache.commons.codec.binary.Base64; import org.apache.commons.lang3.RandomStringUtils; import org.apache.log4j.BasicConfigurator; import org.apache.log4j.Level; import org.apache.log4j.Logger; -import org.joda.time.DateTime; import org.junit.AfterClass; import org.junit.Assert; import org.junit.BeforeClass; @@ -32,7 +33,7 @@ import org.junit.Test; import fr.devinsy.sikevadb.core.Element; import fr.devinsy.sikevadb.core.Elements; import fr.devinsy.sikevadb.core.SikevaDBException; -import fr.devinsy.util.strings.StringList; +import fr.devinsy.strings.StringList; /** * The Class SQLSikevaDBTest. @@ -61,9 +62,9 @@ public class SQLSikevaDBTest element.setSubkey(null); element.setSize(10); element.setDigest("qsdkfqskjf"); - element.setCreationDate(DateTime.now().minusDays(11)); - element.setEditionDate(DateTime.now().minusDays(11)); - element.setArchiveDate(DateTime.now().minusDays(10)); + element.setCreationDate(LocalDateTime.now().minusDays(11)); + element.setEditionDate(LocalDateTime.now().minusDays(11)); + element.setArchiveDate(LocalDateTime.now().minusDays(10)); element.setValue("bonjour"); database.put(element); @@ -97,9 +98,9 @@ public class SQLSikevaDBTest element.setSubkey(null); element.setSize(10); element.setDigest("qsdkfqskjf"); - element.setCreationDate(DateTime.now()); - element.setEditionDate(DateTime.now()); - element.setArchiveDate(DateTime.now().minusDays(10)); + element.setCreationDate(LocalDateTime.now()); + element.setEditionDate(LocalDateTime.now()); + element.setArchiveDate(LocalDateTime.now().minusDays(10)); element.setValue("bonjour"); database.put(element); @@ -379,9 +380,9 @@ public class SQLSikevaDBTest element.setSubkey(null); element.setSize(10); element.setDigest("qsdkfqskjf"); - element.setCreationDate(DateTime.now().minusDays(11)); - element.setEditionDate(DateTime.now().minusDays(11)); - element.setArchiveDate(DateTime.now().minusDays(10)); + element.setCreationDate(LocalDateTime.now().minusDays(11)); + element.setEditionDate(LocalDateTime.now().minusDays(11)); + element.setArchiveDate(LocalDateTime.now().minusDays(10)); element.setValue("bonjour"); database.put(element); @@ -412,9 +413,9 @@ public class SQLSikevaDBTest element.setSubkey(null); element.setSize(10); element.setDigest("qsdkfqskjf"); - element.setCreationDate(DateTime.now().minusDays(11)); - element.setEditionDate(DateTime.now().minusDays(11)); - element.setArchiveDate(DateTime.now().minusDays(10)); + element.setCreationDate(LocalDateTime.now().minusDays(11)); + element.setEditionDate(LocalDateTime.now().minusDays(11)); + element.setArchiveDate(LocalDateTime.now().minusDays(10)); element.setValue("bonjour"); database.put(element); @@ -446,9 +447,9 @@ public class SQLSikevaDBTest element.setSubkey(null); element.setSize(10); element.setDigest("qsdkfqskjf"); - element.setCreationDate(DateTime.now().minusDays(11)); - element.setEditionDate(DateTime.now().minusDays(11)); - element.setArchiveDate(DateTime.now().minusDays(10)); + element.setCreationDate(LocalDateTime.now().minusDays(11)); + element.setEditionDate(LocalDateTime.now().minusDays(11)); + element.setArchiveDate(LocalDateTime.now().minusDays(10)); element.setValue("bonjour"); database.put(element); @@ -461,9 +462,9 @@ public class SQLSikevaDBTest element.setSubkey(null); element.setSize(10); element.setDigest("qsdkfqskjf"); - element.setCreationDate(DateTime.now().minusDays(11)); - element.setEditionDate(DateTime.now().minusDays(11)); - element.setArchiveDate(DateTime.now().minusDays(10)); + element.setCreationDate(LocalDateTime.now().minusDays(11)); + element.setEditionDate(LocalDateTime.now().minusDays(11)); + element.setArchiveDate(LocalDateTime.now().minusDays(10)); element.setValue("bonjour"); database.put(element);