Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.Enumeration;
import java.util.GregorianCalendar;
Expand Down Expand Up @@ -2592,6 +2593,14 @@ protected void processEmbargoMetadata(Context c, Item item) throws SQLException,
". Embargo will not be applied.");
return;
}

// Resource policy start date = embargoend + 1 day
// The embargo end date is the last day of the embargo,
// so the file becomes accessible the day after.
Calendar cal = Calendar.getInstance();
cal.setTime(endDate);
cal.add(Calendar.DAY_OF_MONTH, 1);
endDate = cal.getTime();
} catch (Exception e) {
logError("ERROR: Failed to parse embargo end date: " + embargoEndDateStr +
". Error: " + e.getMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@
public class EmbargoImportIT extends AbstractIntegrationTestWithDatabase {

private static final String EMBARGOEND_DATE_FUTURE = "2026-06-30";
// The resource policy start date should be embargoend + 1 day
private static final String EXPECTED_POLICY_START_DATE = "2026-07-01";
private static final String EMBARGOEND_DATE_PAST = "2020-01-01";
private static final String ITEM_TITLE = "Test Embargo Item";

Expand Down Expand Up @@ -171,10 +173,10 @@ public void testStandardEmbargoImport() throws Exception {
assertNotNull("Should have embargo policy for Anonymous group", embargoPolicy);
assertNotNull("Embargo policy should have start date", embargoPolicy.getStartDate());

// Verify start date matches embargo end date
// Verify start date is embargoend + 1 day (file becomes accessible day after embargo ends)
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
assertEquals("Embargo start date should match embargoend metadata",
EMBARGOEND_DATE_FUTURE, sdf.format(embargoPolicy.getStartDate()));
assertEquals("Embargo policy start date should be embargoend + 1 day",
EXPECTED_POLICY_START_DATE, sdf.format(embargoPolicy.getStartDate()));
}

/**
Expand Down Expand Up @@ -360,8 +362,8 @@ public void testMultipleBitstreamsEmbargo() throws Exception {
assertNotNull("Each embargo policy should have start date", embargoPolicy.getStartDate());

SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
assertEquals("Each embargo start date should match embargoend metadata",
EMBARGOEND_DATE_FUTURE, sdf.format(embargoPolicy.getStartDate()));
assertEquals("Each embargo start date should be embargoend + 1 day",
EXPECTED_POLICY_START_DATE, sdf.format(embargoPolicy.getStartDate()));
}
}
}
Loading