From 147f2c47037bccddf66a08c7596ca1caec7145d6 Mon Sep 17 00:00:00 2001 From: Tim Donohue Date: Thu, 23 Sep 2010 14:56:07 +0000 Subject: [PATCH] AIP Work -- Minor tweaks to AIP METS generation, so that METS manifest is generated the same each time & so that it includes DSpace software version information. In other words, if the DSpace Object is unchanged & DSpace software version is unchanged, then the METS manifest should be unchanged (i.e. identical checksums). Previously, the METS manifest would change each time it was generated as it included a timestamp of when it was generated, etc. (NOTE: Once METS AIP is compressed into a ZIP, the checksum of the ZIP will still change each time, as the ZIP format contains a timestamp based on when the compressed file(s) were generated. Not sure if there's any way around that.) git-svn-id: http://scm.dspace.org/svn/repo/dspace/trunk@5352 9c30dcfa-912a-0410-8fc2-9e0234be79fd --- .../packager/AbstractMETSDisseminator.java | 5 +++-- .../packager/DSpaceAIPDisseminator.java | 22 +++++++++++++++---- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/dspace-api/src/main/java/org/dspace/content/packager/AbstractMETSDisseminator.java b/dspace-api/src/main/java/org/dspace/content/packager/AbstractMETSDisseminator.java index 2517262158..7792c77552 100644 --- a/dspace-api/src/main/java/org/dspace/content/packager/AbstractMETSDisseminator.java +++ b/dspace-api/src/main/java/org/dspace/content/packager/AbstractMETSDisseminator.java @@ -84,6 +84,7 @@ import java.io.FileOutputStream; import org.apache.log4j.Logger; +import org.dspace.app.util.Util; import org.dspace.authorize.AuthorizeException; import org.dspace.authorize.AuthorizeManager; import org.dspace.content.Bitstream; @@ -286,7 +287,7 @@ public abstract class AbstractMETSDisseminator // map of extra streams to put in Zip (these are located during makeManifest()) MdStreamCache extraStreams = new MdStreamCache(); ZipOutputStream zip = new ZipOutputStream(pkg); - zip.setComment("METS archive created by DSpace METSDisseminationCrosswalk"); + zip.setComment("METS archive created by DSpace " + Util.getSourceVersion()); Mets manifest = makeManifest(context, dso, params, extraStreams); // copy extra (metadata, license, etc) bitstreams into zip, update manifest @@ -714,7 +715,7 @@ public abstract class AbstractMETSDisseminator Mets mets = new Mets(); // this ID should be globally unique - mets.setID("dspace"+Utils.generateKey()); + mets.setID("dspace" + dso.hashCode()); // identifies the object described by this document mets.setOBJID(makePersistentID(dso)); diff --git a/dspace-api/src/main/java/org/dspace/content/packager/DSpaceAIPDisseminator.java b/dspace-api/src/main/java/org/dspace/content/packager/DSpaceAIPDisseminator.java index e849ed2516..ba2291e517 100644 --- a/dspace-api/src/main/java/org/dspace/content/packager/DSpaceAIPDisseminator.java +++ b/dspace-api/src/main/java/org/dspace/content/packager/DSpaceAIPDisseminator.java @@ -42,11 +42,11 @@ package org.dspace.content.packager; import java.io.IOException; import java.sql.SQLException; -import java.util.Date; import java.util.List; import java.util.ArrayList; import org.apache.log4j.Logger; +import org.dspace.app.util.Util; import org.dspace.authorize.AuthorizeException; import org.dspace.content.Bitstream; import org.dspace.content.Bundle; @@ -188,13 +188,15 @@ public class DSpaceAIPDisseminator { MetsHdr metsHdr = new MetsHdr(); - // date the METS package/manifest was created. - metsHdr.setCREATEDATE(new Date()); + // Note: we specifically do not add a CREATEDATE to + // as for AIPs we want md5 checksums to be identical if no content + // has changed. Adding a CREATEDATE changes checksum each time. + // Add a LASTMODDATE for items if (dso.getType() == Constants.ITEM) metsHdr.setLASTMODDATE(((Item)dso).getLastModified()); - // Agent - name custodian, the DSpace Archive, by handle. + // Agent Custodian - name custodian, the DSpace Archive, by handle. Agent agent = new Agent(); agent.setROLE(Role.CUSTODIAN); agent.setTYPE(Type.OTHER); @@ -204,6 +206,18 @@ public class DSpaceAIPDisseminator .add(new PCData(Site.getSiteHandle())); agent.getContent().add(name); metsHdr.getContent().add(agent); + + // Agent Creator - name creator, which is a specific version of DSpace. + Agent agentCreator = new Agent(); + agentCreator.setROLE(Role.CREATOR); + agentCreator.setTYPE(Type.OTHER); + agentCreator.setOTHERTYPE("DSpace Software"); + Name creatorName = new Name(); + creatorName.getContent() + .add(new PCData("DSpace " + Util.getSourceVersion())); + agentCreator.getContent().add(creatorName); + metsHdr.getContent().add(agentCreator); + return metsHdr; }