-
Notifications
You must be signed in to change notification settings - Fork 493
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BagIt Support - Add automatic checksum validation on upload
- Loading branch information
Showing
45 changed files
with
2,829 additions
and
21 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
doc/release-notes/8608-bagit-support-validate-checksums.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
## BagIt Support - Automatic checksum validation on zip file upload | ||
The BagIt file handler detects and transforms zip files with a BagIt package format into Dataverse DataFiles. The system validates the checksums of the files in the package payload as described in the first manifest file with a hash algorithm that we support. Take a look at `BagChecksumType class <https://github.com/IQSS/dataverse/tree/develop/src/main/java/edu/harvard/iq/dataverse/util/bagit/BagChecksumType.java>`_ for the list of the currently supported hash algorithms. | ||
|
||
The handler will not allow packages with checksum errors. The first 5 errors will be displayed to the user. This is configurable though database settings. | ||
|
||
The checksum validation uses a thread pool to improve performance. This thread pool can be adjusted to your Dataverse installation requirements. | ||
|
||
The BagIt file handler is disabled by default. Use the ``:BagItHandlerEnabled`` database settings to enable it: ``curl -X PUT -d 'true' http://localhost:8080/api/admin/settings/:BagItHandlerEnabled`` | ||
|
||
For more configuration settings see the user guide: https://guides.dataverse.org/en/latest/installation/config.html#bagit-file-handler |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
src/main/java/edu/harvard/iq/dataverse/EditDataFilesPageHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package edu.harvard.iq.dataverse; | ||
|
||
import edu.harvard.iq.dataverse.util.BundleUtil; | ||
import edu.harvard.iq.dataverse.util.file.CreateDataFileResult; | ||
|
||
import javax.ejb.Stateless; | ||
import javax.inject.Inject; | ||
import java.util.List; | ||
import java.util.Optional; | ||
import java.util.stream.Collectors; | ||
|
||
/** | ||
* | ||
* @author adaybujeda | ||
*/ | ||
@Stateless | ||
public class EditDataFilesPageHelper { | ||
|
||
public static final String MAX_ERRORS_TO_DISPLAY_SETTING = ":CreateDataFilesMaxErrorsToDisplay"; | ||
public static final Integer MAX_ERRORS_TO_DISPLAY = 5; | ||
|
||
@Inject | ||
private SettingsWrapper settingsWrapper; | ||
|
||
public String getHtmlErrorMessage(CreateDataFileResult createDataFileResult) { | ||
List<String> errors = createDataFileResult.getErrors(); | ||
if(errors == null || errors.isEmpty()) { | ||
return null; | ||
} | ||
|
||
Integer maxErrorsToShow = settingsWrapper.getInteger(EditDataFilesPageHelper.MAX_ERRORS_TO_DISPLAY_SETTING, EditDataFilesPageHelper.MAX_ERRORS_TO_DISPLAY); | ||
if(maxErrorsToShow < 1) { | ||
return null; | ||
} | ||
|
||
String typeMessage = Optional.ofNullable(BundleUtil.getStringFromBundle(createDataFileResult.getBundleKey())).orElse("Error processing file"); | ||
String errorsMessage = errors.stream().limit(maxErrorsToShow).map(text -> String.format("<li>%s</li>", text)).collect(Collectors.joining()); | ||
return String.format("%s:<br /><ul>%s</ul>", typeMessage, errorsMessage); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.