mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-17 06:53:09 +00:00
Add logic for resetting embargo when restoring from an AIP
git-svn-id: http://scm.dspace.org/svn/repo/dspace/trunk@5930 9c30dcfa-912a-0410-8fc2-9e0234be79fd
This commit is contained in:
@@ -87,7 +87,16 @@ public class EmbargoManager
|
|||||||
throws SQLException, AuthorizeException, IOException
|
throws SQLException, AuthorizeException, IOException
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
String slift = lift.toString();
|
// if lift is null, we might be restoring an item from an AIP
|
||||||
|
DCDate myLift = lift;
|
||||||
|
if (myLift == null)
|
||||||
|
{
|
||||||
|
if ((myLift = recoverEmbargoDate(item)) == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
String slift = myLift.toString();
|
||||||
boolean ignoreAuth = context.ignoreAuthorization();
|
boolean ignoreAuth = context.ignoreAuthorization();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -408,4 +417,21 @@ public class EmbargoManager
|
|||||||
String sa[] = field.split("\\.", 3);
|
String sa[] = field.split("\\.", 3);
|
||||||
return sa.length > 2 ? sa[2] : null;
|
return sa.length > 2 ? sa[2] : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// return the lift date assigned when embargo was set, or null, if either:
|
||||||
|
// it was never under embargo, or the lift date has passed.
|
||||||
|
private static DCDate recoverEmbargoDate(Item item) {
|
||||||
|
DCDate liftDate = null;
|
||||||
|
DCValue lift[] = item.getMetadata(lift_schema, lift_element, lift_qualifier, Item.ANY);
|
||||||
|
if (lift.length > 0)
|
||||||
|
{
|
||||||
|
liftDate = new DCDate(lift[0].value);
|
||||||
|
// sanity check: do not allow an embargo lift date in the past.
|
||||||
|
if (liftDate.toDate().before(new Date()))
|
||||||
|
{
|
||||||
|
liftDate = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return liftDate;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user