Fix for SF bug [1730606] Restricted Items metadata exposed via OAI

git-svn-id: http://scm.dspace.org/svn/repo/branches/dspace-1_5_x@3346 9c30dcfa-912a-0410-8fc2-9e0234be79fd
This commit is contained in:
Stuart Lewis
2008-12-23 19:29:52 +00:00
parent d4e558acef
commit 09dcb5219b
6 changed files with 43 additions and 7 deletions

View File

@@ -389,6 +389,7 @@ public class Subscribe
Collection c = (Collection) collections.get(i);
try {
boolean includeAll = ConfigurationManager.getBooleanProperty("harvest.includerestricted.subscription", true);
List itemInfos = Harvest.harvest(context, c, startDate, endDate, 0, // Limit
// and
// offset
@@ -397,7 +398,8 @@ public class Subscribe
// everything
0, true, // Need item objects
false, // But not containers
false); // Or withdrawals
false, // Or withdrawals
includeAll);
if (ConfigurationManager.getBooleanProperty("eperson.subscription.onlynew", false))
{

View File

@@ -60,6 +60,8 @@ import org.dspace.handle.HandleManager;
import org.dspace.storage.rdbms.DatabaseManager;
import org.dspace.storage.rdbms.TableRow;
import org.dspace.storage.rdbms.TableRowIterator;
import org.dspace.authorize.AuthorizeManager;
import org.dspace.eperson.Group;
/**
* Utility class for extracting information about items, possibly just within a
@@ -111,14 +113,16 @@ public class Harvest
* @param withdrawn
* If <code>true</code>, information about withdrawn items is
* included
* @param nonAnon
* If items without anonymous access should be included or not
* @return List of <code>HarvestedItemInfo</code> objects
* @throws SQLException
* @throws ParseException If the date is not in a supported format
*/
public static List harvest(Context context, DSpaceObject scope,
String startDate, String endDate, int offset, int limit,
boolean items, boolean collections, boolean withdrawn)
throws SQLException, ParseException
boolean items, boolean collections, boolean withdrawn,
boolean nonAnon) throws SQLException, ParseException
{
// Put together our query. Note there is no need for an
@@ -261,7 +265,22 @@ public class Harvest
itemInfo.item = Item.find(context, itemInfo.itemID);
}
infoObjects.add(itemInfo);
if (nonAnon)
{
infoObjects.add(itemInfo);
} else
{
Group[] authorizedGroups = AuthorizeManager.getAuthorizedGroups(context, itemInfo.item, Constants.READ);
boolean added = false;
for (int i = 0; i < authorizedGroups.length; i++)
{
if ((authorizedGroups[i].getID() == 0) && (!added))
{
infoObjects.add(itemInfo);
added = true;
}
}
}
}
index++;