From 75066bb430b08f5201e3d9fb9a53f59daa8fcd76 Mon Sep 17 00:00:00 2001 From: Richard Millet Date: Fri, 16 Dec 2011 07:54:24 +0000 Subject: [PATCH] CSPACE-4740: RefNameServiceUtils method that updates refnames (updateAuthorityRefDocs) now throws exceptions if underlying DB calls fail. --- .../authentication/realm/db/CSpaceDbRealm.java | 5 ++++- .../vocabulary/nuxeo/AuthorityItemDocumentModelHandler.java | 4 +++- .../services/common/vocabulary/RefNameServiceUtils.java | 5 +++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/services/authentication/service/src/main/java/org/collectionspace/authentication/realm/db/CSpaceDbRealm.java b/services/authentication/service/src/main/java/org/collectionspace/authentication/realm/db/CSpaceDbRealm.java index 887017f5f..759de6a2b 100644 --- a/services/authentication/service/src/main/java/org/collectionspace/authentication/realm/db/CSpaceDbRealm.java +++ b/services/authentication/service/src/main/java/org/collectionspace/authentication/realm/db/CSpaceDbRealm.java @@ -150,7 +150,10 @@ public class CSpaceDbRealm implements CSpaceRealm { password = rs.getString(1); } catch (SQLException ex) { - LoginException le = new LoginException("Query failed"); + if (logger.isTraceEnabled() == true) { + logger.error("Could not open database to read AuthN tables.", ex); + } + LoginException le = new LoginException("Authentication query failed: " + ex.getLocalizedMessage()); le.initCause(ex); throw le; } catch (Exception ex) { diff --git a/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityItemDocumentModelHandler.java b/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityItemDocumentModelHandler.java index a4365e1e7..0daa61835 100644 --- a/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityItemDocumentModelHandler.java +++ b/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityItemDocumentModelHandler.java @@ -62,6 +62,7 @@ import org.nuxeo.ecm.core.api.DocumentModel; import org.nuxeo.ecm.core.api.model.PropertyException; import org.nuxeo.ecm.core.api.model.PropertyNotFoundException; import org.nuxeo.ecm.core.api.repository.RepositoryInstance; +import org.nuxeo.runtime.transaction.TransactionHelper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -268,8 +269,9 @@ public abstract class AuthorityItemDocumentModelHandler /** * Checks to see if the refName has changed, and if so, * uses utilities to find all references and update them. + * @throws Exception */ - protected void handleItemRefNameReferenceUpdate() { + protected void handleItemRefNameReferenceUpdate() throws Exception { if (newRefNameOnUpdate != null && oldRefNameOnUpdate != null) { // We have work to do. if (logger.isDebugEnabled()) { diff --git a/services/common/src/main/java/org/collectionspace/services/common/vocabulary/RefNameServiceUtils.java b/services/common/src/main/java/org/collectionspace/services/common/vocabulary/RefNameServiceUtils.java index ab2efb03c..b0272b0a8 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/vocabulary/RefNameServiceUtils.java +++ b/services/common/src/main/java/org/collectionspace/services/common/vocabulary/RefNameServiceUtils.java @@ -267,7 +267,7 @@ public class RefNameServiceUtils { RepositoryInstance repoSession, String oldRefName, String newRefName, - String refPropName ) { + String refPropName ) throws Exception { Map queriedServiceBindings = new HashMap(); Map> authRefFieldsByService = new HashMap>(); int nRefsFound = 0; @@ -300,9 +300,10 @@ public class RefNameServiceUtils { } pageNumProcessed++; } - } catch(Exception e) { + } catch (Exception e) { logger.error("Internal error updating the AuthorityRefDocs: " + e.getLocalizedMessage()); logger.debug(Tools.errorToString(e, true)); + throw e; } logger.debug("updateAuthorityRefDocs replaced a total of: "+nRefsFound); return nRefsFound; -- 2.47.3