NIHVIVO-2979 Committing functionality to the trunk.

This commit is contained in:
deepakkoni 2011-07-22 16:52:48 +00:00
parent 1006b4316e
commit adba60a9de
3 changed files with 20 additions and 3 deletions

View file

@ -29,6 +29,7 @@ import edu.cornell.mannlib.vitro.webapp.dao.UserAccountsDao;
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory; import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
import edu.cornell.mannlib.vitro.webapp.dao.jena.LoginEvent; import edu.cornell.mannlib.vitro.webapp.dao.jena.LoginEvent;
import edu.cornell.mannlib.vitro.webapp.dao.jena.LogoutEvent; import edu.cornell.mannlib.vitro.webapp.dao.jena.LogoutEvent;
import edu.cornell.mannlib.vitro.webapp.search.indexing.IndexBuilder;
/** /**
* The "standard" implementation of Authenticator. * The "standard" implementation of Authenticator.
@ -136,8 +137,7 @@ public class BasicAuthenticator extends Authenticator {
if (IsRootUser.isRootUser(RequestIdentifiers if (IsRootUser.isRootUser(RequestIdentifiers
.getIdBundleForRequest(request))) { .getIdBundleForRequest(request))) {
// Insert method call here. IndexBuilder.checkIndexOnRootLogin(request); }
}
} }
/** /**

View file

@ -56,4 +56,6 @@ public interface IndexerIface {
* This may be called instead of endIndexing() * This may be called instead of endIndexing()
*/ */
public void abortIndexingAndCleanUp(); public void abortIndexingAndCleanUp();
public boolean isIndexEmpty();
} }

View file

@ -11,6 +11,8 @@ import java.util.LinkedList;
import java.util.List; import java.util.List;
import javax.servlet.ServletContext; import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
@ -195,7 +197,20 @@ public class IndexBuilder extends Thread {
} }
/* ******************** non-public methods ************************* */ public static void checkIndexOnRootLogin(HttpServletRequest req){
HttpSession session = req.getSession();
ServletContext context = session.getServletContext();
IndexBuilder indexBuilder = (IndexBuilder)context.getAttribute(IndexBuilder.class.getName());
log.debug("Checking if the index is empty");
if(indexBuilder.indexer.isIndexEmpty()){
log.info("Index is empty. Running a full index rebuild!");
indexBuilder.doIndexRebuild();
}
}
/* ******************** non-public methods ************************* */
private List<Statement> getAndEmptyChangedStatements(){ private List<Statement> getAndEmptyChangedStatements(){
List<Statement> localChangedStmt = null; List<Statement> localChangedStmt = null;