* </xmlDate>
* </mdWrap>
* </dmdSec
*/
protected void renderDescriptiveSection() throws WingException, SAXException, CrosswalkException, IOException, SQLException {
AttributeMap attributes;
String groupID = getGenericID("group_dmd_");
dmdSecIDS = new StringBuffer();
// Add DIM descriptive metadata if it was requested or if no metadata types
// were specified. Further more since this is the default type we also use a
// faster rendering method that the crosswalk API.
if (dmdTypes.size() == 0 || dmdTypes.contains("DIM")) {
// Metadata element's ID
String dmdID = getGenericID("dmd_");
// Keep track of all descriptive sections
dmdSecIDS.append("" + dmdID);
////////////////////////////////
// Start a metadata wrapper
attributes = new AttributeMap();
attributes.put("ID", dmdID);
attributes.put("GROUPID", groupID);
startElement(METS, "dmdSec", attributes);
////////////////////////////////
// Start a metadata wrapper
attributes = new AttributeMap();
attributes.put("MDTYPE", "OTHER");
attributes.put("OTHERMDTYPE", "DIM");
startElement(METS, "mdWrap", attributes);
// ////////////////////////////////
// Start the xml data
startElement(METS, "xmlData");
// ///////////////////////////////
// Start the DIM element
attributes = new AttributeMap();
attributes.put("dspaceType", Constants.typeText[item.getType()]);
if (item.isWithdrawn()) {
attributes.put("withdrawn", "y");
}
startElement(DIM, "dim", attributes);
DCValue[] dcvs = item.getMetadata(Item.ANY, Item.ANY, Item.ANY, Item.ANY);
for (DCValue dcv : dcvs) {
if (!MetadataExposure.isHidden(context, dcv.schema, dcv.element, dcv.qualifier)) {
// ///////////////////////////////
// Field element for each metadata field.
attributes = new AttributeMap();
attributes.put("mdschema", dcv.schema);
attributes.put("element", dcv.element);
if (dcv.qualifier != null) {
attributes.put("qualifier", dcv.qualifier);
}
if (dcv.language != null) {
attributes.put("language", dcv.language);
}
if (dcv.authority != null || dcv.confidence != Choices.CF_UNSET) {
attributes.put("authority", dcv.authority);
attributes.put("confidence", Choices.getConfidenceText(dcv.confidence));
}
startElement(DIM, "field", attributes);
sendCharacters(dcv.value);
endElement(DIM, "field");
}
}
// ///////////////////////////////
// End the DIM element
endElement(DIM, "dim");
// ////////////////////////////////
// End elements
endElement(METS, "xmlData");
endElement(METS, "mdWrap");
endElement(METS, "dmdSec");
}
// Add any extra crosswalks that may configured.
for (String dmdType : dmdTypes) {
// If DIM was requested then it was generated above without using
// the crosswalk API. So we can skip this one.
if ("DIM".equals(dmdType)) {
continue;
}
DisseminationCrosswalk crosswalk = getDisseminationCrosswalk(dmdType);
if (crosswalk == null) {
continue;
}
String dmdID = getGenericID("dmd_");
// Add our id to the list.
dmdSecIDS.append(" " + dmdID);
////////////////////////////////
// Start a metadata wrapper
attributes = new AttributeMap();
attributes.put("ID", dmdID);
attributes.put("GROUPID", groupID);
startElement(METS, "dmdSec", attributes);
////////////////////////////////
// Start a metadata wrapper
attributes = new AttributeMap();
if (isDefinedMETStype(dmdType)) {
attributes.put("MDTYPE", dmdType);
} else {
attributes.put("MDTYPE", "OTHER");
attributes.put("OTHERMDTYPE", dmdType);
}
startElement(METS, "mdWrap", attributes);
// ////////////////////////////////
// Start the xml data
startElement(METS, "xmlData");
// ///////////////////////////////
// Send the actual XML content
try {
Element dissemination = crosswalk.disseminateElement(item);
SAXFilter filter = new SAXFilter(contentHandler, lexicalHandler, namespaces);
// Allow the basics for XML
filter.allowElements().allowIgnorableWhitespace().allowCharacters().allowCDATA().allowPrefixMappings();
SAXOutputter outputter = new SAXOutputter();
outputter.setContentHandler(filter);
outputter.setLexicalHandler(filter);
outputter.output(dissemination);
} catch (JDOMException jdome) {
throw new WingException(jdome);
} catch (AuthorizeException ae) {
// just ignore the authorize exception and continue on with
//out parsing the xml document.
}
// ////////////////////////////////
// End elements
endElement(METS, "xmlData");
endElement(METS, "mdWrap");
endElement(METS, "dmdSec");
}
// Check to see if there is an in-line MODS document
// stored as a bitstream. If there is then we should also
// include these metadata in our METS document. However
// we don't really know what the document describes, so we
// but it in it's own dmd group.
Boolean include = ConfigurationManager.getBooleanProperty("xmlui.bitstream.mods");
if (include && dmdTypes.contains("MODS")) {
// Generate a second group id for any extra metadata added.
String groupID2 = getGenericID("group_dmd_");
Bundle[] bundles = item.getBundles("METADATA");
for (Bundle bundle : bundles) {
Bitstream bitstream = bundle.getBitstreamByName("MODS.xml");
if (bitstream == null) {
continue;
}
String dmdID = getGenericID("dmd_");
////////////////////////////////
// Start a metadata wrapper
attributes = new AttributeMap();
attributes.put("ID", dmdID);
attributes.put("GROUPID", groupID2);
startElement(METS, "dmdSec", attributes);
////////////////////////////////
// Start a metadata wrapper
attributes = new AttributeMap();
attributes.put("MDTYPE", "MODS");
startElement(METS, "mdWrap", attributes);
// ////////////////////////////////
// Start the xml data
startElement(METS, "xmlData");