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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Digital Preservation
mediaconch_plugin4rosetta
Commits
41d96a4b
Commit
41d96a4b
authored
3 years ago
by
Andreas Romeyke
Browse files
Options
Downloads
Patches
Plain Diff
- added code to extract the attributes of transfomed results
parent
bda17832
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
java/org/slub/rosetta/dps/repository/plugin/SLUBTechnicalMetadataExtractorMediaConchPlugin.java
+37
-6
37 additions, 6 deletions
...lugin/SLUBTechnicalMetadataExtractorMediaConchPlugin.java
with
37 additions
and
6 deletions
java/org/slub/rosetta/dps/repository/plugin/SLUBTechnicalMetadataExtractorMediaConchPlugin.java
+
37
−
6
View file @
41d96a4b
...
...
@@ -19,12 +19,24 @@ package org.slub.rosetta.dps.repository.plugin;
import
com.exlibris.core.sdk.strings.StringUtils
;
import
com.exlibris.dps.sdk.techmd.MDExtractorPlugin
;
import
org.w3c.dom.Document
;
import
org.w3c.dom.Node
;
import
org.w3c.dom.NodeList
;
import
org.xml.sax.SAXException
;
import
javax.xml.XMLConstants
;
import
javax.xml.parsers.DocumentBuilder
;
import
javax.xml.parsers.DocumentBuilderFactory
;
import
javax.xml.parsers.ParserConfigurationException
;
import
javax.xml.transform.Transformer
;
import
javax.xml.transform.TransformerFactory
;
import
javax.xml.transform.stream.StreamResult
;
import
javax.xml.transform.stream.StreamSource
;
import
javax.xml.xpath.XPath
;
import
javax.xml.xpath.XPathConstants
;
import
javax.xml.xpath.XPathExpression
;
import
javax.xml.xpath.XPathExpressionException
;
import
javax.xml.xpath.XPathFactory
;
import
java.io.BufferedReader
;
import
java.io.File
;
import
java.io.FileInputStream
;
...
...
@@ -173,11 +185,27 @@ public class SLUBTechnicalMetadataExtractorMediaConchPlugin implements MDExtract
/* debug output: */
StreamResult
result
=
new
StreamResult
(
temp_media_transformed_outputstream
);
transformer
.
transform
(
mediainfo_source
,
result
);
/* TODO: read debugFile and return attributes */
attributes
.
put
(
"key"
,
"value"
);
/* */
temp_media_transformed_outputstream
.
close
();
mediastream
.
close
();
/* TODO: read transformed outputfile and return attributes */
extract_attributes_of_transformed_result
(
temp_media_transformed_outputfile
);
}
private
void
extract_attributes_of_transformed_result
(
File
temp_media_transformed_outputfile
)
throws
XPathExpressionException
,
ParserConfigurationException
,
SAXException
,
IOException
{
XPathFactory
xPathfactory
=
XPathFactory
.
newInstance
();
XPath
xpath
=
xPathfactory
.
newXPath
();
XPathExpression
expr
=
xpath
.
compile
(
"/mdExtractor/attributes/key"
);
DocumentBuilderFactory
dbf
=
DocumentBuilderFactory
.
newInstance
();
DocumentBuilder
db
=
dbf
.
newDocumentBuilder
();
Document
temp_media_transformed_source
=
db
.
parse
(
temp_media_transformed_outputfile
);
NodeList
nl
=
(
NodeList
)
expr
.
evaluate
(
temp_media_transformed_source
,
XPathConstants
.
NODESET
);
int
len
=
nl
.
getLength
();
for
(
int
i
=
0
;
i
<
len
;
i
++
)
{
Node
node
=
nl
.
item
(
i
);
String
id
=
String
.
valueOf
(
node
.
getAttributes
().
getNamedItem
(
"id"
));
String
value
=
node
.
getTextContent
();
attributes
.
put
(
id
,
value
);
}
}
private
void
call_mediaconch
(
String
filePath
)
throws
Exception
{
...
...
@@ -395,7 +423,7 @@ public class SLUBTechnicalMetadataExtractorMediaConchPlugin implements MDExtract
@Override
public
boolean
isValid
()
{
System
.
out
.
println
(
"DEBUG: is valid="
+
this
.
isvalid
);
//
System.out.println("DEBUG: is valid=" + this.isvalid);
return
this
.
isvalid
;
}
@Override
...
...
@@ -461,8 +489,11 @@ public class SLUBTechnicalMetadataExtractorMediaConchPlugin implements MDExtract
System
.
out
.
println
(
"----------------------------------"
);
System
.
out
.
println
(
"getProfile:"
);
System
.
out
.
println
(
plugin
.
getProfile
());
System
.
out
.
println
(
"----------------------------------"
);
System
.
out
.
println
(
"getAttributeByName (summarized):"
);
for
(
Map
.
Entry
m:
plugin
.
attributes
.
entrySet
())
{
System
.
out
.
println
(
m
.
getKey
()
+
" -> "
+
m
.
getValue
());
}
}
}
...
...
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