Skip to content

Commit

Permalink
Minor refactoring of several packagers: Added a getObjectTypeString()…
Browse files Browse the repository at this point in the history
… method to AbstractMETSDisseminator, which takes the place of several hardcoded Object Type strings (and allows extending METS Packagers to override what values to put in METS @type attributes).   Cleaned up all three of these classes by adding @OverRide annotations where appropriate and cleaned up comments.

git-svn-id: http://scm.dspace.org/svn/repo/dspace/trunk@5299 9c30dcfa-912a-0410-8fc2-9e0234be79fd
  • Loading branch information
tdonohue committed Aug 27, 2010
1 parent 633faec commit 0b6b54e
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 18 deletions.
Expand Up @@ -684,14 +684,13 @@ protected Mets makeManifest(Context context, DSpaceObject dso,
{
// Create the METS manifest in memory
Mets mets = new Mets();
String typeStr = Constants.typeText[dso.getType()];


// this ID should be globally unique
mets.setID("dspace"+Utils.generateKey());

// identifies the object described by this document
mets.setOBJID(makePersistentID(dso));
mets.setTYPE("DSpace "+typeStr);
mets.setTYPE(getObjectTypeString(dso));

// this is the signature by which the ingester will recognize
// a document it can expect to interpret.
Expand Down Expand Up @@ -787,6 +786,7 @@ protected Mets makeManifest(Context context, DSpaceObject dso,
primaryBitstreamID = bundles[i].getPrimaryBitstreamID();
}

// For each bitstream, add to METS manifest
for (int bits = 0; bits < bitstreams.length; bits++)
{
// Check for authorization. Handle unauthorized
Expand Down Expand Up @@ -821,7 +821,7 @@ else if (!(unauth != null && unauth.equalsIgnoreCase("zero")))

// if this is content, add to structmap too:
if (isContentBundle)
div0.getContent().add(makeFileDiv(fileID, "DSpace Content Bitstream"));
div0.getContent().add(makeFileDiv(fileID, getObjectTypeString(bitstreams[bits])));

/*
* If we're in THUMBNAIL or TEXT bundles, the bitstream is
Expand All @@ -845,12 +845,9 @@ else if (!(unauth != null && unauth.equalsIgnoreCase("zero")))
}
file.setGROUPID(groupID);
file.setMIMETYPE(bitstreams[bits].getFormat().getMIMEType());

// FIXME: CREATED: no date

file.setSIZE(auth ? bitstreams[bits].getSize() : 0);

// FIXME: need to translate checksum and type to METS, if available.
// Translate checksum and type to METS
String csType = bitstreams[bits].getChecksumAlgorithm();
String cs = bitstreams[bits].getChecksum();
if (auth && cs != null && csType != null)
Expand Down Expand Up @@ -887,7 +884,7 @@ else if (dso.getType() == Constants.COLLECTION)
{
//add a child <div> for each item in collection
Item item = ii.next();
Div childDiv = makeChildDiv("DSpace Item", item, params);
Div childDiv = makeChildDiv(getObjectTypeString(item), item, params);
if(childDiv!=null)
div0.getContent().add(childDiv);
}
Expand All @@ -906,7 +903,7 @@ else if (dso.getType() == Constants.COMMUNITY)
for (int i = 0; i < subcomms.length; ++i)
{
//add a child <div> for each subcommunity in this community
Div childDiv = makeChildDiv("DSpace Community", subcomms[i], params);
Div childDiv = makeChildDiv(getObjectTypeString(subcomms[i]), subcomms[i], params);
if(childDiv!=null)
div0.getContent().add(childDiv);
}
Expand All @@ -916,7 +913,7 @@ else if (dso.getType() == Constants.COMMUNITY)
for (int i = 0; i < colls.length; ++i)
{
//add a child <div> for each collection in this community
Div childDiv = makeChildDiv("DSpace Collection", colls[i], params);
Div childDiv = makeChildDiv(getObjectTypeString(colls[i]), colls[i], params);
if(childDiv!=null)
div0.getContent().add(childDiv);
}
Expand All @@ -936,7 +933,7 @@ else if (dso.getType() == Constants.SITE)
for (int i = 0; i < comms.length; ++i)
{
//add a child <div> for each top level community in this site
Div childDiv = makeChildDiv("DSpace Community", comms[i], params);
Div childDiv = makeChildDiv(getObjectTypeString(comms[i]), comms[i], params);
if(childDiv!=null)
div0.getContent().add(childDiv);
}
Expand Down Expand Up @@ -1003,7 +1000,7 @@ protected void addLogoBitstream(Bitstream logoBs, FileSec fileSec, Div div0, Pac
file.setMIMETYPE(logoBs.getFormat().getMIMEType());
file.setSIZE(logoBs.getSize());

// FIXME: need to translate checksum and type to METS, if available.
// Translate checksum and type to METS
String csType = logoBs.getChecksumAlgorithm();
String cs = logoBs.getChecksum();
if (cs != null && csType != null)
Expand All @@ -1018,6 +1015,8 @@ protected void addLogoBitstream(Bitstream logoBs, FileSec fileSec, Div div0, Pac
log.warn("Cannot set bitstream checksum type="+csType+" in METS.");
}
}

//Create <fileGroup USE="LOGO"> with a <FLocat> pointing at bitstream
FLocat flocat = new FLocat();
flocat.setLOCTYPE(Loctype.URL);
flocat.setXlinkHref(makeBitstreamURL(logoBs, params));
Expand Down Expand Up @@ -1283,6 +1282,22 @@ else if(mdRef.getMDTYPE() != null && mdRef.getMDTYPE() == Mdtype.OTHER &&
}
}

/**
* Build a string which will be used as the "Type" of this object in
* the METS manifest.
* <P>
* Default format is "DSpace [Type-as-string]".
*
* @param dso DSpaceObject to create type-string for
* @return a string which will represent this object Type in METS
* @see org.dspace.core.Constants
*/
public String getObjectTypeString(DSpaceObject dso)
{
//Format: "DSpace <Type-as-string>" (e.g. "DSpace ITEM", "DSpace COLLECTION", etc)
return "DSpace " + Constants.typeText[dso.getType()];
}

/**
* Return identifier for bitstream in an Item; when making a package,
* this is the archive member name (e.g. in Zip file). In a bare
Expand Down
Expand Up @@ -57,7 +57,6 @@
import org.dspace.content.NonUniqueMetadataException;
import org.dspace.content.crosswalk.CrosswalkException;
import org.dspace.content.crosswalk.MetadataValidationException;
import org.dspace.core.ConfigurationManager;
import org.dspace.core.Context;
import org.dspace.core.Constants;

Expand Down
Expand Up @@ -115,6 +115,7 @@ public class DSpaceMETSDisseminator
*
* @return string name of profile.
*/
@Override
public String getProfile()
{
return PROFILE_LABEL;
Expand All @@ -128,6 +129,7 @@ public String getProfile()
* @param bname name of DSpace bundle.
* @return string name of fileGrp
*/
@Override
public String bundleToFileGrp(String bname)
{
if (bname.equals("ORIGINAL"))
Expand All @@ -139,13 +141,14 @@ public String bundleToFileGrp(String bname)
/**
* Create metsHdr element - separate so subclasses can override.
*/
@Override
public MetsHdr makeMetsHdr(Context context, DSpaceObject dso,
PackageParameters params)
{
MetsHdr metsHdr = new MetsHdr();
metsHdr.setCREATEDATE(new Date()); // FIXME: CREATEDATE is now:
// maybe should be item create
// date?

// FIXME: CREATEDATE is now: maybe should be item create?
metsHdr.setCREATEDATE(new Date());

// Agent
Agent agent = new Agent();
Expand All @@ -168,6 +171,7 @@ public MetsHdr makeMetsHdr(Context context, DSpaceObject dso,
* the name of a crosswalk plugin, optionally followed by colon and
* its METS MDTYPE name.
*/
@Override
public String [] getDmdTypes(Context context, DSpaceObject dso, PackageParameters params)
throws SQLException, IOException, AuthorizeException
{
Expand All @@ -190,6 +194,7 @@ public MetsHdr makeMetsHdr(Context context, DSpaceObject dso,
* Default is PREMIS. This is both the name of the crosswalk plugin
* and the METS MDTYPE.
*/
@Override
public String[] getTechMdTypes(Context context, DSpaceObject dso, PackageParameters params)
throws SQLException, IOException, AuthorizeException
{
Expand All @@ -203,18 +208,21 @@ public String[] getTechMdTypes(Context context, DSpaceObject dso, PackageParamet
return new String[0];
}

@Override
public String[] getSourceMdTypes(Context context, DSpaceObject dso, PackageParameters params)
throws SQLException, IOException, AuthorizeException
{
return new String[0];
}


@Override
public String[] getDigiprovMdTypes(Context context, DSpaceObject dso, PackageParameters params)
throws SQLException, IOException, AuthorizeException
{
return new String[0];
}

@Override
public String makeBitstreamURL(Bitstream bitstream, PackageParameters params)
{
String base = "bitstream_"+String.valueOf(bitstream.getID());
Expand All @@ -226,6 +234,7 @@ public String makeBitstreamURL(Bitstream bitstream, PackageParameters params)
* Add rights MD (licenses) for DSpace item. These
* may include a deposit license, and Creative Commons.
*/
@Override
public String[] getRightsMdTypes(Context context, DSpaceObject dso, PackageParameters params)
throws SQLException, IOException, AuthorizeException
{
Expand All @@ -246,13 +255,15 @@ else if (CreativeCommons.getLicenseTextBitstream(item) != null)
}

// This is where we'd elaborate on the default structMap; nothing to add, yet.
@Override
public void addStructMap(Context context, DSpaceObject dso,
PackageParameters params, Mets mets)
throws SQLException, IOException, AuthorizeException, MetsException
{
}

// only exclude metadata bundles from package.
@Override
public boolean includeBundle(Bundle bundle)
{
return ! PackageUtils.isMetaInfoBundle(bundle);
Expand Down

0 comments on commit 0b6b54e

Please sign in to comment.