[opencms-dev] Concept Problems of Static Export
M Butcher
mbutcher at grcomputing.net
Wed Nov 26 07:11:01 CET 2003
jose.mato at ieuskadi.com wrote:
> Well, I've been investigating in how to do the indexes directly from the
> Vfs. Can you explain how can I do that?
Sure.
The Lucene module always indexes from the VFS. The configuration in the
registry.xml file deals with VFS paths for all but the location of the
actual index files, which ought to be stored outside of the DB, because
it is optimized for file system accesses.
If you are interested in looking at the code, it's available at the same
place that the module is. The build.xml file includes a 'doc' target for
building the Javadocs, too.
Essentially, once you get a handle on a CmsObject, you can work within
the OpenCms VFS. The Javadocs explain the methods in detail.
Here's an example piece of code that deals with directories in the VFS:
// cmso is a CmsObject, dir is a string with a dir name
Vector folders = cmso.getSubFolders(dir);
CmsFolder mfolder;
Enumeration e = folders.elements();
// recurse with subdirs
while (e.hasMoreElements()) {
mfolder = (CmsFolder)e.nextElement();
processDir(mfolder.getAbsolutePath(), traverseDir, writer);
}
This snippet gets a Vector containing a list of subfolders, processing
each as it goes.
The above is taken from the IndexManager class of the search module.
Anyway, all of this is to illustrate that this interaction with the VFS
does not follow the pattern of normal Java FS access. It uses a
well-abstracted API.
The Lucene module _only_ uses VFS access (it does not really do any FS
access). IndexManager contains lots of code for that sort of thing, so
if you are thinking of implementing some code that works on the VFS,
that may be a good place to start.
Matt
More information about the opencms-dev
mailing list