mirror of
https://github.com/internetarchive/heritrix3.git
synced 2026-09-17 03:05:46 +00:00
Merge pull request #609 from internetarchive/remove-joda-time
Remove joda-time
This commit is contained in:
@@ -23,6 +23,8 @@ import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.time.ZoneOffset;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
@@ -50,10 +52,6 @@ import org.archive.uid.RecordIDGenerator;
|
||||
import org.archive.uid.UUIDGenerator;
|
||||
import org.archive.util.FileUtils;
|
||||
import org.archive.util.anvl.ANVLRecord;
|
||||
import org.joda.time.DateTimeZone;
|
||||
import org.joda.time.format.DateTimeFormat;
|
||||
import org.joda.time.format.ISODateTimeFormat;
|
||||
|
||||
|
||||
/**
|
||||
* Convert ARCs to (sortof) WARCs.
|
||||
@@ -61,6 +59,8 @@ import org.joda.time.format.ISODateTimeFormat;
|
||||
* @version $Date$ $Revision$
|
||||
*/
|
||||
public class Arc2Warc {
|
||||
private static final DateTimeFormatter ARC_DATE_FORMAT = DateTimeFormatter.ofPattern("yyyyMMddHHmmss")
|
||||
.withZone(ZoneOffset.UTC);
|
||||
protected RecordIDGenerator generator = new UUIDGenerator();
|
||||
|
||||
private static void usage(HelpFormatter formatter, Options options,
|
||||
@@ -156,10 +156,8 @@ public class Arc2Warc {
|
||||
|
||||
// convert ARC date to WARC-Date format
|
||||
String arcDateString = r.getHeader().getDate();
|
||||
String warcDateString = DateTimeFormat.forPattern("yyyyMMddHHmmss")
|
||||
.withZone(DateTimeZone.UTC)
|
||||
.parseDateTime(arcDateString)
|
||||
.toString(ISODateTimeFormat.dateTimeNoMillis());
|
||||
|
||||
String warcDateString = DateTimeFormatter.ISO_DATE_TIME.format(ARC_DATE_FORMAT.parse(arcDateString));
|
||||
recordInfo.setCreate14DigitDate(warcDateString);
|
||||
|
||||
ANVLRecord ar = new ANVLRecord();
|
||||
|
||||
@@ -70,11 +70,6 @@
|
||||
<artifactId>org.restlet.ext.crypto</artifactId>
|
||||
<version>2.4.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>joda-time</groupId>
|
||||
<artifactId>joda-time</artifactId>
|
||||
<version>1.6</version>
|
||||
</dependency>
|
||||
<!-- jaxb is no longer included in jdk11+ -->
|
||||
<dependency>
|
||||
<groupId>javax.xml.bind</groupId>
|
||||
|
||||
@@ -29,6 +29,7 @@ import java.io.InputStreamReader;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.PrintWriter;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.Instant;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
@@ -68,7 +69,6 @@ import org.archive.spring.PathSharingContext;
|
||||
import org.archive.util.ArchiveUtils;
|
||||
import org.archive.util.ObjectIdentityCache;
|
||||
import org.archive.util.TextUtils;
|
||||
import org.joda.time.DateTime;
|
||||
import org.springframework.beans.BeanWrapperImpl;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.BeanCreationException;
|
||||
@@ -98,10 +98,10 @@ public class CrawlJob implements Comparable<CrawlJob>, ApplicationListener<Appli
|
||||
protected PathSharingContext ac;
|
||||
protected int launchCount;
|
||||
protected boolean isLaunchInfoPartial;
|
||||
protected DateTime lastLaunch;
|
||||
protected Instant lastLaunch;
|
||||
protected AlertThreadGroup alertThreadGroup;
|
||||
|
||||
protected DateTime xmlOkAt = new DateTime(0L);
|
||||
protected Instant xmlOkAt = Instant.ofEpochMilli(0);
|
||||
protected Logger jobLogger;
|
||||
|
||||
public CrawlJob(File cxml) {
|
||||
@@ -154,7 +154,7 @@ public class CrawlJob implements Comparable<CrawlJob>, ApplicationListener<Appli
|
||||
return jobLogger;
|
||||
}
|
||||
|
||||
public DateTime getLastLaunch() {
|
||||
public Instant getLastLaunch() {
|
||||
return lastLaunch;
|
||||
}
|
||||
public int getLaunchCount() {
|
||||
@@ -191,7 +191,7 @@ public class CrawlJob implements Comparable<CrawlJob>, ApplicationListener<Appli
|
||||
Matcher m = launchLine.matcher(line);
|
||||
if (m.matches()) {
|
||||
launchCount++;
|
||||
lastLaunch = new DateTime(m.group(1));
|
||||
lastLaunch = Instant.parse(m.group(1));
|
||||
}
|
||||
}
|
||||
jobLogReader.close();
|
||||
@@ -251,14 +251,14 @@ public class CrawlJob implements Comparable<CrawlJob>, ApplicationListener<Appli
|
||||
public void checkXML() {
|
||||
// TODO: suppress check if XML unchanged? job.log when XML changed?
|
||||
|
||||
DateTime testTime = new DateTime(getPrimaryConfig().lastModified());
|
||||
Instant testTime = Instant.ofEpochMilli(getPrimaryConfig().lastModified());
|
||||
Document doc = getDomDocument(getPrimaryConfig());
|
||||
// TODO: check for other minimal requirements, like
|
||||
// presence of a few key components (CrawlController etc.)?
|
||||
if(doc!=null) {
|
||||
xmlOkAt = testTime;
|
||||
} else {
|
||||
xmlOkAt = new DateTime(0L);
|
||||
xmlOkAt = Instant.ofEpochMilli(0);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -290,7 +290,7 @@ public class CrawlJob implements Comparable<CrawlJob>, ApplicationListener<Appli
|
||||
* @return true if the primary configuration file passed XML testing
|
||||
*/
|
||||
public boolean isXmlOk() {
|
||||
return xmlOkAt.getMillis() >= getPrimaryConfig().lastModified();
|
||||
return xmlOkAt.toEpochMilli() >= getPrimaryConfig().lastModified();
|
||||
}
|
||||
|
||||
|
||||
@@ -588,7 +588,7 @@ public class CrawlJob implements Comparable<CrawlJob>, ApplicationListener<Appli
|
||||
// all this stuff should happen even in case ac.close() bugs out
|
||||
ac = null;
|
||||
|
||||
xmlOkAt = new DateTime(0);
|
||||
xmlOkAt = Instant.ofEpochMilli(0);
|
||||
|
||||
if (currentLaunchJobLogHandler != null) {
|
||||
getJobLogger().removeHandler(currentLaunchJobLogHandler);
|
||||
@@ -615,7 +615,7 @@ public class CrawlJob implements Comparable<CrawlJob>, ApplicationListener<Appli
|
||||
public String format(LogRecord record) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb
|
||||
.append(new DateTime(record.getMillis()))
|
||||
.append(Instant.ofEpochMilli(record.getMillis()))
|
||||
.append(" ")
|
||||
.append(record.getLevel())
|
||||
.append(" ")
|
||||
|
||||
@@ -148,7 +148,7 @@ public class CrawlJobModel extends LinkedHashMap<String, Object> implements Seri
|
||||
}
|
||||
public String getLastLaunchTime(){
|
||||
long ago = System.currentTimeMillis()
|
||||
- crawlJob.getLastLaunch().getMillis();
|
||||
- crawlJob.getLastLaunch().toEpochMilli();
|
||||
return ArchiveUtils.formatMillisecondsToConventional(ago, 2);
|
||||
}
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user