Skip to content
Snippets Groups Projects
Commit f0ec3417 authored by Rick Herrick's avatar Rick Herrick
Browse files

XNAT-4516 Change to determine if view update is required or not.

parent 8f2bbdc8
No related branches found
No related tags found
No related merge requests found
...@@ -2,8 +2,11 @@ package org.nrg.xnat.initialization.tasks; ...@@ -2,8 +2,11 @@ package org.nrg.xnat.initialization.tasks;
import org.nrg.framework.orm.DatabaseHelper; import org.nrg.framework.orm.DatabaseHelper;
import org.nrg.xdat.display.DisplayManager; import org.nrg.xdat.display.DisplayManager;
import org.nrg.xdat.servlet.XDATServlet;
import org.nrg.xft.db.PoolDBUtils; import org.nrg.xft.db.PoolDBUtils;
import org.nrg.xft.exception.DBPoolException; import org.nrg.xft.exception.DBPoolException;
import org.nrg.xft.exception.XFTInitException;
import org.nrg.xft.schema.XFTManager;
import org.nrg.xnat.services.XnatAppInfo; import org.nrg.xnat.services.XnatAppInfo;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -30,14 +33,20 @@ public class CreateOrUpdateDatabaseViews extends AbstractInitializingTask { ...@@ -30,14 +33,20 @@ public class CreateOrUpdateDatabaseViews extends AbstractInitializingTask {
protected void callImpl() throws InitializingTaskException { protected void callImpl() throws InitializingTaskException {
if (_appInfo.isPrimaryNode()) { if (_appInfo.isPrimaryNode()) {
_log.info("This service is the primary XNAT node, checking whether database updates are required."); _log.info("This service is the primary XNAT node, checking whether database updates are required.");
final Boolean shouldUpdateViews = XDATServlet.shouldUpdateViews();
try { try {
if (!_helper.tableExists("xdat_search", "xs_item_access")) { if (!_helper.tableExists("xdat_search", "xs_item_access") || !XFTManager.isInitialized() || shouldUpdateViews == null) {
throw new InitializingTaskException(InitializingTaskException.Level.SingleNotice, "The table 'xdat_search.xs_item_access' does not yet exist. Deferring execution."); throw new InitializingTaskException(InitializingTaskException.Level.SingleNotice, "The table 'xdat_search.xs_item_access' does not yet exist. Deferring execution.");
} }
} catch (SQLException e) { } catch (SQLException e) {
throw new InitializingTaskException(InitializingTaskException.Level.Error, "An error occurred trying to access the database to check for the table 'xdat_search.xs_item_access'.", e); throw new InitializingTaskException(InitializingTaskException.Level.Error, "An error occurred trying to access the database to check for the table 'xdat_search.xs_item_access'.", e);
} }
if (!shouldUpdateViews) {
_log.info("XDATServlet indicates that views do not need to be updated, terminating task.");
}
final PoolDBUtils.Transaction transaction = PoolDBUtils.getTransaction(); final PoolDBUtils.Transaction transaction = PoolDBUtils.getTransaction();
try { try {
try { try {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment