
Bulk Processing
Table of Contents [-]
Legacy #
This article is for legacy Liferay installs. For more recent information, see Document Library Portlet.
Bulk/Batch Processing#
Bulk or batch processing is an important feature in system maintenance, backup, and migrations. It's also helpful from an upgrade perspective. This article is a work in progress attempt at addressing how developers and administrator may leverage Liferay services for bulk/batch processing.
Document Library#
The Problem#
Bulk loading the document library is possible via the document library web services interfaces. However, currently, the content repository hooks automatically perform indexing for each file operation. For instance, if you add a file, the Lucene index will be updated. Re-indexing for each file over 100 files consumes unnecessary time and energy.
To solve this problem, we must:
- Stop the repository hook from automatically indexing on each file operation
- Trigger the Indexer to reindex the entire repository.
The Solution#
The solution is to replace the com.liferay.documentlibrary.util.Hook with an instance that does not invoke the Indexer when performing file operations. You can do this by:
- Create a new class (CustomHook) and copy the contents of the Hook implementation you are looking to replace (e.g. JCRHook, FileSystemHook, S3Hook, etc)
- Add a new property for portal.properties. For instance, dl.hook.impl.autoIndex=true. You can put this into portal-ext.properties in the WEB-INF/classes.
- Add a new boolean attribute to CustomHook and set the value on construction:
private static final String _INDEX_SWITCH_PROP = "dl.hook.impl.autoIndex"; private final boolean _indexSwitch; public CustomHook() { _indexSwitch = Boolean.parseBoolean(PropsUtil.get(_INDEX_SWITCH_PROP)); } }}}
- Modify the CustomHook such that each time the Indexer is called, we check the variable _indexSwitch.
- Create a jar file for the CustomHook and place it into WEB-INF/lib
This solution will allow you to customize the behavior without having to rebuild the entire portal distribution. A more permanent solution has been proposed and submitted by Rich Sezov (http://support.liferay.com/browse/LEP-3757). This solution will be incorporated into a future release of the portal.