|
75 | 75 | import edu.harvard.iq.dataverse.pidproviders.PidUtil; |
76 | 76 | import edu.harvard.iq.dataverse.settings.JvmSettings; |
77 | 77 | import static edu.harvard.iq.dataverse.settings.SettingsServiceBean.Key.BagGeneratorThreads; |
| 78 | + |
| 79 | +import edu.harvard.iq.dataverse.util.SystemConfig; |
78 | 80 | import edu.harvard.iq.dataverse.util.json.JsonLDTerm; |
| 81 | +import jakarta.enterprise.inject.spi.CDI; |
79 | 82 |
|
80 | 83 | /** |
81 | 84 | * Creates an archival zipped Bag for long-term storage. It is intended to |
@@ -153,7 +156,6 @@ public class BagGenerator { |
153 | 156 | public BagGenerator(OREMap oreMap, String dataciteXml) throws JsonSyntaxException, Exception { |
154 | 157 | this.oremap = oreMap; |
155 | 158 | this.oremapObject = oreMap.getOREMap(); |
156 | | - //(JsonObject) new JsonParser().parse(oreMap.getOREMap().toString()); |
157 | 159 | this.dataciteXml = dataciteXml; |
158 | 160 |
|
159 | 161 | try { |
@@ -189,10 +191,6 @@ public void setIgnoreHashes(boolean val) { |
189 | 191 | ignorehashes = val; |
190 | 192 | } |
191 | 193 |
|
192 | | - public void setDefaultCheckSumType(ChecksumType type) { |
193 | | - hashtype=type; |
194 | | - } |
195 | | - |
196 | 194 | public static void println(String s) { |
197 | 195 | System.out.println(s); |
198 | 196 | System.out.flush(); |
@@ -278,6 +276,15 @@ public boolean generateBag(OutputStream outputStream) throws Exception { |
278 | 276 | String path = sha1Entry.getKey(); |
279 | 277 | sha1StringBuffer.append(sha1Entry.getValue() + " " + path); |
280 | 278 | } |
| 279 | + if(hashtype == null) { // No files - still want to send an empty manifest to nominally comply with BagIT specification requirement. |
| 280 | + try { |
| 281 | + //Use the current type if we can retrieve it |
| 282 | + hashtype = CDI.current().select(SystemConfig.class).get().getFileFixityChecksumAlgorithm(); |
| 283 | + } catch (Exception e) { |
| 284 | + // Default to MD5 if we can't |
| 285 | + hashtype=DataFile.ChecksumType.MD5; |
| 286 | + } |
| 287 | + } |
281 | 288 | if (!(hashtype == null)) { |
282 | 289 | String manifestName = "manifest-"; |
283 | 290 | if (hashtype.equals(DataFile.ChecksumType.SHA1)) { |
|
0 commit comments