&& (bundles[i].getName().equals("THUMBNAIL") ||
bundles[i].getName().startsWith("TEXT")))
{
// Try and find the original bitstream, and chuck the
// derived bitstream in the same group
Bitstream original = findOriginalBitstream(item,
bitstreams[bits]);
if (original != null)
{
groupID = "GROUP_" + bitstreamIDstart
+ original.getSequenceID();
}
}
file.setGROUPID(groupID);
file.setMIMETYPE(bitstreams[bits].getFormat().getMIMEType());
file.setSIZE(auth ? bitstreams[bits].getSize() : 0);
// Translate checksum and type to METS
String csType = bitstreams[bits].getChecksumAlgorithm();
String cs = bitstreams[bits].getChecksum();
if (auth && cs != null && csType != null)
{
try
{
file.setCHECKSUMTYPE(Checksumtype.parse(csType));
file.setCHECKSUM(cs);
}
catch (MetsException e)
{
log.warn("Cannot set bitstream checksum type="+csType+" in METS.");
}
}
// FLocat: point to location of bitstream contents.
FLocat flocat = new FLocat();
flocat.setLOCTYPE(Loctype.URL);
flocat.setXlinkHref(makeBitstreamURL(bitstreams[bits], params));
file.getContent().add(flocat);
// technical metadata for bitstream
String techID = addAmdSec(context, bitstreams[bits], params, mets, extraStreams);
if (techID != null)
{
file.setADMID(techID);
}
}
fileSec.getContent().add(fileGrp);
}
}
else if (dso.getType() == Constants.COLLECTION)
{
Collection collection = (Collection)dso;
ItemIterator ii = collection.getItems();
while (ii.hasNext())
{
//add a child <div> for each item in collection
Item item = ii.next();
Div childDiv = makeChildDiv(getObjectTypeString(item), item, params);
if(childDiv!=null)
{
div0.getContent().add(childDiv);
}
}
// add metadata & info for Template Item, if exists
Item templateItem = collection.getTemplateItem();
if(templateItem!=null)
{
String templateDmdId[] = new String[dmdTypes.length];
// index where we should add the first template item <dmdSec>.
// Index = number of <dmdSecs> already added + number of <metsHdr> = # of dmdSecs + 1
// (Note: in order to be a valid METS file, all dmdSecs must be before the 1st amdSec)
int dmdIndex = dmdTypes.length + 1;
//For each type of dmdSec specified,
// add a new dmdSec which contains the Template Item metadata
// (Note: Template Items are only metadata -- they have no content files)
for (int i = 0; i < dmdTypes.length; ++i)
{
MdSec templateDmdSec = makeMdSec(context, templateItem, DmdSec.class, dmdTypes[i], params, extraStreams);
if (templateDmdSec != null)
{
mets.getContent().add(dmdIndex, templateDmdSec);
dmdIndex++;
templateDmdId[i] = templateDmdSec.getID();
}
}
//Now add a child <div> in structMap to represent that Template Item
Div templateItemDiv = new Div();
templateItemDiv.setID(gensym("div"));
templateItemDiv.setTYPE(getObjectTypeString(templateItem) + TEMPLATE_TYPE_SUFFIX);
//Link up the dmdSec(s) for the Template Item to this <div>
StringBuilder templateDmdIds = new StringBuilder();
for (String currdmdId : templateDmdId)
{
templateDmdIds.append(" ").append(currdmdId);
}
templateItemDiv.setDMDID(templateDmdIds.substring(1));
//add this child <div> before the listing of normal Items
div0.getContent().add(0, templateItemDiv);
}
// add link to Collection Logo, if one exists
Bitstream logoBs = collection.getLogo();
if (logoBs != null)
{
fileSec = new FileSec();
addLogoBitstream(logoBs, fileSec, div0, params);
}
}
else if (dso.getType() == Constants.COMMUNITY)
{
// Subcommunities are directly under "DSpace Object Contents" <div>,
// but are labeled as Communities.
Community subcomms[] = ((Community)dso).getSubcommunities();
for (int i = 0; i < subcomms.length; ++i)
{
//add a child <div> for each subcommunity in this community
Div childDiv = makeChildDiv(getObjectTypeString(subcomms[i]), subcomms[i], params);
if(childDiv!=null)
{
div0.getContent().add(childDiv);
}
}
// Collections are also directly under "DSpace Object Contents" <div>,
// but are labeled as Collections.
Collection colls[] = ((Community)dso).getCollections();
for (int i = 0; i < colls.length; ++i)
{
//add a child <div> for each collection in this community
Div childDiv = makeChildDiv(getObjectTypeString(colls[i]), colls[i], params);
if(childDiv!=null)
{
div0.getContent().add(childDiv);
}
}
//add Community logo bitstream
Bitstream logoBs = ((Community)dso).getLogo();
if (logoBs != null)
{
fileSec = new FileSec();
addLogoBitstream(logoBs, fileSec, div0, params);
}