mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-17 15:03:18 +00:00
DefaultAccessStatusHelper: getEmbargoFromItem return null embargo if status than embargo
This commit is contained in:
@@ -22,6 +22,7 @@ public interface AccessStatusHelper {
|
|||||||
*
|
*
|
||||||
* @param context the DSpace context
|
* @param context the DSpace context
|
||||||
* @param item the item
|
* @param item the item
|
||||||
|
* @param threshold the embargo threshold date
|
||||||
* @return an access status value
|
* @return an access status value
|
||||||
* @throws SQLException An exception that provides information on a database access error or other errors.
|
* @throws SQLException An exception that provides information on a database access error or other errors.
|
||||||
*/
|
*/
|
||||||
@@ -33,8 +34,9 @@ public interface AccessStatusHelper {
|
|||||||
*
|
*
|
||||||
* @param context the DSpace context
|
* @param context the DSpace context
|
||||||
* @param item the item to check for embargo information
|
* @param item the item to check for embargo information
|
||||||
|
* @param threshold the embargo threshold date
|
||||||
* @return an embargo date
|
* @return an embargo date
|
||||||
* @throws SQLException An exception that provides information on a database access error or other errors.
|
* @throws SQLException An exception that provides information on a database access error or other errors.
|
||||||
*/
|
*/
|
||||||
public String getEmbargoFromItem(Context context, Item item) throws SQLException;
|
public String getEmbargoFromItem(Context context, Item item, Date threshold) throws SQLException;
|
||||||
}
|
}
|
||||||
|
@@ -70,6 +70,6 @@ public class AccessStatusServiceImpl implements AccessStatusService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getEmbargoFromItem(Context context, Item item) throws SQLException {
|
public String getEmbargoFromItem(Context context, Item item) throws SQLException {
|
||||||
return helper.getEmbargoFromItem(context, item);
|
return helper.getEmbargoFromItem(context, item, forever_date);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -173,11 +173,14 @@ public class DefaultAccessStatusHelper implements AccessStatusHelper {
|
|||||||
* @return an access status value
|
* @return an access status value
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getEmbargoFromItem(Context context, Item item)
|
public String getEmbargoFromItem(Context context, Item item, Date threshold)
|
||||||
throws SQLException {
|
throws SQLException {
|
||||||
Date embargoedDate;
|
Date embargoDate;
|
||||||
|
|
||||||
if (item == null) {
|
// If Item status is not "embargo" then return a null embargo date.
|
||||||
|
String accessStatus = getAccessStatusFromItem(context, item, threshold);
|
||||||
|
|
||||||
|
if (item == null || !accessStatus.equals(EMBARGO)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
// Consider only the original bundles.
|
// Consider only the original bundles.
|
||||||
@@ -202,9 +205,9 @@ public class DefaultAccessStatusHelper implements AccessStatusHelper {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
embargoedDate = this.retrieveShortestEmbargo(context, bitstream);
|
embargoDate = this.retrieveShortestEmbargo(context, bitstream);
|
||||||
|
|
||||||
return embargoedDate != null ? embargoedDate.toString() : null;
|
return embargoDate != null ? embargoDate.toString() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -274,7 +274,7 @@ public class DefaultAccessStatusHelperTest extends AbstractUnitTest {
|
|||||||
context.restoreAuthSystemState();
|
context.restoreAuthSystemState();
|
||||||
String status = helper.getAccessStatusFromItem(context, itemWithEmbargo, threshold);
|
String status = helper.getAccessStatusFromItem(context, itemWithEmbargo, threshold);
|
||||||
assertThat("testWithEmbargo 0", status, equalTo(DefaultAccessStatusHelper.EMBARGO));
|
assertThat("testWithEmbargo 0", status, equalTo(DefaultAccessStatusHelper.EMBARGO));
|
||||||
String embargoDate = helper.getEmbargoFromItem(context, itemWithEmbargo);
|
String embargoDate = helper.getEmbargoFromItem(context, itemWithEmbargo, threshold);
|
||||||
assertThat("testWithEmbargo 1", embargoDate, equalTo(policy.getStartDate().toString()));
|
assertThat("testWithEmbargo 1", embargoDate, equalTo(policy.getStartDate().toString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -393,7 +393,7 @@ public class DefaultAccessStatusHelperTest extends AbstractUnitTest {
|
|||||||
context.restoreAuthSystemState();
|
context.restoreAuthSystemState();
|
||||||
String status = helper.getAccessStatusFromItem(context, itemWithPrimaryAndMultipleBitstreams, threshold);
|
String status = helper.getAccessStatusFromItem(context, itemWithPrimaryAndMultipleBitstreams, threshold);
|
||||||
assertThat("testWithPrimaryAndMultipleBitstreams 0", status, equalTo(DefaultAccessStatusHelper.EMBARGO));
|
assertThat("testWithPrimaryAndMultipleBitstreams 0", status, equalTo(DefaultAccessStatusHelper.EMBARGO));
|
||||||
String embargoDate = helper.getEmbargoFromItem(context, itemWithPrimaryAndMultipleBitstreams);
|
String embargoDate = helper.getEmbargoFromItem(context, itemWithPrimaryAndMultipleBitstreams, threshold);
|
||||||
assertThat("testWithPrimaryAndMultipleBitstreams 1", embargoDate, equalTo(policy.getStartDate().toString()));
|
assertThat("testWithPrimaryAndMultipleBitstreams 1", embargoDate, equalTo(policy.getStartDate().toString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -424,7 +424,7 @@ public class DefaultAccessStatusHelperTest extends AbstractUnitTest {
|
|||||||
context.restoreAuthSystemState();
|
context.restoreAuthSystemState();
|
||||||
String status = helper.getAccessStatusFromItem(context, itemWithoutPrimaryAndMultipleBitstreams, threshold);
|
String status = helper.getAccessStatusFromItem(context, itemWithoutPrimaryAndMultipleBitstreams, threshold);
|
||||||
assertThat("testWithNoPrimaryAndMultipleBitstreams 0", status, equalTo(DefaultAccessStatusHelper.OPEN_ACCESS));
|
assertThat("testWithNoPrimaryAndMultipleBitstreams 0", status, equalTo(DefaultAccessStatusHelper.OPEN_ACCESS));
|
||||||
String embargoDate = helper.getEmbargoFromItem(context, itemWithEmbargo);
|
String embargoDate = helper.getEmbargoFromItem(context, itemWithEmbargo, threshold);
|
||||||
assertThat("testWithNoPrimaryAndMultipleBitstreams 1", embargoDate, equalTo(null));
|
assertThat("testWithNoPrimaryAndMultipleBitstreams 1", embargoDate, equalTo(null));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user