removing individuals from search index when they are inferred to be a prohibited type. NIHVIVO-824

This commit is contained in:
bdc34 2010-07-15 17:59:54 +00:00
parent 2fc49b4ac8
commit 5d87f1b995

View file

@ -16,7 +16,6 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import edu.cornell.mannlib.vitro.webapp.beans.Individual; import edu.cornell.mannlib.vitro.webapp.beans.Individual;
import edu.cornell.mannlib.vitro.webapp.beans.IndividualImpl;
import edu.cornell.mannlib.vitro.webapp.beans.VClass; import edu.cornell.mannlib.vitro.webapp.beans.VClass;
import edu.cornell.mannlib.vitro.webapp.dao.VClassDao; import edu.cornell.mannlib.vitro.webapp.dao.VClassDao;
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary; import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
@ -68,10 +67,10 @@ public class IndexBuilder {
public IndexBuilder(ServletContext context, public IndexBuilder(ServletContext context,
IndexerIface indexer, IndexerIface indexer,
List /*ObjectSourceIface*/ sources ){ List /*ObjectSourceIface*/ sources){
this.indexer = indexer; this.indexer = indexer;
this.sourceList = sources; this.sourceList = sources;
this.context = context; this.context = context;
this.changedUris = new HashSet<String>(); this.changedUris = new HashSet<String>();
this.indexingThread = new IndexBuilderThread(this); this.indexingThread = new IndexBuilderThread(this);
@ -341,14 +340,18 @@ public class IndexBuilder {
boolean prohibitedClass = false; boolean prohibitedClass = false;
if( classesProhibitedFromSearch != null ){ if( classesProhibitedFromSearch != null ){
for( VClass vclass : ind.getVClasses() ){ for( VClass vclass : ind.getVClasses() ){
if( classesProhibitedFromSearch.isClassProhibited(vclass.getURI()) ){ if( classesProhibitedFromSearch.isClassProhibited(vclass.getURI()) ){
prohibitedClass = true; prohibitedClass = true;
log.debug("not indexing " + ind.getURI() + " because class " + vclass.getURI() + " is on prohibited list.");
break; break;
} }
} }
} }
if( !prohibitedClass ) if( !prohibitedClass )
indexer.index(ind, newDoc); indexer.index(ind, newDoc);
else
indexer.removeFromIndex(ind);
}catch(Throwable ex){ }catch(Throwable ex){
log.debug("IndexBuilder.indexItem() Error indexing " log.debug("IndexBuilder.indexItem() Error indexing "
+ ind + "\n" +ex); + ind + "\n" +ex);