mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-16 09:47:42 +00:00
categorizer initialize on demand
This commit is contained in:
parent
288f459fcf
commit
c99491a8e7
@ -128,18 +128,33 @@ public class DefaultDomainCategorizer implements DomainCategorizer {
|
|||||||
private Map<String, String> mapping = null;
|
private Map<String, String> mapping = null;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initialize() throws DomainCategorizerException {
|
public synchronized void initialize() throws DomainCategorizerException {
|
||||||
if (this.mapping == null) {
|
if (isInitialized()) {
|
||||||
try {
|
return;
|
||||||
this.mapping = loadMapping();
|
}
|
||||||
} catch (IOException ex) {
|
|
||||||
throw new DomainCategorizerException("Unable to load domain type csv for domain category analysis", ex);
|
try {
|
||||||
}
|
this.mapping = loadMapping();
|
||||||
|
} catch (IOException ex) {
|
||||||
|
throw new DomainCategorizerException("Unable to load domain type csv for domain category analysis", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if this categorizer is properly initialized.
|
||||||
|
*
|
||||||
|
* @return True if this categorizer is properly initialized.
|
||||||
|
*/
|
||||||
|
private synchronized boolean isInitialized() {
|
||||||
|
return this.mapping != null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DomainCategory getCategory(String domain, String host) throws DomainCategorizerException {
|
public synchronized DomainCategory getCategory(String domain, String host) throws DomainCategorizerException {
|
||||||
|
if (!isInitialized()) {
|
||||||
|
initialize();
|
||||||
|
}
|
||||||
|
|
||||||
// use host; use domain as fallback if no host provided
|
// use host; use domain as fallback if no host provided
|
||||||
String hostToUse = StringUtils.isBlank(host) ? domain : host;
|
String hostToUse = StringUtils.isBlank(host) ? domain : host;
|
||||||
|
|
||||||
@ -162,7 +177,7 @@ public class DefaultDomainCategorizer implements DomainCategorizer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void close() throws Exception {
|
public synchronized void close() throws Exception {
|
||||||
// clear out the mapping to release resources
|
// clear out the mapping to release resources
|
||||||
mapping = null;
|
mapping = null;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user