use of org.xwiki.search.solr.internal.api.SolrIndexerException in project xwiki-platform by xwiki.
the class ObjectSolrReferenceResolver method getReferences.
@Override
public List<EntityReference> getReferences(EntityReference objectReference) throws SolrIndexerException {
List<EntityReference> result = new ArrayList<>();
// Object itself
result.add(objectReference);
// Object properties
DocumentReference documentReference = new DocumentReference(objectReference.getParent());
XWikiDocument document;
try {
document = getDocument(documentReference);
} catch (Exception e) {
throw new SolrIndexerException("Failed to get document for object [" + objectReference + "]", e);
}
BaseObject object = document.getXObject(objectReference);
if (object != null) {
for (Object field : object.getFieldList()) {
BaseProperty<ObjectPropertyReference> objectProperty = (BaseProperty<ObjectPropertyReference>) field;
ObjectPropertyReference objectPropertyReference = objectProperty.getReference();
try {
Iterables.addAll(result, this.objectPropertyResolverProvider.get().getReferences(objectPropertyReference));
} catch (Exception e) {
this.logger.error("Failed to resolve references for object property [" + objectPropertyReference + "]", e);
}
}
}
return result;
}
use of org.xwiki.search.solr.internal.api.SolrIndexerException in project xwiki-platform by xwiki.
the class SpaceSolrReferenceResolver method getReferences.
@Override
public List<EntityReference> getReferences(EntityReference spaceReference) throws SolrIndexerException {
List<EntityReference> result = new ArrayList<EntityReference>();
EntityReference wikiReference = spaceReference.extractReference(EntityType.WIKI);
String localSpaceReference = this.localEntityReferenceSerializer.serialize(spaceReference);
// Ignore the space reference because it is not indexable.
// Make sure the list of spaces is from the requested wiki
List<String> documentNames;
try {
documentNames = this.queryManager.getNamedQuery("getSpaceDocsName").setWiki(wikiReference.getName()).bindValue("space", localSpaceReference).execute();
} catch (QueryException e) {
throw new SolrIndexerException("Failed to query space [" + spaceReference + "] documents", e);
}
for (String documentName : documentNames) {
EntityReference documentReference = new EntityReference(documentName, EntityType.DOCUMENT, spaceReference);
try {
Iterables.addAll(result, this.documentResolverProvider.get().getReferences(documentReference));
} catch (Exception e) {
this.logger.error("Failed to resolve references for document [" + documentReference + "]", e);
}
}
return result;
}
Aggregations