]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
DRYD-841, DRYD-855: Merging in UCB contributions to post-v6.0 master branch.
authorRichard Millet <remillet@yahoo.com>
Wed, 29 Apr 2020 00:49:25 +0000 (17:49 -0700)
committerRichard Millet <remillet@yahoo.com>
Wed, 29 Apr 2020 00:49:25 +0000 (17:49 -0700)
services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/MergeAuthorityItemsBatchJob.java
services/common/src/main/java/org/collectionspace/services/common/storage/JDBCTools.java
services/report/service/src/main/java/org/collectionspace/services/report/nuxeo/ReportDocumentModelHandler.java

index 41dde283ee8af1d923cb729d0519eed2e3bece26..80b9b304081a8d3dcc6ab56fa58fd18091dc5307 100644 (file)
@@ -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 {
index 3384052710ea4bf025c9ff89495b3c582899c1e7..b62dfd6025518094451fbd252869abd9303282ba 100644 (file)
@@ -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) {
index 277eb74a2182cc64ea2e071bf7db138c250d9823..9b43a3662a31bf3d67df3c6301ebc315cbc3a54e 100644 (file)
@@ -160,6 +160,27 @@ public class ReportDocumentModelHandler extends NuxeoDocumentModelHandler<Report
         return result;
     }
     
+    private String getInvocationContextLogging(InvocationContext invContext, Map<String, Object> 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<PoxPayloadIn, PoxPayloadOut> ctx,
                        String csid,
@@ -221,6 +242,10 @@ public class ReportDocumentModelHandler extends NuxeoDocumentModelHandler<Report
                                +invocationMode);
                }
                
+               logger.debug("The invocation context is: \n " + getInvocationContextLogging(invContext, params));
+               logger.debug("The report is being called with the following parameters, which are being passed to Jasper: \n" + params.toString());
+               logger.debug("The mode being passed to Jasper is: " + invocationMode);
+               
                NuxeoRepositoryClientImpl repoClient = (NuxeoRepositoryClientImpl)this.getRepositoryClient(ctx);
                repoSession = this.getRepositorySession();
                if (repoSession == null) {