mirror of
https://github.com/sismics/docs.git
synced 2024-11-22 14:07:55 +01:00
indexing in transactional context
This commit is contained in:
parent
c9ba182a2e
commit
95ce4f0dc0
@ -27,7 +27,6 @@ import java.io.OutputStream;
|
|||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Listener on file processing.
|
* Listener on file processing.
|
||||||
@ -51,10 +50,13 @@ public class FileProcessingAsyncListener {
|
|||||||
log.info("File created event: " + event.toString());
|
log.info("File created event: " + event.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
processFile(event);
|
TransactionUtil.handle(() -> {
|
||||||
|
// Generate thumbnail, extract content
|
||||||
|
processFile(event);
|
||||||
|
|
||||||
// Update index
|
// Update index
|
||||||
TransactionUtil.handle(() -> AppContext.getInstance().getIndexingHandler().createFile(event.getFile()));
|
AppContext.getInstance().getIndexingHandler().createFile(event.getFile());
|
||||||
|
});
|
||||||
|
|
||||||
FileUtil.endProcessingFile(event.getFile().getId());
|
FileUtil.endProcessingFile(event.getFile().getId());
|
||||||
}
|
}
|
||||||
@ -133,9 +135,9 @@ public class FileProcessingAsyncListener {
|
|||||||
|
|
||||||
// Extract text content from the file
|
// Extract text content from the file
|
||||||
long startTime = System.currentTimeMillis();
|
long startTime = System.currentTimeMillis();
|
||||||
final AtomicReference<String> content = new AtomicReference<>();
|
String content = null;
|
||||||
try {
|
try {
|
||||||
content.set(formatHandler.extractContent(event.getLanguage(), event.getUnencryptedFile()));
|
content = formatHandler.extractContent(event.getLanguage(), event.getUnencryptedFile());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("Error extracting content from: " + event.getFile(), e);
|
log.error("Error extracting content from: " + event.getFile(), e);
|
||||||
}
|
}
|
||||||
@ -148,7 +150,7 @@ public class FileProcessingAsyncListener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
file.setContent(content.get());
|
file.setContent(content);
|
||||||
fileDao.update(file);
|
fileDao.update(file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user