From e2bced236dd16865daaec23c8d3700cf43a2909f Mon Sep 17 00:00:00 2001 From: Richard Millet Date: Tue, 28 Apr 2020 17:49:25 -0700 Subject: [PATCH] DRYD-841, DRYD-855: Merging in UCB contributions to post-v6.0 master branch. --- .../nuxeo/MergeAuthorityItemsBatchJob.java | 4 +-- .../services/common/storage/JDBCTools.java | 35 ++++++++++++++----- .../nuxeo/ReportDocumentModelHandler.java | 25 +++++++++++++ 3 files changed, 53 insertions(+), 11 deletions(-) diff --git a/services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/MergeAuthorityItemsBatchJob.java b/services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/MergeAuthorityItemsBatchJob.java index 41dde283e..80b9b3040 100644 --- a/services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/MergeAuthorityItemsBatchJob.java +++ b/services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/MergeAuthorityItemsBatchJob.java @@ -372,7 +372,7 @@ public class MergeAuthorityItemsBatchJob extends AbstractBatchJob { NuxeoBasedResource resource = (NuxeoBasedResource) getResourceMap().get(serviceName); - resource.update(getResourceMap(), createUriInfo(), csid, payload); + resource.update(getServiceContext(), getResourceMap(), createUriInfo(), csid, payload); } else if (uriParts.length == 5) { String serviceName = uriParts[1]; @@ -383,7 +383,7 @@ public class MergeAuthorityItemsBatchJob extends AbstractBatchJob { if (items.equals("items")) { AuthorityResource resource = (AuthorityResource) getResourceMap().get(serviceName); - resource.updateAuthorityItem(getResourceMap(), createUriInfo(), vocabularyCsid, csid, payload); + resource.updateAuthorityItem(getServiceContext(), getResourceMap(), createUriInfo(), vocabularyCsid, csid, payload); } } else { diff --git a/services/common/src/main/java/org/collectionspace/services/common/storage/JDBCTools.java b/services/common/src/main/java/org/collectionspace/services/common/storage/JDBCTools.java index 338405271..b62dfd602 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/storage/JDBCTools.java +++ b/services/common/src/main/java/org/collectionspace/services/common/storage/JDBCTools.java @@ -103,15 +103,32 @@ public class JDBCTools { logger.debug("Looking up DataSource instance in JNDI with name: " + dataSourceName); } - envCtx = (Context) ctx.lookup("java:comp/env"); - DataSource ds = (DataSource) envCtx.lookup("jdbc/" + dataSourceName); - if (ds == null) { - throw new IllegalArgumentException("DataSource instance not found: " + dataSourceName); - } else { - result = ds; - // now cache this DataSource instance for future references - cachedDataSources.put(dataSourceName, result); - } + try { + envCtx = (Context) ctx.lookup("java:comp/env"); + DataSource ds = (DataSource) envCtx.lookup("jdbc/" + dataSourceName); + if (ds == null) { + throw new IllegalArgumentException("DataSource instance not found: " + dataSourceName); + } else { + result = ds; + // now cache this DataSource instance for future references + cachedDataSources.put(dataSourceName, result); + } + } finally { // We should explicitly close both context instances + if (ctx != null) { + try { + ctx.close(); + } catch (Exception e) { + logger.error("Error getting DataSource for: " + dataSourceName, e); + } + } + if (envCtx != null) { + try { + envCtx.close(); + } catch (Exception e) { + logger.error("Error getting DataSource for: " + dataSourceName, e); + } + } + } } if (result != null) { diff --git a/services/report/service/src/main/java/org/collectionspace/services/report/nuxeo/ReportDocumentModelHandler.java b/services/report/service/src/main/java/org/collectionspace/services/report/nuxeo/ReportDocumentModelHandler.java index 277eb74a2..9b43a3662 100644 --- a/services/report/service/src/main/java/org/collectionspace/services/report/nuxeo/ReportDocumentModelHandler.java +++ b/services/report/service/src/main/java/org/collectionspace/services/report/nuxeo/ReportDocumentModelHandler.java @@ -160,6 +160,27 @@ public class ReportDocumentModelHandler extends NuxeoDocumentModelHandler params) { + String outputMIME = invContext.getOutputMIME(); + String mode = invContext.getMode(); + String updateCoreValues = invContext.getUpdateCoreValues(); + String docType = invContext.getDocType(); + String singleCSID = invContext.getSingleCSID(); + String groupCSID = invContext.getGroupCSID(); + String listCSIDs = invContext.getListCSIDs() == null ? "" : invContext.getListCSIDs().toString(); + + String result = + "{MIME type: " + outputMIME + + "\n \t Context mode: " + mode + + "\n \t Update Core Values: " + updateCoreValues + + "\n \t Document type: " + docType + + "\n \t CSID: " + singleCSID + + "\n \t Group CSID: " + groupCSID + + "\n \t List CSIDs: " + listCSIDs + + "\n \t Parameters: " + params.toString() + "}"; + return result; + } + public InputStream invokeReport( ServiceContext ctx, String csid, @@ -221,6 +242,10 @@ public class ReportDocumentModelHandler extends NuxeoDocumentModelHandler