diff --git a/java/org/slub/rosetta/dps/repository/plugin/SLUBTechnicalMetadataExtractorMediaConchPlugin.java b/java/org/slub/rosetta/dps/repository/plugin/SLUBTechnicalMetadataExtractorMediaConchPlugin.java index 28e694726fc369b9db0b018faffd1db3afd28748..d9a8de4b0cbea4f1c1194eaa0c6fd2a138ada393 100644 --- a/java/org/slub/rosetta/dps/repository/plugin/SLUBTechnicalMetadataExtractorMediaConchPlugin.java +++ b/java/org/slub/rosetta/dps/repository/plugin/SLUBTechnicalMetadataExtractorMediaConchPlugin.java @@ -20,12 +20,10 @@ package org.slub.rosetta.dps.repository.plugin; import com.exlibris.core.sdk.strings.StringUtils; import com.exlibris.dps.sdk.techmd.MDExtractorPlugin; import org.xml.sax.InputSource; -import org.xml.sax.XMLReader; -import javax.xml.parsers.SAXParserFactory; +import javax.xml.XMLConstants; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerFactory; -import javax.xml.transform.sax.SAXSource; import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamSource; import java.io.BufferedReader; @@ -122,6 +120,7 @@ public class SLUBTechnicalMetadataExtractorMediaConchPlugin implements MDExtract } + /* ffprobe output of metadata supports different outputs. we are using the flat-model, see WRITERS section in ffprobe manual the streams will be mapped as: streams.stream.0.$property @@ -137,43 +136,37 @@ public class SLUBTechnicalMetadataExtractorMediaConchPlugin implements MDExtract String line=reader.readLine(); StringBuilder mediainfo_output= new StringBuilder(); while (line != null) { - System.out.println(line); - mediainfo_output.append(line); + /* we should patched out, because not allowed to download xsd */ + String regex = " https://mediaarea\\.net/mediainfo/mediainfo.*\\.xsd"; + String line_patched = line.replaceAll( regex, ""); + mediainfo_output.append(line_patched); line = reader.readLine(); } /* xslt transform */ InputStream stylestream = getClass().getResourceAsStream("resources/transformer.xsl"); StreamSource stylesource = new StreamSource( stylestream); + System.out.println("stylesource, systemID=" + stylesource.getSystemId()); + System.out.println("stylesource, publicID=" + stylesource.getPublicId()); + // Use a Transformer for output - SAXParserFactory spf = SAXParserFactory.newInstance(); - spf.setNamespaceAware(true); - /* disabled external DTD loading, which does not work with class ressource */ - spf.setValidating(false); - spf.setNamespaceAware(true); - spf.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false); - spf.setFeature("http://xml.org/sax/features/use-entity-resolver2", false); - spf.setFeature("http://xml.org/sax/features/validation", false); - spf.setFeature("http://apache.org/xml/features/nonvalidating/load-dtd-grammar", false); - spf.setFeature("http://xml.org/sax/features/allow-dtd-events-after-endDTD", false); - XMLReader r = spf.newSAXParser().getXMLReader(); -// StreamSource mediainfo_source = new StreamSource(mediainfo_output); - SAXSource mediainfo_sax_source = new SAXSource(r, new InputSource(mediainfo_output.toString())); + StreamSource mediainfo_source = new StreamSource(String.valueOf(new InputSource(mediainfo_output.toString()))); + System.out.println("mediainfo_source, systemID=" + mediainfo_source.getSystemId()); + System.out.println("mediainfo_source, publicID=" + mediainfo_source.getPublicId()); + TransformerFactory tFactory = TransformerFactory.newInstance(); - //tFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, ""); - //tFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_STYLESHEET, ""); -// tFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_SCHEMA, ""); -// tFactory.setAttribute(XMLConstants.USE_CATALOG, ""); + tFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, ""); + tFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_STYLESHEET, ""); Transformer transformer = tFactory.newTransformer(stylesource); /* ok, mediainfo is loaded correctly, and xslt loaded too */ OutputStream debugFile = new FileOutputStream("DEBUG.xml"); StreamResult result = new StreamResult( debugFile); // StreamResult result = new StreamResult(System.out); /* FIXME , use StringOutputStream */ - transformer.transform(mediainfo_sax_source, result); + transformer.transform(mediainfo_source, result); attributes.put("key", "value"); } catch (InterruptedException e) { + Thread.currentThread().interrupt(); e.printStackTrace(); - } } @@ -209,6 +202,7 @@ public class SLUBTechnicalMetadataExtractorMediaConchPlugin implements MDExtract } catch (IOException e) { //log.error("exception creation socket, clamd not available at host=" + host + "port=" + port, e); } catch (InterruptedException e) { + Thread.currentThread().interrupt(); e.printStackTrace(); } return response.toString().trim(); @@ -224,7 +218,8 @@ public class SLUBTechnicalMetadataExtractorMediaConchPlugin implements MDExtract @Override public List<String> getExtractionErrors() { - return this.extractionErrors; + List<String> extractionErrors = this.extractionErrors; + return extractionErrors; } /* following list is build using: