digidoc4j
digidoc4j copied to clipboard
Mime type exception when validating BDOC container
Hi everyone! I'm getting a strange error when trying to validate a BDOC container:
My code:
Container container = ContainerBuilder.aContainer(DocumentType.BDOC)
.fromExistingFile(bdocFileName)
.build();
// Validate the container
ContainerValidationResult result = container.validate();
// Check if the container is valid
boolean isContainerValid = result.isValid();
// Get the validation errors and warnings
List<DigiDoc4JException> validationErrors = result.getErrors();
List<DigiDoc4JException> validationWarnings = result.getWarnings();
List<DigiDoc4JException> containerErrors = result.getContainerErrors();// Container format errors
List<DigiDoc4JException> containerWarnings = result.getContainerWarnings();
String validationReport = result.getReport();
result.saveXmlReports(reportFileName));
System.out.println(validationErrors);
I think that the issue might concern this function in the ContainerOpener.java class:
In fact, in the read() function at line 126 it crushes by throwing the mentioned exception, assuming that it is an ASIC container before doing the checks that would follow.
Am I doing something wrong?