Skip to content

Commit

Permalink
Write debug file on METS export
Browse files Browse the repository at this point in the history
  • Loading branch information
matthias-ronge authored Mar 1, 2024
1 parent 92e7f32 commit 7115591
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion Kitodo/src/main/java/org/kitodo/export/ExportMets.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@
import javax.xml.transform.TransformerException;
import javax.xml.transform.stream.StreamSource;

import org.apache.commons.io.FileUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.kitodo.api.dataformat.Workpiece;
import org.kitodo.config.ConfigCore;
import org.kitodo.data.database.beans.Process;
import org.kitodo.data.database.beans.User;
import org.kitodo.data.database.exceptions.DAOException;
Expand Down Expand Up @@ -149,7 +151,12 @@ protected boolean writeMetsFile(Process process, URI metaFile, LegacyMetsModsDig
*/
try (ByteArrayOutputStream out = new ByteArrayOutputStream()) {
ServiceManager.getMetsService().save(workpiece, out);
try (ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(out.toByteArray())) {
byte[] xmlBytes = out.toByteArray();
File debugFolder = ConfigCore.getKitodoDebugDirectory();
if (Objects.nonNull(debugFolder)) {
FileUtils.writeByteArrayToFile(new File(debugFolder, "preExport.xml"), xmlBytes);
}
try (ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xmlBytes)) {
StreamSource source = new StreamSource(byteArrayInputStream);
try (BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(new FileOutputStream(new File(metaFile)))) {
URI xslFile = XsltHelper.getXsltFileFromConfig(process);
Expand Down

0 comments on commit 7115591

Please sign in to comment.