Hi all, I've this function that retrive execute a lucene query and return a list of reference: public static List<Reference> searchLuceneFromTheRoot(String toSearch) {
List<Reference> toReturn = new ArrayList<Reference>();
RepositoryServiceSoapBindingStub repoService = WebServiceFactory.getRepositoryService();
String encodedString = ISO9075.encode(toSearch);
String queryPath = "PATH:\"/app:company_home//*\" ";
String queryTitlet = "+@cm\\:name:\"" + encodedString + "\"";
String statement = queryPath.concat(queryTitlet);
if (log.isDebugEnabled()) {
log.debug("searchLuceneFromTheRoot, statement [" + statement + "]");
}
Query query = new Query(Constants.QUERY_LANG_LUCENE, statement);
QueryResult results = null;
ResultSet resultSet = null;
NamedValue currentNamedValue;
String path;
String id;
try {
results = repoService.query(getStore(), query, false);
resultSet = results.getResultSet();
if (resultSet.getTotalRowCount() == 0) {
log.info("searchLuceneFromTheRoot, NON ho trovato nessun file con titolo [" + toSearch + "]");
} else {
log.info("searchLuceneFromTheRoot, ho trovato [" + resultSet.getTotalRowCount() + "] file con nome [" + toSearch + "]");
for (int i = 0; i < resultSet.getTotalRowCount(); i++) {
NamedValue[] namedValues = resultSet.getRows()[i].getColumns();
path = null;
id = null;
for (int y = 0; y < namedValues.length; y++) {
currentNamedValue = namedValues[y];
if (currentNamedValue.getName().equals(ContentModel.PROP_NODE_UUID.toString())) {
id = currentNamedValue.getValue();
if (log.isDebugEnabled()) {
log.debug("searchLuceneFromTheRoot, ID: " + id);
}
}
if (currentNamedValue.getName().equals("{http://www.alfresco.org/model/content/1.0}path")) {
path = rewritePathFromProp(currentNamedValue.getValue());
if (log.isDebugEnabled()) {
log.debug("searchLuceneFromTheRoot, PATH: " + path);
}
}
if (id != null && path != null) {
Reference toInsert = new Reference(getStore(), id, path);
toReturn.add(toInsert);
}
}
}
}
} catch (ContentFault e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (RepositoryFault e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return toReturn;
}Sometime this code works fine and sometime doesn't work because the query don't find anything although the file to search is inside Alfresco.PLEASE CAN YOU HELP ME?THANKS YOU