Collection toIndex = (Collection) nodeEntry.getValue();
Collection toIndex2 = new ArrayList();
for (Iterator fieldsIt = toIndex.iterator(); fieldsIt.hasNext(); ){
LiusField lf = (LiusField) fieldsIt.next();
//Le champs courrant : requ�te sur les enfants du <node> s�lectionn� plus haut
String fieldXPathQuery = "/jcr:root" + JcrUtil.xmlEncodePath(selectNode) + "/" + lf.getXpathSelect();
log.info(fieldXPathQuery);
Query fieldQuery = qm.createQuery(fieldXPathQuery, Query.XPATH);
QueryResult fieldQueryResults = fieldQuery.execute();
boolean found = false;
//Nodes
for (NodeIterator nodesToIndexIterator = fieldQueryResults.getNodes(); nodesToIndexIterator.hasNext(); ) {
Node nodeToIndex = nodesToIndexIterator.nextNode();
if (nodeToIndex.getPrimaryNodeType().getName().equals("nt:file")) {
Node jcrContent = nodeToIndex.getNode("jcr:content");
Property prop = jcrContent.getProperty("jcr:mimeType");
String mimeType = prop.getString();
Property content = jcrContent.getProperty("jcr:data");
InputStream is = content.getStream();
Indexer indexer = IndexerFactory.getIndexer(is, mimeType, getLiusConfig());
if (indexer == null) {
System.out.println(prop.getString());
System.out.println(nodeToIndex.getName());
}
else{
lf.setValue(indexer.getContent());
LiusField newLiusField = new LiusField();
BeanUtils.copyProperties(newLiusField, lf);
toIndex2.add(newLiusField);
found = true;
}
}
}
if (!found) {
//Rows/Properties
for (RowIterator propertiesToIndexIterator = fieldQueryResults.getRows(); propertiesToIndexIterator.hasNext(); ) {
Row row = propertiesToIndexIterator.nextRow();
//FIXME Premi�re valeur seulement ??
String[] columnNames = fieldQueryResults.getColumnNames();
for (int i = 0; i < columnNames.length; i++){
if ((columnNames[i].equals("jcr:path") && columnNames.length != 2) || columnNames[i].equals("jcr:score")) {
continue;
}
Value currentVal = row.getValue(columnNames[i]);
if (currentVal != null) {
lf.setValue(currentVal.getString());
} else {
lf.setValue("");
}
LiusField newLiusField = new LiusField();
BeanUtils.copyProperties(newLiusField, lf);
toIndex2.add(newLiusField);
}
}