Added CrawlCache expired management feature.
This commit is contained in:
parent
cfec6aab7c
commit
d024d02409
7 changed files with 51 additions and 1 deletions
|
@ -36,5 +36,10 @@
|
|||
<attribute name="owner.project.facets" value="jst.utility"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" path=".apt_generated">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -2,3 +2,4 @@
|
|||
/build
|
||||
/dist
|
||||
*~
|
||||
/.apt_generated/
|
||||
|
|
5
.settings/org.eclipse.jdt.apt.core.prefs
Normal file
5
.settings/org.eclipse.jdt.apt.core.prefs
Normal file
|
@ -0,0 +1,5 @@
|
|||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.apt.aptEnabled=true
|
||||
org.eclipse.jdt.apt.genSrcDir=.apt_generated
|
||||
org.eclipse.jdt.apt.genTestSrcDir=.apt_generated_tests
|
||||
org.eclipse.jdt.apt.reconcileEnabled=true
|
|
@ -21,6 +21,7 @@ org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
|||
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
|
||||
org.eclipse.jdt.core.compiler.processAnnotations=enabled
|
||||
org.eclipse.jdt.core.compiler.release=enabled
|
||||
org.eclipse.jdt.core.compiler.source=17
|
||||
org.eclipse.jdt.core.formatter.align_assignment_statements_on_columns=false
|
||||
|
|
|
@ -152,6 +152,7 @@ org.eclipse.jdt.ui.exception.name=exception
|
|||
org.eclipse.jdt.ui.gettersetter.use.is=true
|
||||
org.eclipse.jdt.ui.keywordthis=false
|
||||
org.eclipse.jdt.ui.overrideannotation=true
|
||||
org.eclipse.jdt.ui.text.custom_code_templates=
|
||||
sp_cleanup.add_all=false
|
||||
sp_cleanup.add_default_serial_version_id=true
|
||||
sp_cleanup.add_generated_serial_version_id=false
|
||||
|
|
|
@ -1,6 +1,12 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
|
||||
<wb-module deploy-name="SikevaDB">
|
||||
|
||||
<wb-module deploy-name="StatooInfos">
|
||||
|
||||
<wb-resource deploy-path="/" source-path="/src"/>
|
||||
|
||||
<wb-resource deploy-path="/" source-path="/test"/>
|
||||
<wb-resource deploy-path="/" source-path="/.apt_generated"/>
|
||||
|
||||
</wb-module>
|
||||
|
||||
</project-modules>
|
||||
|
|
|
@ -21,6 +21,8 @@ package fr.devinsy.statoolinfos.core;
|
|||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.OffsetDateTime;
|
||||
|
||||
import fr.devinsy.statoolinfos.crawl.CrawlCache;
|
||||
import fr.devinsy.statoolinfos.uptime.UptimeJournal;
|
||||
|
@ -32,6 +34,7 @@ public class StatoolInfosContext
|
|||
{
|
||||
private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(StatoolInfosContext.class);
|
||||
|
||||
private LocalDateTime initDateTime;
|
||||
private Configuration configuration;
|
||||
private Federation federation;
|
||||
private Categories categories;
|
||||
|
@ -81,6 +84,7 @@ public class StatoolInfosContext
|
|||
this.categories = Factory.loadCategories(categoriesURL, this.federation);
|
||||
}
|
||||
this.uptimeJournal = this.cache.restoreUptimeJournal();
|
||||
this.initDateTime = LocalDateTime.now();
|
||||
System.out.println("Loaded configuration context in " + (System.currentTimeMillis() - startTime) + " ms.");
|
||||
}
|
||||
else
|
||||
|
@ -158,4 +162,31 @@ public class StatoolInfosContext
|
|||
{
|
||||
return this.uptimeJournal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is expired.
|
||||
*
|
||||
* @return true, if is expired
|
||||
*/
|
||||
public boolean isExpired()
|
||||
{
|
||||
boolean result;
|
||||
|
||||
getCache();
|
||||
|
||||
long cacheTime = this.getCache().getDirectory().lastModified();
|
||||
LocalDateTime cacheDateTime = LocalDateTime.ofEpochSecond(cacheTime / 1000, 0, OffsetDateTime.now().getOffset());
|
||||
|
||||
if (cacheDateTime.isAfter(this.initDateTime))
|
||||
{
|
||||
result = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = false;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue