Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mediaconch_plugin4rosetta
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Harbor Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Digital Preservation
mediaconch_plugin4rosetta
Commits
a6ae8315
Commit
a6ae8315
authored
3 years ago
by
Andreas Romeyke
Browse files
Options
Downloads
Patches
Plain Diff
- simplified
parent
69cd7b9b
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
java/org/slub/rosetta/dps/repository/plugin/SLUBTechnicalMetadataExtractorMediaConchPlugin.java
+20
-25
20 additions, 25 deletions
...lugin/SLUBTechnicalMetadataExtractorMediaConchPlugin.java
with
20 additions
and
25 deletions
java/org/slub/rosetta/dps/repository/plugin/SLUBTechnicalMetadataExtractorMediaConchPlugin.java
+
20
−
25
View file @
a6ae8315
...
...
@@ -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:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment