xwalk.ingest(context, dso, getMdContentAsXml(xmd,callback));
}
// Otherwise, try stream-based crosswalk
else
{
StreamIngestionCrosswalk sxwalk =
(StreamIngestionCrosswalk)getCrosswalk(type, StreamIngestionCrosswalk.class);
if (sxwalk != null)
{
// Check if our Crosswalk actually wraps another Packager Plugin
if(sxwalk instanceof AbstractPackagerWrappingCrosswalk)
{
// If this crosswalk wraps another Packager Plugin, we can pass it our Packaging Parameters
// (which essentially allow us to customize the ingest process of the crosswalk)
AbstractPackagerWrappingCrosswalk wrapper = (AbstractPackagerWrappingCrosswalk) sxwalk;
wrapper.setPackagingParameters(params);
}
// If we found a Stream-based crosswalk that matches, we now want to
// locate the stream we are crosswalking. This stream should be
// references in METS via an <mdRef> element
// (which is how METS references external files)
Element mdRef = xmd.getChild("mdRef", metsNS);
if (mdRef != null)
{
InputStream in = null;
try
{
in = callback.getInputStream(mdRef);
sxwalk.ingest(context, dso, in,
mdRef.getAttributeValue("MIMETYPE"));
}
finally
{
if (in != null)
{
in.close();
}
}
} // If we couldn't find an <mdRef>, then we'll try an <mdWrap>
// with a <binData> element instead.
// (this is how METS wraps embedded base64-encoded content streams)
else
{
Element mdWrap = xmd.getChild("mdWrap", metsNS);
if (mdWrap != null)
{
Element bin = mdWrap.getChild("binData", metsNS);
if (bin == null)
{
throw new MetadataValidationException("Invalid METS Manifest: mdWrap element for streaming crosswalk without binData child.");
}
else
{
byte value[] = Base64.decodeBase64(bin.getText().getBytes());
sxwalk.ingest(context, dso,
new ByteArrayInputStream(value),
mdWrap.getAttributeValue("MIMETYPE"));
}
}
else