digidoc4j icon indicating copy to clipboard operation
digidoc4j copied to clipboard

Mime type exception when validating BDOC container

Open hello96 opened this issue 7 months ago • 2 comments

Hi everyone! I'm getting a strange error when trying to validate a BDOC container:

image

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:

WhatsApp Image 2024-07-12 at 12 07 44

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?

hello96 avatar Jul 12 '24 15:07 hello96