mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-18 15:33:09 +00:00
Adding another minor option to the AIP Disseminator (DS-466). There's now also an 'updatedAfter' flag, which allows for a very basic form of 'incremental backup'. When this flag is used, an ISO-8601 date must be specified. When used, the AIP Disseminator will only export Item AIPs for items that have changed since that date (it will still always export all Community & Collection AIPs, as there's no last-modified date for them). This new option has also been already documented in the AIP Backup & Restore docs at: https://wiki.duraspace.org/display/DSDOC/AipBackupRestore
git-svn-id: http://scm.dspace.org/svn/repo/dspace/trunk@5696 9c30dcfa-912a-0410-8fc2-9e0234be79fd
This commit is contained in:
@@ -114,73 +114,77 @@ public abstract class AbstractPackageDisseminator
|
|||||||
//try to disseminate the first object using provided PackageDisseminator
|
//try to disseminate the first object using provided PackageDisseminator
|
||||||
disseminate(context, dso, params, pkgFile);
|
disseminate(context, dso, params, pkgFile);
|
||||||
|
|
||||||
//add to list of successfully disseminated packages
|
//check if package was disseminated
|
||||||
addToPackageList(pkgFile);
|
if(pkgFile.exists())
|
||||||
|
|
||||||
//We can only recursively disseminate non-Items
|
|
||||||
//(NOTE: Items have no children, as Bitstreams/Bundles are created from Item packages)
|
|
||||||
if(dso.getType()!=Constants.ITEM)
|
|
||||||
{
|
{
|
||||||
//Determine where first file package was disseminated to, as all
|
//add to list of successfully disseminated packages
|
||||||
//others will be written to same directory
|
addToPackageList(pkgFile);
|
||||||
String pkgDirectory = pkgFile.getCanonicalFile().getParent();
|
|
||||||
if(!pkgDirectory.endsWith(File.separator))
|
//We can only recursively disseminate non-Items
|
||||||
|
//(NOTE: Items have no children, as Bitstreams/Bundles are created from Item packages)
|
||||||
|
if(dso.getType()!=Constants.ITEM)
|
||||||
{
|
{
|
||||||
pkgDirectory += File.separator;
|
//Determine where first file package was disseminated to, as all
|
||||||
}
|
//others will be written to same directory
|
||||||
String fileExtension = PackageUtils.getFileExtension(pkgFile.getName());
|
String pkgDirectory = pkgFile.getCanonicalFile().getParent();
|
||||||
|
if(!pkgDirectory.endsWith(File.separator))
|
||||||
|
{
|
||||||
|
pkgDirectory += File.separator;
|
||||||
|
}
|
||||||
|
String fileExtension = PackageUtils.getFileExtension(pkgFile.getName());
|
||||||
|
|
||||||
//recursively disseminate content, based on object type
|
//recursively disseminate content, based on object type
|
||||||
switch (dso.getType())
|
switch (dso.getType())
|
||||||
{
|
{
|
||||||
case Constants.COLLECTION :
|
case Constants.COLLECTION :
|
||||||
//Also find all Items in this Collection and disseminate
|
//Also find all Items in this Collection and disseminate
|
||||||
Collection collection = (Collection) dso;
|
Collection collection = (Collection) dso;
|
||||||
ItemIterator iterator = collection.getAllItems();
|
ItemIterator iterator = collection.getAllItems();
|
||||||
while(iterator.hasNext())
|
while(iterator.hasNext())
|
||||||
{
|
{
|
||||||
Item item = iterator.next();
|
Item item = iterator.next();
|
||||||
|
|
||||||
//disseminate all items (recursively!)
|
//disseminate all items (recursively!)
|
||||||
String childFileName = pkgDirectory + PackageUtils.getPackageName(item, fileExtension);
|
String childFileName = pkgDirectory + PackageUtils.getPackageName(item, fileExtension);
|
||||||
disseminateAll(context, item, params, new File(childFileName));
|
disseminateAll(context, item, params, new File(childFileName));
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case Constants.COMMUNITY :
|
case Constants.COMMUNITY :
|
||||||
//Also find all SubCommunities in this Community and disseminate
|
//Also find all SubCommunities in this Community and disseminate
|
||||||
Community community = (Community) dso;
|
Community community = (Community) dso;
|
||||||
Community[] subcommunities = community.getSubcommunities();
|
Community[] subcommunities = community.getSubcommunities();
|
||||||
for(int i=0; i<subcommunities.length; i++)
|
for(int i=0; i<subcommunities.length; i++)
|
||||||
{
|
{
|
||||||
//disseminate all sub-communities (recursively!)
|
//disseminate all sub-communities (recursively!)
|
||||||
String childFileName = pkgDirectory + PackageUtils.getPackageName(subcommunities[i], fileExtension);
|
String childFileName = pkgDirectory + PackageUtils.getPackageName(subcommunities[i], fileExtension);
|
||||||
disseminateAll(context, subcommunities[i], params, new File(childFileName));
|
disseminateAll(context, subcommunities[i], params, new File(childFileName));
|
||||||
}
|
}
|
||||||
|
|
||||||
//Also find all Collections in this Community and disseminate
|
//Also find all Collections in this Community and disseminate
|
||||||
Collection[] collections = community.getCollections();
|
Collection[] collections = community.getCollections();
|
||||||
for(int i=0; i<collections.length; i++)
|
for(int i=0; i<collections.length; i++)
|
||||||
{
|
{
|
||||||
//disseminate all collections (recursively!)
|
//disseminate all collections (recursively!)
|
||||||
String childFileName = pkgDirectory + PackageUtils.getPackageName(collections[i], fileExtension);
|
String childFileName = pkgDirectory + PackageUtils.getPackageName(collections[i], fileExtension);
|
||||||
disseminateAll(context, collections[i], params, new File(childFileName));
|
disseminateAll(context, collections[i], params, new File(childFileName));
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case Constants.SITE :
|
case Constants.SITE :
|
||||||
//Also find all top-level Communities and disseminate
|
//Also find all top-level Communities and disseminate
|
||||||
Community[] topCommunities = Community.findAllTop(context);
|
Community[] topCommunities = Community.findAllTop(context);
|
||||||
for(int i=0; i<topCommunities.length; i++)
|
for(int i=0; i<topCommunities.length; i++)
|
||||||
{
|
{
|
||||||
//disseminate all top-level communities (recursively!)
|
//disseminate all top-level communities (recursively!)
|
||||||
String childFileName = pkgDirectory + PackageUtils.getPackageName(topCommunities[i], fileExtension);
|
String childFileName = pkgDirectory + PackageUtils.getPackageName(topCommunities[i], fileExtension);
|
||||||
disseminateAll(context, topCommunities[i], params, new File(childFileName));
|
disseminateAll(context, topCommunities[i], params, new File(childFileName));
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}//end switch
|
}//end switch
|
||||||
}//end if not an Item
|
}//end if not an Item
|
||||||
|
}//end if pkgFile exists
|
||||||
|
|
||||||
//return list of all successfully disseminated packages
|
//return list of all successfully disseminated packages
|
||||||
return getPackageList();
|
return getPackageList();
|
||||||
|
@@ -76,6 +76,9 @@ import edu.harvard.hul.ois.mets.Type;
|
|||||||
import edu.harvard.hul.ois.mets.helper.MetsException;
|
import edu.harvard.hul.ois.mets.helper.MetsException;
|
||||||
import edu.harvard.hul.ois.mets.helper.PCData;
|
import edu.harvard.hul.ois.mets.helper.PCData;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
|
import java.text.ParseException;
|
||||||
|
import java.util.Date;
|
||||||
|
import org.dspace.core.Utils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Subclass of the METS packager framework to disseminate a DSpace
|
* Subclass of the METS packager framework to disseminate a DSpace
|
||||||
@@ -155,8 +158,32 @@ public class DSpaceAIPDisseminator extends AbstractMETSDisseminator
|
|||||||
//Before disseminating anything, save the passed in PackageParameters, so they can be used by all methods
|
//Before disseminating anything, save the passed in PackageParameters, so they can be used by all methods
|
||||||
disseminateParams = params;
|
disseminateParams = params;
|
||||||
|
|
||||||
//just do a normal dissemination as specified by AbstractMETSDisseminator
|
boolean disseminate = true; //by default, always disseminate
|
||||||
super.disseminate(context, dso, params, pkgFile);
|
|
||||||
|
//if user specified to only disseminate objects updated *after* a specific date
|
||||||
|
// (Note: this only works for Items right now, as DSpace doesn't store a
|
||||||
|
// last modified date for Collections or Communities)
|
||||||
|
if(disseminateParams.containsKey("updatedAfter") && dso.getType()==Constants.ITEM)
|
||||||
|
{
|
||||||
|
Date afterDate = Utils.parseISO8601Date(disseminateParams.getProperty("updatedAfter"));
|
||||||
|
|
||||||
|
//if null is returned, we couldn't parse the date!
|
||||||
|
if(afterDate==null)
|
||||||
|
throw new IOException("Invalid date passed in via 'updatedAfter' option. Date must be in ISO-8601 format, and include both a day and time (e.g. 2010-01-01T00:00:00).");
|
||||||
|
|
||||||
|
//check when this item was last modified.
|
||||||
|
Item i = (Item) dso;
|
||||||
|
if(i.getLastModified().after(afterDate))
|
||||||
|
disseminate = true;
|
||||||
|
else
|
||||||
|
disseminate = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(disseminate)
|
||||||
|
{
|
||||||
|
//just do a normal dissemination as specified by AbstractMETSDisseminator
|
||||||
|
super.disseminate(context, dso, params, pkgFile);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user