From f0ec3417877d3285dc2dd4b168f4e611524cabea Mon Sep 17 00:00:00 2001 From: Rick Herrick <jrherrick@wustl.edu> Date: Fri, 16 Sep 2016 17:38:06 -0500 Subject: [PATCH] XNAT-4516 Change to determine if view update is required or not. --- .../tasks/CreateOrUpdateDatabaseViews.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/nrg/xnat/initialization/tasks/CreateOrUpdateDatabaseViews.java b/src/main/java/org/nrg/xnat/initialization/tasks/CreateOrUpdateDatabaseViews.java index caafe899..8d0b5be1 100644 --- a/src/main/java/org/nrg/xnat/initialization/tasks/CreateOrUpdateDatabaseViews.java +++ b/src/main/java/org/nrg/xnat/initialization/tasks/CreateOrUpdateDatabaseViews.java @@ -2,8 +2,11 @@ package org.nrg.xnat.initialization.tasks; import org.nrg.framework.orm.DatabaseHelper; import org.nrg.xdat.display.DisplayManager; +import org.nrg.xdat.servlet.XDATServlet; import org.nrg.xft.db.PoolDBUtils; 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.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -30,14 +33,20 @@ public class CreateOrUpdateDatabaseViews extends AbstractInitializingTask { protected void callImpl() throws InitializingTaskException { if (_appInfo.isPrimaryNode()) { _log.info("This service is the primary XNAT node, checking whether database updates are required."); + final Boolean shouldUpdateViews = XDATServlet.shouldUpdateViews(); + 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."); } } 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); } + if (!shouldUpdateViews) { + _log.info("XDATServlet indicates that views do not need to be updated, terminating task."); + } + final PoolDBUtils.Transaction transaction = PoolDBUtils.getTransaction(); try { try { -- GitLab