Revision: 18960
http://sourceforge.net/p/dcm4che/svn/18960
Author: javawilli
Date: 2021-03-11 16:02:23 +0000 (Thu, 11 Mar 2021)
Log Message:
-----------
Add update File MD5sum method
Modified Paths:
--------------
dcm4chee/dcm4chee-arc/branches/DCM4CHEE_2_18_0-RC/dcm4jboss-sar/src/java/org/dcm4chex/archive/mbean/UpdateAttributesService.java
Modified: dcm4chee/dcm4chee-arc/branches/DCM4CHEE_2_18_0-RC/dcm4jboss-sar/src/java/org/dcm4chex/archive/mbean/UpdateAttributesService.java
===================================================================
--- dcm4chee/dcm4chee-arc/branches/DCM4CHEE_2_18_0-RC/dcm4jboss-sar/src/java/org/dcm4chex/archive/mbean/UpdateAttributesService.java 2021-03-11 16:01:16 UTC (rev 18959)
+++ dcm4chee/dcm4chee-arc/branches/DCM4CHEE_2_18_0-RC/dcm4jboss-sar/src/java/org/dcm4chex/archive/mbean/UpdateAttributesService.java 2021-03-11 16:02:23 UTC (rev 18960)
@@ -40,6 +40,8 @@
import java.io.File;
import java.io.IOException;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
import java.sql.Timestamp;
import java.text.ParseException;
import java.text.SimpleDateFormat;
@@ -55,6 +57,7 @@
import org.dcm4che.data.DcmObjectFactory;
import org.dcm4che.data.FileFormat;
import org.dcm4che.dict.Tags;
+import org.dcm4che.util.MD5Utils;
import org.dcm4chex.archive.common.Availability;
import org.dcm4chex.archive.ejb.conf.AttributeFilter;
import org.dcm4chex.archive.ejb.interfaces.UpdateAttributes;
@@ -380,12 +383,15 @@
}
private File getFile(FileInfo info) throws Exception {
- return (File) server.invoke(queryRetrieveScpServiceName, "getFile",
+ File file = (File) server.invoke(queryRetrieveScpServiceName, "getFile",
new Object[] { info.basedir, info.fileID }, new String[] {
String.class.getName(), String.class.getName() });
+ if (info.md5 == null)
+ updateMD5(info, file);
+ return file;
}
- public void coerceAttributes(String xsl, Dataset in) {
+ public void coerceAttributes(String xsl, Dataset in) {
if (xsl != null) {
Dataset coerce = CoercionUtils.getCoercionAttributesFor(null, in, templates.getTemplatesForAET(null, xsl));
if (coerce != null) {
@@ -394,4 +400,16 @@
}
}
}
+
+ private void updateMD5(FileInfo info, File file) {
+ String msg = "Update missing md5 in file pk:"+info.pk+", "+info.fileID;
+ try {
+ log.info(msg);
+ byte[] md5sum = MD5Utils.md5sum(file, MessageDigest.getInstance("MD5"), new byte[8192]);
+ this.updateAttributes().updateFileMD5(info.pk, md5sum);
+ } catch (Exception e) {
+ log.warn("Failed to "+msg);
+ }
+ }
+
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|