{
File indexDirectory = new File(handler.getContext().getIndexDirectory());
try
{
IndexRecovery indexRecovery = handler.getContext().getIndexRecovery();
// check if index not ready
if (!indexRecovery.checkIndexReady())
{
return false;
}
indexRecovery.setIndexOffline();
for (String filePath : indexRecovery.getIndexList())
{
File indexFile = new File(indexDirectory, filePath);
if (!PrivilegedFileHelper.exists(indexFile.getParentFile()))
{
PrivilegedFileHelper.mkdirs(indexFile.getParentFile());
}
// transfer file
InputStream in = indexRecovery.getIndexFile(filePath);
OutputStream out = PrivilegedFileHelper.fileOutputStream(indexFile);
try
{
DirectoryHelper.transfer(in, out);
}
finally
{
DirectoryHelper.safeClose(in);
DirectoryHelper.safeClose(out);
}
indexRecovery.setIndexOnline();
}
return true;
}
catch (RepositoryException e)