/**
* run the walker on the store
*/
public void run() {
SimpleFeatureIterator it = null;
try {
configHandler.indexingPreamble();
startTransaction();
// start looking into catalog
final GranuleCatalog catalog = configHandler.getCatalog();
for (String typeName : catalog.getTypeNames()) {
// how many rows for this feature type?
final Query query = new Query(typeName);
int numFiles = catalog.getGranulesCount(query);
if (numFiles <= 0) {
// empty table?
LOGGER.log(Level.FINE, "No rows in the typeName: " + typeName);
continue;
}
setNumFiles(numFiles);
// cool, now let's walk over the features
final SimpleFeatureCollection coll = catalog.getGranules(query);
// create an iterator
it = coll.features();
// TODO setup index name
while (it.hasNext()) {
// get next element
final SimpleFeature feature = it.next();
// String
// locationAttrName=config.getCatalogConfigurationBean().getLocationAttribute();
String locationAttrName = configHandler.getRunConfiguration().getParameter(
Prop.LOCATION_ATTRIBUTE);
Object locationAttrObj = feature.getAttribute(locationAttrName);
File file = null;
if (locationAttrObj instanceof String) {
final String path = (String) locationAttrObj;
if (Boolean.getBoolean(configHandler.getRunConfiguration().getParameter(
Prop.ABSOLUTE_PATH))) {
// absolute files
file = new File(path);
// check this is _really_ absolute
if (!checkFile(file)) {
file = null;
}
}
if (file == null) {
// relative files
file = new File(configHandler.getRunConfiguration().getParameter(
Prop.ROOT_MOSAIC_DIR), path);
// check this is _really_ relative
if (!(file.exists() && file.canRead() && file.isFile())) {
// let's try for absolute, despite what the config says
// absolute files
file = new File(path);
// check this is _really_ absolute
if (!(checkFile(file))) {
file = null;
}
}
}
// final check
if (file == null) {
// SKIP and log
// empty table?
super.skipFile(path);
continue;
}
} else if (locationAttrObj instanceof File) {
file = (File) locationAttrObj;
} else {
eventHandler.fireException(new IOException(
"Location attribute type not recognized for column name: "
+ locationAttrName));
stop();
break;
}
// process this file
handleFile(file);
}
} // next table
// close transaction
// did we cancel?
if (getStop()) {
rollbackTransaction();
} else {
commitTransaction();
}
} catch (Exception e) {
LOGGER.log(Level.WARNING, "Failure occurred while collecting the granules", e);
try {
rollbackTransaction();
} catch (IOException e1) {
throw new IllegalStateException(e1);
}
} finally {
// close read iterator
if (it != null) {
try {
it.close();
} catch (Exception e) {
LOGGER.log(Level.FINE, e.getLocalizedMessage(), e);
}
}
// close transaction