mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-17 06:53:09 +00:00
Add missing close() calls to use of TableRowIterator, also add close() to ItemIterator (to close underlying TableRowIterator)
git-svn-id: http://scm.dspace.org/svn/repo/branches/dspace-1_5_x@3038 9c30dcfa-912a-0410-8fc2-9e0234be79fd
This commit is contained in:
@@ -259,9 +259,16 @@ public class ItemExport {
|
|||||||
|
|
||||||
// it's a collection, so do a bunch of items
|
// it's a collection, so do a bunch of items
|
||||||
ItemIterator i = mycollection.getItems();
|
ItemIterator i = mycollection.getItems();
|
||||||
|
try
|
||||||
exportItem(c, i, destDirName, seqStart);
|
{
|
||||||
}
|
exportItem(c, i, destDirName, seqStart);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (i != null)
|
||||||
|
i.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
c.complete();
|
c.complete();
|
||||||
}
|
}
|
||||||
@@ -623,40 +630,50 @@ public class ItemExport {
|
|||||||
for (Collection collection : collections) {
|
for (Collection collection : collections) {
|
||||||
// get all the items in each collection
|
// get all the items in each collection
|
||||||
ItemIterator iitems = collection.getItems();
|
ItemIterator iitems = collection.getItems();
|
||||||
while (iitems.hasNext()) {
|
try {
|
||||||
Item item = iitems.next();
|
while (iitems.hasNext()) {
|
||||||
// get all the bundles in the item
|
Item item = iitems.next();
|
||||||
Bundle[] bundles = item.getBundles();
|
// get all the bundles in the item
|
||||||
for (Bundle bundle : bundles) {
|
Bundle[] bundles = item.getBundles();
|
||||||
// get all the bitstreams in each bundle
|
for (Bundle bundle : bundles) {
|
||||||
Bitstream[] bitstreams = bundle.getBitstreams();
|
// get all the bitstreams in each bundle
|
||||||
for (Bitstream bit : bitstreams) {
|
Bitstream[] bitstreams = bundle.getBitstreams();
|
||||||
// add up the size
|
for (Bitstream bit : bitstreams) {
|
||||||
size += bit.getSize();
|
// add up the size
|
||||||
}
|
size += bit.getSize();
|
||||||
}
|
}
|
||||||
items.add(item.getID());
|
}
|
||||||
}
|
items.add(item.getID());
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
if (iitems != null)
|
||||||
|
iitems.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
} else if (dso.getType() == Constants.COLLECTION) {
|
} else if (dso.getType() == Constants.COLLECTION) {
|
||||||
Collection collection = (Collection) dso;
|
Collection collection = (Collection) dso;
|
||||||
// get all the items in the collection
|
// get all the items in the collection
|
||||||
ItemIterator iitems = collection.getItems();
|
ItemIterator iitems = collection.getItems();
|
||||||
while (iitems.hasNext()) {
|
try {
|
||||||
Item item = iitems.next();
|
while (iitems.hasNext()) {
|
||||||
// get all thebundles in the item
|
Item item = iitems.next();
|
||||||
Bundle[] bundles = item.getBundles();
|
// get all thebundles in the item
|
||||||
for (Bundle bundle : bundles) {
|
Bundle[] bundles = item.getBundles();
|
||||||
// get all the bitstreams in the bundle
|
for (Bundle bundle : bundles) {
|
||||||
Bitstream[] bitstreams = bundle.getBitstreams();
|
// get all the bitstreams in the bundle
|
||||||
for (Bitstream bit : bitstreams) {
|
Bitstream[] bitstreams = bundle.getBitstreams();
|
||||||
// add up the size
|
for (Bitstream bit : bitstreams) {
|
||||||
size += bit.getSize();
|
// add up the size
|
||||||
}
|
size += bit.getSize();
|
||||||
}
|
}
|
||||||
items.add(item.getID());
|
}
|
||||||
}
|
items.add(item.getID());
|
||||||
} else if (dso.getType() == Constants.ITEM) {
|
}
|
||||||
|
} finally {
|
||||||
|
if (iitems != null)
|
||||||
|
iitems.close();
|
||||||
|
}
|
||||||
|
} else if (dso.getType() == Constants.ITEM) {
|
||||||
Item item = (Item) dso;
|
Item item = (Item) dso;
|
||||||
// get all the bundles in the item
|
// get all the bundles in the item
|
||||||
Bundle[] bundles = item.getBundles();
|
Bundle[] bundles = item.getBundles();
|
||||||
@@ -699,12 +716,13 @@ public class ItemExport {
|
|||||||
Thread go = new Thread() {
|
Thread go = new Thread() {
|
||||||
public void run() {
|
public void run() {
|
||||||
Context context;
|
Context context;
|
||||||
try {
|
ItemIterator iitems = null;
|
||||||
|
try {
|
||||||
// create a new dspace context
|
// create a new dspace context
|
||||||
context = new Context();
|
context = new Context();
|
||||||
// ignore auths
|
// ignore auths
|
||||||
context.setIgnoreAuthorization(true);
|
context.setIgnoreAuthorization(true);
|
||||||
ItemIterator iitems = new ItemIterator(context, items);
|
iitems = new ItemIterator(context, items);
|
||||||
|
|
||||||
String fileName = assembleFileName("item", eperson, new Date());
|
String fileName = assembleFileName("item", eperson, new Date());
|
||||||
String workDir = getExportWorkDirectory()
|
String workDir = getExportWorkDirectory()
|
||||||
@@ -747,7 +765,10 @@ public class ItemExport {
|
|||||||
// wont throw here
|
// wont throw here
|
||||||
}
|
}
|
||||||
throw new RuntimeException(e1);
|
throw new RuntimeException(e1);
|
||||||
}
|
} finally {
|
||||||
|
if (iitems != null)
|
||||||
|
iitems.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@@ -420,9 +420,17 @@ public class MediaFilterManager
|
|||||||
{
|
{
|
||||||
//otherwise, just find every item and process
|
//otherwise, just find every item and process
|
||||||
ItemIterator i = Item.findAll(c);
|
ItemIterator i = Item.findAll(c);
|
||||||
while (i.hasNext() && processed < max2Process)
|
try
|
||||||
{
|
{
|
||||||
applyFiltersItem(c, i.next());
|
while (i.hasNext() && processed < max2Process)
|
||||||
|
{
|
||||||
|
applyFiltersItem(c, i.next());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (i != null)
|
||||||
|
i.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -453,9 +461,17 @@ public class MediaFilterManager
|
|||||||
if(!inSkipList(collection.getHandle()))
|
if(!inSkipList(collection.getHandle()))
|
||||||
{
|
{
|
||||||
ItemIterator i = collection.getItems();
|
ItemIterator i = collection.getItems();
|
||||||
while (i.hasNext() && processed < max2Process)
|
try
|
||||||
{
|
{
|
||||||
applyFiltersItem(c, i.next());
|
while (i.hasNext() && processed < max2Process)
|
||||||
|
{
|
||||||
|
applyFiltersItem(c, i.next());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (i != null)
|
||||||
|
i.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -178,42 +178,49 @@ public class METSExport
|
|||||||
}
|
}
|
||||||
|
|
||||||
ItemIterator items = null;
|
ItemIterator items = null;
|
||||||
|
try
|
||||||
if (line.hasOption('c'))
|
|
||||||
{
|
{
|
||||||
String handle = getHandleArg(line.getOptionValue('c'));
|
if (line.hasOption('c'))
|
||||||
|
|
||||||
// Exporting a collection's worth of items
|
|
||||||
DSpaceObject o = HandleManager.resolveToObject(context, handle);
|
|
||||||
|
|
||||||
if ((o != null) && o instanceof Collection)
|
|
||||||
{
|
{
|
||||||
items = ((Collection) o).getItems();
|
String handle = getHandleArg(line.getOptionValue('c'));
|
||||||
|
|
||||||
|
// Exporting a collection's worth of items
|
||||||
|
DSpaceObject o = HandleManager.resolveToObject(context, handle);
|
||||||
|
|
||||||
|
if ((o != null) && o instanceof Collection)
|
||||||
|
{
|
||||||
|
items = ((Collection) o).getItems();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
System.err.println(line.getOptionValue('c')
|
||||||
|
+ " is not a valid collection Handle");
|
||||||
|
System.exit(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
if (line.hasOption('a'))
|
||||||
{
|
{
|
||||||
System.err.println(line.getOptionValue('c')
|
items = Item.findAll(context);
|
||||||
+ " is not a valid collection Handle");
|
}
|
||||||
|
|
||||||
|
if (items == null)
|
||||||
|
{
|
||||||
|
System.err.println("Nothing to export specified!");
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (line.hasOption('a'))
|
while (items.hasNext())
|
||||||
|
{
|
||||||
|
writeAIP(context, items.next(), dest);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
{
|
{
|
||||||
items = Item.findAll(context);
|
if (items != null)
|
||||||
|
items.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (items == null)
|
|
||||||
{
|
|
||||||
System.err.println("Nothing to export specified!");
|
|
||||||
System.exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
while (items.hasNext())
|
|
||||||
{
|
|
||||||
writeAIP(context, items.next(), dest);
|
|
||||||
}
|
|
||||||
|
|
||||||
context.abort();
|
context.abort();
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
}
|
}
|
||||||
|
@@ -234,41 +234,49 @@ public class GenerateSitemaps
|
|||||||
}
|
}
|
||||||
|
|
||||||
ItemIterator allItems = Item.findAll(c);
|
ItemIterator allItems = Item.findAll(c);
|
||||||
int itemCount = 0;
|
try
|
||||||
|
|
||||||
while (allItems.hasNext())
|
|
||||||
{
|
{
|
||||||
Item i = allItems.next();
|
int itemCount = 0;
|
||||||
String url = handleURLStem + i.getHandle();
|
|
||||||
Date lastMod = i.getLastModified();
|
while (allItems.hasNext())
|
||||||
|
{
|
||||||
|
Item i = allItems.next();
|
||||||
|
String url = handleURLStem + i.getHandle();
|
||||||
|
Date lastMod = i.getLastModified();
|
||||||
|
|
||||||
|
if (makeHTMLMap)
|
||||||
|
html.addURL(url, lastMod);
|
||||||
|
if (makeSitemapOrg)
|
||||||
|
sitemapsOrg.addURL(url, lastMod);
|
||||||
|
i.decache();
|
||||||
|
|
||||||
|
itemCount++;
|
||||||
|
}
|
||||||
|
|
||||||
if (makeHTMLMap)
|
if (makeHTMLMap)
|
||||||
html.addURL(url, lastMod);
|
{
|
||||||
|
int files = html.finish();
|
||||||
|
log.info(LogManager.getHeader(c, "write_sitemap",
|
||||||
|
"type=html,num_files=" + files + ",communities="
|
||||||
|
+ comms.length + ",collections=" + colls.length
|
||||||
|
+ ",items=" + itemCount));
|
||||||
|
}
|
||||||
|
|
||||||
if (makeSitemapOrg)
|
if (makeSitemapOrg)
|
||||||
sitemapsOrg.addURL(url, lastMod);
|
{
|
||||||
i.decache();
|
int files = sitemapsOrg.finish();
|
||||||
|
log.info(LogManager.getHeader(c, "write_sitemap",
|
||||||
itemCount++;
|
"type=html,num_files=" + files + ",communities="
|
||||||
|
+ comms.length + ",collections=" + colls.length
|
||||||
|
+ ",items=" + itemCount));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
if (makeHTMLMap)
|
|
||||||
{
|
{
|
||||||
int files = html.finish();
|
if (allItems != null)
|
||||||
log.info(LogManager.getHeader(c, "write_sitemap",
|
allItems.close();
|
||||||
"type=html,num_files=" + files + ",communities="
|
|
||||||
+ comms.length + ",collections=" + colls.length
|
|
||||||
+ ",items=" + itemCount));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (makeSitemapOrg)
|
|
||||||
{
|
|
||||||
int files = sitemapsOrg.finish();
|
|
||||||
log.info(LogManager.getHeader(c, "write_sitemap",
|
|
||||||
"type=html,num_files=" + files + ",communities="
|
|
||||||
+ comms.length + ",collections=" + colls.length
|
|
||||||
+ ",items=" + itemCount));
|
|
||||||
}
|
|
||||||
|
|
||||||
c.abort();
|
c.abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -186,51 +186,19 @@ public class PolicySet
|
|||||||
Group group = Group.find(c, groupID);
|
Group group = Group.find(c, groupID);
|
||||||
|
|
||||||
ItemIterator i = collection.getItems();
|
ItemIterator i = collection.getItems();
|
||||||
|
try
|
||||||
if (contentType == Constants.ITEM)
|
|
||||||
{
|
{
|
||||||
// build list of all items in a collection
|
if (contentType == Constants.ITEM)
|
||||||
while (i.hasNext())
|
|
||||||
{
|
{
|
||||||
Item myitem = i.next();
|
// build list of all items in a collection
|
||||||
|
while (i.hasNext())
|
||||||
// is this a replace? delete policies first
|
|
||||||
if (isReplace || clearOnly)
|
|
||||||
{
|
{
|
||||||
AuthorizeManager.removeAllPolicies(c, myitem);
|
Item myitem = i.next();
|
||||||
}
|
|
||||||
|
|
||||||
if (!clearOnly)
|
|
||||||
{
|
|
||||||
// now add the policy
|
|
||||||
ResourcePolicy rp = ResourcePolicy.create(c);
|
|
||||||
|
|
||||||
rp.setResource(myitem);
|
|
||||||
rp.setAction(actionID);
|
|
||||||
rp.setGroup(group);
|
|
||||||
|
|
||||||
rp.update();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (contentType == Constants.BUNDLE)
|
|
||||||
{
|
|
||||||
// build list of all items in a collection
|
|
||||||
// build list of all bundles in those items
|
|
||||||
while (i.hasNext())
|
|
||||||
{
|
|
||||||
Item myitem = i.next();
|
|
||||||
|
|
||||||
Bundle[] bundles = myitem.getBundles();
|
|
||||||
|
|
||||||
for (int j = 0; j < bundles.length; j++)
|
|
||||||
{
|
|
||||||
Bundle t = bundles[j]; // t for target
|
|
||||||
|
|
||||||
// is this a replace? delete policies first
|
// is this a replace? delete policies first
|
||||||
if (isReplace || clearOnly)
|
if (isReplace || clearOnly)
|
||||||
{
|
{
|
||||||
AuthorizeManager.removeAllPolicies(c, t);
|
AuthorizeManager.removeAllPolicies(c, myitem);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!clearOnly)
|
if (!clearOnly)
|
||||||
@@ -238,7 +206,7 @@ public class PolicySet
|
|||||||
// now add the policy
|
// now add the policy
|
||||||
ResourcePolicy rp = ResourcePolicy.create(c);
|
ResourcePolicy rp = ResourcePolicy.create(c);
|
||||||
|
|
||||||
rp.setResource(t);
|
rp.setResource(myitem);
|
||||||
rp.setAction(actionID);
|
rp.setAction(actionID);
|
||||||
rp.setGroup(group);
|
rp.setGroup(group);
|
||||||
|
|
||||||
@@ -246,53 +214,92 @@ public class PolicySet
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
else if (contentType == Constants.BUNDLE)
|
||||||
else if (contentType == Constants.BITSTREAM)
|
|
||||||
{
|
|
||||||
// build list of all bitstreams in a collection
|
|
||||||
// iterate over items, bundles, get bitstreams
|
|
||||||
while (i.hasNext())
|
|
||||||
{
|
{
|
||||||
Item myitem = i.next();
|
// build list of all items in a collection
|
||||||
System.out.println("Item " + myitem.getID());
|
// build list of all bundles in those items
|
||||||
|
while (i.hasNext())
|
||||||
Bundle[] bundles = myitem.getBundles();
|
|
||||||
|
|
||||||
for (int j = 0; j < bundles.length; j++)
|
|
||||||
{
|
{
|
||||||
System.out.println("Bundle " + bundles[j].getID());
|
Item myitem = i.next();
|
||||||
|
|
||||||
Bitstream[] bitstreams = bundles[j].getBitstreams();
|
Bundle[] bundles = myitem.getBundles();
|
||||||
|
|
||||||
for (int k = 0; k < bitstreams.length; k++)
|
for (int j = 0; j < bundles.length; j++)
|
||||||
{
|
{
|
||||||
Bitstream t = bitstreams[k]; // t for target
|
Bundle t = bundles[j]; // t for target
|
||||||
|
|
||||||
if ( filter == null ||
|
// is this a replace? delete policies first
|
||||||
t.getName().indexOf( filter ) != -1 )
|
if (isReplace || clearOnly)
|
||||||
{
|
{
|
||||||
// is this a replace? delete policies first
|
AuthorizeManager.removeAllPolicies(c, t);
|
||||||
if (isReplace || clearOnly)
|
}
|
||||||
|
|
||||||
|
if (!clearOnly)
|
||||||
|
{
|
||||||
|
// now add the policy
|
||||||
|
ResourcePolicy rp = ResourcePolicy.create(c);
|
||||||
|
|
||||||
|
rp.setResource(t);
|
||||||
|
rp.setAction(actionID);
|
||||||
|
rp.setGroup(group);
|
||||||
|
|
||||||
|
rp.update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (contentType == Constants.BITSTREAM)
|
||||||
|
{
|
||||||
|
// build list of all bitstreams in a collection
|
||||||
|
// iterate over items, bundles, get bitstreams
|
||||||
|
while (i.hasNext())
|
||||||
|
{
|
||||||
|
Item myitem = i.next();
|
||||||
|
System.out.println("Item " + myitem.getID());
|
||||||
|
|
||||||
|
Bundle[] bundles = myitem.getBundles();
|
||||||
|
|
||||||
|
for (int j = 0; j < bundles.length; j++)
|
||||||
|
{
|
||||||
|
System.out.println("Bundle " + bundles[j].getID());
|
||||||
|
|
||||||
|
Bitstream[] bitstreams = bundles[j].getBitstreams();
|
||||||
|
|
||||||
|
for (int k = 0; k < bitstreams.length; k++)
|
||||||
|
{
|
||||||
|
Bitstream t = bitstreams[k]; // t for target
|
||||||
|
|
||||||
|
if ( filter == null ||
|
||||||
|
t.getName().indexOf( filter ) != -1 )
|
||||||
{
|
{
|
||||||
AuthorizeManager.removeAllPolicies(c, t);
|
// is this a replace? delete policies first
|
||||||
}
|
if (isReplace || clearOnly)
|
||||||
|
{
|
||||||
|
AuthorizeManager.removeAllPolicies(c, t);
|
||||||
|
}
|
||||||
|
|
||||||
if (!clearOnly)
|
if (!clearOnly)
|
||||||
{
|
{
|
||||||
// now add the policy
|
// now add the policy
|
||||||
ResourcePolicy rp = ResourcePolicy.create(c);
|
ResourcePolicy rp = ResourcePolicy.create(c);
|
||||||
|
|
||||||
rp.setResource(t);
|
rp.setResource(t);
|
||||||
rp.setAction(actionID);
|
rp.setAction(actionID);
|
||||||
rp.setGroup(group);
|
rp.setGroup(group);
|
||||||
|
|
||||||
rp.update();
|
rp.update();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (i != null)
|
||||||
|
i.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -259,27 +259,34 @@ public class BrowseCreateDAOOracle implements BrowseCreateDAO
|
|||||||
TableRowIterator tri = DatabaseManager.queryTable(context, table, "SELECT * FROM " + table + " WHERE item_id=?", itemID);
|
TableRowIterator tri = DatabaseManager.queryTable(context, table, "SELECT * FROM " + table + " WHERE item_id=?", itemID);
|
||||||
if (tri != null)
|
if (tri != null)
|
||||||
{
|
{
|
||||||
while (tri.hasNext())
|
try
|
||||||
{
|
{
|
||||||
TableRow tr = tri.next();
|
while (tri.hasNext())
|
||||||
|
|
||||||
// Check the item mappings to see if it contains this mapping
|
|
||||||
boolean itemIsMapped = false;
|
|
||||||
int trDistinctID = tr.getIntColumn("distinct_id");
|
|
||||||
for (int i = 0; i < distinctIDs.length; i++)
|
|
||||||
{
|
{
|
||||||
// Found this mapping
|
TableRow tr = tri.next();
|
||||||
if (distinctIDs[i] == trDistinctID)
|
|
||||||
{
|
|
||||||
// Flag it, and remove (-1) from the item mappings
|
|
||||||
itemIsMapped = true;
|
|
||||||
distinctIDs[i] = -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// The item is no longer mapped to this community, so remove the database record
|
// Check the item mappings to see if it contains this mapping
|
||||||
if (!itemIsMapped)
|
boolean itemIsMapped = false;
|
||||||
DatabaseManager.delete(context, tr);
|
int trDistinctID = tr.getIntColumn("distinct_id");
|
||||||
|
for (int i = 0; i < distinctIDs.length; i++)
|
||||||
|
{
|
||||||
|
// Found this mapping
|
||||||
|
if (distinctIDs[i] == trDistinctID)
|
||||||
|
{
|
||||||
|
// Flag it, and remove (-1) from the item mappings
|
||||||
|
itemIsMapped = true;
|
||||||
|
distinctIDs[i] = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// The item is no longer mapped to this community, so remove the database record
|
||||||
|
if (!itemIsMapped)
|
||||||
|
DatabaseManager.delete(context, tr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
tri.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -528,12 +535,12 @@ public class BrowseCreateDAOOracle implements BrowseCreateDAO
|
|||||||
{
|
{
|
||||||
distinctID = tri.next().getIntColumn("id");
|
distinctID = tri.next().getIntColumn("id");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (log.isDebugEnabled())
|
if (log.isDebugEnabled())
|
||||||
{
|
{
|
||||||
log.debug("getDistinctID: return=" + distinctID);
|
log.debug("getDistinctID: return=" + distinctID);
|
||||||
}
|
}
|
||||||
|
|
||||||
return distinctID;
|
return distinctID;
|
||||||
}
|
}
|
||||||
catch (SQLException e)
|
catch (SQLException e)
|
||||||
@@ -543,7 +550,8 @@ public class BrowseCreateDAOOracle implements BrowseCreateDAO
|
|||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
tri.close();
|
if (tri != null)
|
||||||
|
tri.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -568,27 +576,34 @@ public class BrowseCreateDAOOracle implements BrowseCreateDAO
|
|||||||
TableRowIterator tri = DatabaseManager.queryTable(context, "Communities2Item", "SELECT * FROM Communities2Item WHERE item_id=?", itemID);
|
TableRowIterator tri = DatabaseManager.queryTable(context, "Communities2Item", "SELECT * FROM Communities2Item WHERE item_id=?", itemID);
|
||||||
if (tri != null)
|
if (tri != null)
|
||||||
{
|
{
|
||||||
while (tri.hasNext())
|
try
|
||||||
{
|
{
|
||||||
TableRow tr = tri.next();
|
while (tri.hasNext())
|
||||||
|
|
||||||
// Check the item mappings to see if it contains this community mapping
|
|
||||||
boolean itemIsMapped = false;
|
|
||||||
int trCommID = tr.getIntColumn("community_id");
|
|
||||||
for (int i = 0; i < commID.length; i++)
|
|
||||||
{
|
{
|
||||||
// Found this community
|
TableRow tr = tri.next();
|
||||||
if (commID[i] == trCommID)
|
|
||||||
{
|
|
||||||
// Flag it, and remove (-1) from the item mappings
|
|
||||||
itemIsMapped = true;
|
|
||||||
commID[i] = -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// The item is no longer mapped to this community, so remove the database record
|
// Check the item mappings to see if it contains this community mapping
|
||||||
if (!itemIsMapped)
|
boolean itemIsMapped = false;
|
||||||
DatabaseManager.delete(context, tr);
|
int trCommID = tr.getIntColumn("community_id");
|
||||||
|
for (int i = 0; i < commID.length; i++)
|
||||||
|
{
|
||||||
|
// Found this community
|
||||||
|
if (commID[i] == trCommID)
|
||||||
|
{
|
||||||
|
// Flag it, and remove (-1) from the item mappings
|
||||||
|
itemIsMapped = true;
|
||||||
|
commID[i] = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// The item is no longer mapped to this community, so remove the database record
|
||||||
|
if (!itemIsMapped)
|
||||||
|
DatabaseManager.delete(context, tr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
tri.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -256,27 +256,34 @@ public class BrowseCreateDAOPostgres implements BrowseCreateDAO
|
|||||||
TableRowIterator tri = DatabaseManager.queryTable(context, table, "SELECT * FROM " + table + " WHERE item_id=?", itemID);
|
TableRowIterator tri = DatabaseManager.queryTable(context, table, "SELECT * FROM " + table + " WHERE item_id=?", itemID);
|
||||||
if (tri != null)
|
if (tri != null)
|
||||||
{
|
{
|
||||||
while (tri.hasNext())
|
try
|
||||||
{
|
{
|
||||||
TableRow tr = tri.next();
|
while (tri.hasNext())
|
||||||
|
|
||||||
// Check the item mappings to see if it contains this mapping
|
|
||||||
boolean itemIsMapped = false;
|
|
||||||
int trDistinctID = tr.getIntColumn("distinct_id");
|
|
||||||
for (int i = 0; i < distinctIDs.length; i++)
|
|
||||||
{
|
{
|
||||||
// Found this mapping
|
TableRow tr = tri.next();
|
||||||
if (distinctIDs[i] == trDistinctID)
|
|
||||||
{
|
|
||||||
// Flag it, and remove (-1) from the item mappings
|
|
||||||
itemIsMapped = true;
|
|
||||||
distinctIDs[i] = -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// The item is no longer mapped to this community, so remove the database record
|
// Check the item mappings to see if it contains this mapping
|
||||||
if (!itemIsMapped)
|
boolean itemIsMapped = false;
|
||||||
DatabaseManager.delete(context, tr);
|
int trDistinctID = tr.getIntColumn("distinct_id");
|
||||||
|
for (int i = 0; i < distinctIDs.length; i++)
|
||||||
|
{
|
||||||
|
// Found this mapping
|
||||||
|
if (distinctIDs[i] == trDistinctID)
|
||||||
|
{
|
||||||
|
// Flag it, and remove (-1) from the item mappings
|
||||||
|
itemIsMapped = true;
|
||||||
|
distinctIDs[i] = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// The item is no longer mapped to this community, so remove the database record
|
||||||
|
if (!itemIsMapped)
|
||||||
|
DatabaseManager.delete(context, tr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
tri.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -569,27 +576,34 @@ public class BrowseCreateDAOPostgres implements BrowseCreateDAO
|
|||||||
TableRowIterator tri = DatabaseManager.queryTable(context, "Communities2Item", "SELECT * FROM Communities2Item WHERE item_id=?", itemID);
|
TableRowIterator tri = DatabaseManager.queryTable(context, "Communities2Item", "SELECT * FROM Communities2Item WHERE item_id=?", itemID);
|
||||||
if (tri != null)
|
if (tri != null)
|
||||||
{
|
{
|
||||||
while (tri.hasNext())
|
try
|
||||||
{
|
{
|
||||||
TableRow tr = tri.next();
|
while (tri.hasNext())
|
||||||
|
|
||||||
// Check the item mappings to see if it contains this community mapping
|
|
||||||
boolean itemIsMapped = false;
|
|
||||||
int trCommID = tr.getIntColumn("community_id");
|
|
||||||
for (int i = 0; i < commID.length; i++)
|
|
||||||
{
|
{
|
||||||
// Found this community
|
TableRow tr = tri.next();
|
||||||
if (commID[i] == trCommID)
|
|
||||||
{
|
|
||||||
// Flag it, and remove (-1) from the item mappings
|
|
||||||
itemIsMapped = true;
|
|
||||||
commID[i] = -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// The item is no longer mapped to this community, so remove the database record
|
// Check the item mappings to see if it contains this community mapping
|
||||||
if (!itemIsMapped)
|
boolean itemIsMapped = false;
|
||||||
DatabaseManager.delete(context, tr);
|
int trCommID = tr.getIntColumn("community_id");
|
||||||
|
for (int i = 0; i < commID.length; i++)
|
||||||
|
{
|
||||||
|
// Found this community
|
||||||
|
if (commID[i] == trCommID)
|
||||||
|
{
|
||||||
|
// Flag it, and remove (-1) from the item mappings
|
||||||
|
itemIsMapped = true;
|
||||||
|
commID[i] = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// The item is no longer mapped to this community, so remove the database record
|
||||||
|
if (!itemIsMapped)
|
||||||
|
DatabaseManager.delete(context, tr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
tri.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1092,6 +1092,11 @@ public class Collection extends DSpaceObject
|
|||||||
log.error("caught exception: ", e);
|
log.error("caught exception: ", e);
|
||||||
throw new IOException(e.getMessage());
|
throw new IOException(e.getMessage());
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (items != null)
|
||||||
|
items.close();
|
||||||
|
}
|
||||||
|
|
||||||
// Delete bitstream logo
|
// Delete bitstream logo
|
||||||
setLogo(null);
|
setLogo(null);
|
||||||
|
@@ -1559,72 +1559,79 @@ public class Item extends DSpaceObject
|
|||||||
TableRowIterator tri = retrieveMetadata();
|
TableRowIterator tri = retrieveMetadata();
|
||||||
if (tri != null)
|
if (tri != null)
|
||||||
{
|
{
|
||||||
while (tri.hasNext())
|
try
|
||||||
{
|
{
|
||||||
TableRow tr = tri.next();
|
while (tri.hasNext())
|
||||||
// Assume that we will remove this row, unless we get a match
|
|
||||||
boolean removeRow = true;
|
|
||||||
|
|
||||||
// Go through the in-memory metadata, unless we've already decided to keep this row
|
|
||||||
for (int dcIdx = 0; dcIdx < dublinCore.size() && removeRow; dcIdx++)
|
|
||||||
{
|
{
|
||||||
// Only process if this metadata has not already been matched to something in the DB
|
TableRow tr = tri.next();
|
||||||
if (!storedDC[dcIdx])
|
// Assume that we will remove this row, unless we get a match
|
||||||
|
boolean removeRow = true;
|
||||||
|
|
||||||
|
// Go through the in-memory metadata, unless we've already decided to keep this row
|
||||||
|
for (int dcIdx = 0; dcIdx < dublinCore.size() && removeRow; dcIdx++)
|
||||||
{
|
{
|
||||||
boolean matched = true;
|
// Only process if this metadata has not already been matched to something in the DB
|
||||||
DCValue dcv = dublinCore.get(dcIdx);
|
if (!storedDC[dcIdx])
|
||||||
|
|
||||||
// Check the metadata field is the same
|
|
||||||
if (matched && dcFields[dcIdx].getFieldID() != tr.getIntColumn("metadata_field_id"))
|
|
||||||
matched = false;
|
|
||||||
|
|
||||||
// Check the place is the same
|
|
||||||
if (matched && placeNum[dcIdx] != tr.getIntColumn("place"))
|
|
||||||
matched = false;
|
|
||||||
|
|
||||||
// Check the text is the same
|
|
||||||
if (matched)
|
|
||||||
{
|
{
|
||||||
String text = tr.getStringColumn("text_value");
|
boolean matched = true;
|
||||||
if (dcv.value == null && text == null)
|
DCValue dcv = dublinCore.get(dcIdx);
|
||||||
matched = true;
|
|
||||||
else if (dcv.value != null && dcv.value.equals(text))
|
// Check the metadata field is the same
|
||||||
matched = true;
|
if (matched && dcFields[dcIdx].getFieldID() != tr.getIntColumn("metadata_field_id"))
|
||||||
else
|
|
||||||
matched = false;
|
matched = false;
|
||||||
}
|
|
||||||
|
|
||||||
// Check the language is the same
|
// Check the place is the same
|
||||||
if (matched)
|
if (matched && placeNum[dcIdx] != tr.getIntColumn("place"))
|
||||||
{
|
|
||||||
String lang = tr.getStringColumn("text_lang");
|
|
||||||
if (dcv.language == null && lang == null)
|
|
||||||
matched = true;
|
|
||||||
else if (dcv.language != null && dcv.language.equals(lang))
|
|
||||||
matched = true;
|
|
||||||
else
|
|
||||||
matched = false;
|
matched = false;
|
||||||
}
|
|
||||||
|
|
||||||
// If the db record is identical to the in memory values
|
// Check the text is the same
|
||||||
if (matched)
|
if (matched)
|
||||||
{
|
{
|
||||||
// Flag that the metadata is already in the DB
|
String text = tr.getStringColumn("text_value");
|
||||||
storedDC[dcIdx] = true;
|
if (dcv.value == null && text == null)
|
||||||
|
matched = true;
|
||||||
|
else if (dcv.value != null && dcv.value.equals(text))
|
||||||
|
matched = true;
|
||||||
|
else
|
||||||
|
matched = false;
|
||||||
|
}
|
||||||
|
|
||||||
// Flag that we are not going to remove the row
|
// Check the language is the same
|
||||||
removeRow = false;
|
if (matched)
|
||||||
|
{
|
||||||
|
String lang = tr.getStringColumn("text_lang");
|
||||||
|
if (dcv.language == null && lang == null)
|
||||||
|
matched = true;
|
||||||
|
else if (dcv.language != null && dcv.language.equals(lang))
|
||||||
|
matched = true;
|
||||||
|
else
|
||||||
|
matched = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the db record is identical to the in memory values
|
||||||
|
if (matched)
|
||||||
|
{
|
||||||
|
// Flag that the metadata is already in the DB
|
||||||
|
storedDC[dcIdx] = true;
|
||||||
|
|
||||||
|
// Flag that we are not going to remove the row
|
||||||
|
removeRow = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// If after processing all the metadata values, we didn't find a match
|
// If after processing all the metadata values, we didn't find a match
|
||||||
// delete this row from the DB
|
// delete this row from the DB
|
||||||
if (removeRow)
|
if (removeRow)
|
||||||
{
|
{
|
||||||
DatabaseManager.delete(ourContext, tr);
|
DatabaseManager.delete(ourContext, tr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
tri.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add missing in-memory DC
|
// Add missing in-memory DC
|
||||||
|
@@ -270,4 +270,13 @@ public class ItemIterator
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dispose of this Iterator, and it's underlying resources
|
||||||
|
*/
|
||||||
|
public void close()
|
||||||
|
{
|
||||||
|
if (itemRows != null)
|
||||||
|
itemRows.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -314,30 +314,37 @@ public class EPerson extends DSpaceObject
|
|||||||
|
|
||||||
// Get all the epeople that match the query
|
// Get all the epeople that match the query
|
||||||
TableRowIterator rows = DatabaseManager.query(context, dbquery, paramArr);
|
TableRowIterator rows = DatabaseManager.query(context, dbquery, paramArr);
|
||||||
|
try
|
||||||
List epeopleRows = rows.toList();
|
{
|
||||||
EPerson[] epeople = new EPerson[epeopleRows.size()];
|
List epeopleRows = rows.toList();
|
||||||
|
EPerson[] epeople = new EPerson[epeopleRows.size()];
|
||||||
for (int i = 0; i < epeopleRows.size(); i++)
|
|
||||||
{
|
for (int i = 0; i < epeopleRows.size(); i++)
|
||||||
TableRow row = (TableRow) epeopleRows.get(i);
|
{
|
||||||
|
TableRow row = (TableRow) epeopleRows.get(i);
|
||||||
// First check the cache
|
|
||||||
EPerson fromCache = (EPerson) context.fromCache(EPerson.class, row
|
// First check the cache
|
||||||
.getIntColumn("eperson_id"));
|
EPerson fromCache = (EPerson) context.fromCache(EPerson.class, row
|
||||||
|
.getIntColumn("eperson_id"));
|
||||||
if (fromCache != null)
|
|
||||||
{
|
if (fromCache != null)
|
||||||
epeople[i] = fromCache;
|
{
|
||||||
}
|
epeople[i] = fromCache;
|
||||||
else
|
}
|
||||||
{
|
else
|
||||||
epeople[i] = new EPerson(context, row);
|
{
|
||||||
}
|
epeople[i] = new EPerson(context, row);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return epeople;
|
|
||||||
}
|
return epeople;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (rows != null)
|
||||||
|
rows.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the total number of epeople returned by a specific query, without the overhead
|
* Returns the total number of epeople returned by a specific query, without the overhead
|
||||||
@@ -428,29 +435,37 @@ public class EPerson extends DSpaceObject
|
|||||||
TableRowIterator rows = DatabaseManager.query(context,
|
TableRowIterator rows = DatabaseManager.query(context,
|
||||||
"SELECT * FROM eperson ORDER BY "+s);
|
"SELECT * FROM eperson ORDER BY "+s);
|
||||||
|
|
||||||
List epeopleRows = rows.toList();
|
try
|
||||||
|
|
||||||
EPerson[] epeople = new EPerson[epeopleRows.size()];
|
|
||||||
|
|
||||||
for (int i = 0; i < epeopleRows.size(); i++)
|
|
||||||
{
|
{
|
||||||
TableRow row = (TableRow) epeopleRows.get(i);
|
List epeopleRows = rows.toList();
|
||||||
|
|
||||||
// First check the cache
|
EPerson[] epeople = new EPerson[epeopleRows.size()];
|
||||||
EPerson fromCache = (EPerson) context.fromCache(EPerson.class, row
|
|
||||||
.getIntColumn("eperson_id"));
|
|
||||||
|
|
||||||
if (fromCache != null)
|
for (int i = 0; i < epeopleRows.size(); i++)
|
||||||
{
|
{
|
||||||
epeople[i] = fromCache;
|
TableRow row = (TableRow) epeopleRows.get(i);
|
||||||
}
|
|
||||||
else
|
// First check the cache
|
||||||
{
|
EPerson fromCache = (EPerson) context.fromCache(EPerson.class, row
|
||||||
epeople[i] = new EPerson(context, row);
|
.getIntColumn("eperson_id"));
|
||||||
|
|
||||||
|
if (fromCache != null)
|
||||||
|
{
|
||||||
|
epeople[i] = fromCache;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
epeople[i] = new EPerson(context, row);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return epeople;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (rows != null)
|
||||||
|
rows.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
return epeople;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -776,29 +776,37 @@ public class Group extends DSpaceObject
|
|||||||
context, "epersongroup",
|
context, "epersongroup",
|
||||||
"SELECT * FROM epersongroup ORDER BY "+s);
|
"SELECT * FROM epersongroup ORDER BY "+s);
|
||||||
|
|
||||||
List gRows = rows.toList();
|
try
|
||||||
|
|
||||||
Group[] groups = new Group[gRows.size()];
|
|
||||||
|
|
||||||
for (int i = 0; i < gRows.size(); i++)
|
|
||||||
{
|
{
|
||||||
TableRow row = (TableRow) gRows.get(i);
|
List gRows = rows.toList();
|
||||||
|
|
||||||
// First check the cache
|
Group[] groups = new Group[gRows.size()];
|
||||||
Group fromCache = (Group) context.fromCache(Group.class, row
|
|
||||||
.getIntColumn("eperson_group_id"));
|
|
||||||
|
|
||||||
if (fromCache != null)
|
for (int i = 0; i < gRows.size(); i++)
|
||||||
{
|
{
|
||||||
groups[i] = fromCache;
|
TableRow row = (TableRow) gRows.get(i);
|
||||||
}
|
|
||||||
else
|
// First check the cache
|
||||||
{
|
Group fromCache = (Group) context.fromCache(Group.class, row
|
||||||
groups[i] = new Group(context, row);
|
.getIntColumn("eperson_group_id"));
|
||||||
|
|
||||||
|
if (fromCache != null)
|
||||||
|
{
|
||||||
|
groups[i] = fromCache;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
groups[i] = new Group(context, row);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return groups;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (rows != null)
|
||||||
|
rows.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
return groups;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -896,28 +904,36 @@ public class Group extends DSpaceObject
|
|||||||
|
|
||||||
TableRowIterator rows =
|
TableRowIterator rows =
|
||||||
DatabaseManager.query(context, dbquery, paramArr);
|
DatabaseManager.query(context, dbquery, paramArr);
|
||||||
|
|
||||||
List groupRows = rows.toList();
|
try
|
||||||
Group[] groups = new Group[groupRows.size()];
|
{
|
||||||
|
List groupRows = rows.toList();
|
||||||
for (int i = 0; i < groupRows.size(); i++)
|
Group[] groups = new Group[groupRows.size()];
|
||||||
{
|
|
||||||
TableRow row = (TableRow) groupRows.get(i);
|
for (int i = 0; i < groupRows.size(); i++)
|
||||||
|
{
|
||||||
// First check the cache
|
TableRow row = (TableRow) groupRows.get(i);
|
||||||
Group fromCache = (Group) context.fromCache(Group.class, row
|
|
||||||
.getIntColumn("eperson_group_id"));
|
// First check the cache
|
||||||
|
Group fromCache = (Group) context.fromCache(Group.class, row
|
||||||
if (fromCache != null)
|
.getIntColumn("eperson_group_id"));
|
||||||
{
|
|
||||||
groups[i] = fromCache;
|
if (fromCache != null)
|
||||||
}
|
{
|
||||||
else
|
groups[i] = fromCache;
|
||||||
{
|
}
|
||||||
groups[i] = new Group(context, row);
|
else
|
||||||
}
|
{
|
||||||
}
|
groups[i] = new Group(context, row);
|
||||||
return groups;
|
}
|
||||||
|
}
|
||||||
|
return groups;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (rows != null)
|
||||||
|
rows.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -570,18 +570,25 @@ public class DSIndexer
|
|||||||
* @param force
|
* @param force
|
||||||
*/
|
*/
|
||||||
public static void updateIndex(Context context, boolean force) {
|
public static void updateIndex(Context context, boolean force) {
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
ItemIterator items = null;
|
||||||
for(ItemIterator i = Item.findAll(context);i.hasNext();)
|
try
|
||||||
{
|
{
|
||||||
Item item = (Item) i.next();
|
for(items = Item.findAll(context);items.hasNext();)
|
||||||
indexContent(context,item,force);
|
{
|
||||||
item.decache();
|
Item item = (Item) items.next();
|
||||||
}
|
indexContent(context,item,force);
|
||||||
|
item.decache();
|
||||||
Collection[] collections = Collection.findAll(context);
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (items != null)
|
||||||
|
items.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
Collection[] collections = Collection.findAll(context);
|
||||||
for (int i = 0; i < collections.length; i++)
|
for (int i = 0; i < collections.length; i++)
|
||||||
{
|
{
|
||||||
indexContent(context,collections[i],force);
|
indexContent(context,collections[i],force);
|
||||||
@@ -603,8 +610,7 @@ public class DSIndexer
|
|||||||
{
|
{
|
||||||
log.error(e.getMessage(), e);
|
log.error(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Iterates over all documents in the Lucene index and verifies they
|
* Iterates over all documents in the Lucene index and verifies they
|
||||||
|
@@ -342,15 +342,22 @@ public class Harvest
|
|||||||
"AND collection2item.collection_id=handle.resource_id AND collection2item.item_id = ? ",
|
"AND collection2item.collection_id=handle.resource_id AND collection2item.item_id = ? ",
|
||||||
Constants.COLLECTION, itemInfo.itemID);
|
Constants.COLLECTION, itemInfo.itemID);
|
||||||
|
|
||||||
// Chuck 'em in the itemInfo object
|
try
|
||||||
itemInfo.collectionHandles = new LinkedList();
|
|
||||||
|
|
||||||
while (colRows.hasNext())
|
|
||||||
{
|
{
|
||||||
TableRow r = colRows.next();
|
// Chuck 'em in the itemInfo object
|
||||||
itemInfo.collectionHandles.add(r.getStringColumn("handle"));
|
itemInfo.collectionHandles = new LinkedList();
|
||||||
|
|
||||||
|
while (colRows.hasNext())
|
||||||
|
{
|
||||||
|
TableRow r = colRows.next();
|
||||||
|
itemInfo.collectionHandles.add(r.getStringColumn("handle"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (colRows != null)
|
||||||
|
colRows.close();
|
||||||
}
|
}
|
||||||
colRows.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -162,13 +162,23 @@ public class DatabaseManager
|
|||||||
}
|
}
|
||||||
|
|
||||||
PreparedStatement statement = context.getDBConnection().prepareStatement(query);
|
PreparedStatement statement = context.getDBConnection().prepareStatement(query);
|
||||||
loadParameters(statement,parameters);
|
try
|
||||||
|
{
|
||||||
TableRowIterator retTRI = new TableRowIterator(statement.executeQuery(),
|
loadParameters(statement,parameters);
|
||||||
canonicalize(table));
|
|
||||||
|
|
||||||
retTRI.setStatement(statement);
|
TableRowIterator retTRI = new TableRowIterator(statement.executeQuery(),
|
||||||
return retTRI;
|
canonicalize(table));
|
||||||
|
|
||||||
|
retTRI.setStatement(statement);
|
||||||
|
return retTRI;
|
||||||
|
}
|
||||||
|
catch (SQLException sqle)
|
||||||
|
{
|
||||||
|
if (statement != null)
|
||||||
|
try { statement.close(); } catch (SQLException s) { }
|
||||||
|
|
||||||
|
throw sqle;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -204,13 +214,22 @@ public class DatabaseManager
|
|||||||
}
|
}
|
||||||
|
|
||||||
PreparedStatement statement = context.getDBConnection().prepareStatement(query);
|
PreparedStatement statement = context.getDBConnection().prepareStatement(query);
|
||||||
loadParameters(statement,parameters);
|
try
|
||||||
|
{
|
||||||
TableRowIterator retTRI = new TableRowIterator(statement.executeQuery());
|
loadParameters(statement,parameters);
|
||||||
|
|
||||||
|
TableRowIterator retTRI = new TableRowIterator(statement.executeQuery());
|
||||||
retTRI.setStatement(statement);
|
|
||||||
return retTRI;
|
retTRI.setStatement(statement);
|
||||||
|
return retTRI;
|
||||||
|
}
|
||||||
|
catch (SQLException sqle)
|
||||||
|
{
|
||||||
|
if (statement != null)
|
||||||
|
try { statement.close(); } catch (SQLException s) { }
|
||||||
|
|
||||||
|
throw sqle;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -197,13 +197,18 @@ public class TableRowIterator
|
|||||||
{
|
{
|
||||||
List resultsList = new ArrayList();
|
List resultsList = new ArrayList();
|
||||||
|
|
||||||
while (hasNext())
|
try
|
||||||
{
|
{
|
||||||
resultsList.add(next());
|
while (hasNext())
|
||||||
|
{
|
||||||
|
resultsList.add(next());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
// Close the connection after converting it to a list.
|
||||||
|
this.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close the connection after converting it to a list.
|
|
||||||
this.close();
|
|
||||||
|
|
||||||
return resultsList;
|
return resultsList;
|
||||||
}
|
}
|
||||||
|
@@ -766,15 +766,22 @@ public class MyDSpaceServlet extends DSpaceServlet
|
|||||||
throws ServletException, IOException, SQLException,
|
throws ServletException, IOException, SQLException,
|
||||||
AuthorizeException
|
AuthorizeException
|
||||||
{
|
{
|
||||||
|
// Turn the iterator into a list
|
||||||
|
List subList = new LinkedList();
|
||||||
ItemIterator subs = Item.findBySubmitter(context, context
|
ItemIterator subs = Item.findBySubmitter(context, context
|
||||||
.getCurrentUser());
|
.getCurrentUser());
|
||||||
|
|
||||||
// Turn the iterator into a list
|
try
|
||||||
List subList = new LinkedList();
|
|
||||||
|
|
||||||
while (subs.hasNext())
|
|
||||||
{
|
{
|
||||||
subList.add(subs.next());
|
while (subs.hasNext())
|
||||||
|
{
|
||||||
|
subList.add(subs.next());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (subs != null)
|
||||||
|
subs.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
Item[] items = new Item[subList.size()];
|
Item[] items = new Item[subList.size()];
|
||||||
|
@@ -126,50 +126,57 @@ public class ItemMapServlet extends DSpaceServlet
|
|||||||
|
|
||||||
// get all items from that collection, add them to a hash
|
// get all items from that collection, add them to a hash
|
||||||
ItemIterator i = myCollection.getItems();
|
ItemIterator i = myCollection.getItems();
|
||||||
|
try
|
||||||
// iterate through the items in this collection, and count how many
|
{
|
||||||
// are native, and how many are imports, and which collections they
|
// iterate through the items in this collection, and count how many
|
||||||
// came from
|
// are native, and how many are imports, and which collections they
|
||||||
while (i.hasNext())
|
// came from
|
||||||
{
|
while (i.hasNext())
|
||||||
Item myItem = i.next();
|
{
|
||||||
|
Item myItem = i.next();
|
||||||
// get key for hash
|
|
||||||
Integer myKey = new Integer(myItem.getID());
|
// get key for hash
|
||||||
|
Integer myKey = new Integer(myItem.getID());
|
||||||
if (myItem.isOwningCollection(myCollection))
|
|
||||||
{
|
if (myItem.isOwningCollection(myCollection))
|
||||||
count_native++;
|
{
|
||||||
}
|
count_native++;
|
||||||
else
|
}
|
||||||
{
|
else
|
||||||
count_import++;
|
{
|
||||||
}
|
count_import++;
|
||||||
|
}
|
||||||
// is the collection in the hash?
|
|
||||||
Collection owningCollection = myItem.getOwningCollection();
|
// is the collection in the hash?
|
||||||
Integer cKey = new Integer(owningCollection.getID());
|
Collection owningCollection = myItem.getOwningCollection();
|
||||||
|
Integer cKey = new Integer(owningCollection.getID());
|
||||||
if (myCollections.containsKey(cKey))
|
|
||||||
{
|
if (myCollections.containsKey(cKey))
|
||||||
Integer x = (Integer) myCounts.get(cKey);
|
{
|
||||||
int myCount = x.intValue() + 1;
|
Integer x = (Integer) myCounts.get(cKey);
|
||||||
|
int myCount = x.intValue() + 1;
|
||||||
// increment count for that collection
|
|
||||||
myCounts.put(cKey, new Integer(myCount));
|
// increment count for that collection
|
||||||
}
|
myCounts.put(cKey, new Integer(myCount));
|
||||||
else
|
}
|
||||||
{
|
else
|
||||||
// store and initialize count
|
{
|
||||||
myCollections.put(cKey, owningCollection);
|
// store and initialize count
|
||||||
myCounts.put(cKey, new Integer(1));
|
myCollections.put(cKey, owningCollection);
|
||||||
}
|
myCounts.put(cKey, new Integer(1));
|
||||||
|
}
|
||||||
// store the item
|
|
||||||
myItems.put(myKey, myItem);
|
// store the item
|
||||||
}
|
myItems.put(myKey, myItem);
|
||||||
|
}
|
||||||
// remove this collection's entry because we already have a native
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (i != null)
|
||||||
|
i.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
// remove this collection's entry because we already have a native
|
||||||
// count
|
// count
|
||||||
myCollections.remove(new Integer(myCollection.getID()));
|
myCollections.remove(new Integer(myCollection.getID()));
|
||||||
|
|
||||||
@@ -381,26 +388,33 @@ public class ItemMapServlet extends DSpaceServlet
|
|||||||
// FIXME: oh god this is so annoying - what an API /Richard
|
// FIXME: oh god this is so annoying - what an API /Richard
|
||||||
// we need to deduplicate against existing items in this collection
|
// we need to deduplicate against existing items in this collection
|
||||||
ItemIterator itr = myCollection.getItems();
|
ItemIterator itr = myCollection.getItems();
|
||||||
ArrayList idslist = new ArrayList();
|
try
|
||||||
while (itr.hasNext())
|
{
|
||||||
{
|
ArrayList idslist = new ArrayList();
|
||||||
idslist.add(new Integer(itr.nextID()));
|
while (itr.hasNext())
|
||||||
}
|
{
|
||||||
|
idslist.add(new Integer(itr.nextID()));
|
||||||
for (int i = 0; i < browseItems.length; i++)
|
}
|
||||||
{
|
|
||||||
// only if it isn't already in this collection
|
for (int i = 0; i < browseItems.length; i++)
|
||||||
if (!idslist.contains(new Integer(browseItems[i].getID())))
|
{
|
||||||
{
|
// only if it isn't already in this collection
|
||||||
// only put on list if you can read item
|
if (!idslist.contains(new Integer(browseItems[i].getID())))
|
||||||
if (AuthorizeManager.authorizeActionBoolean(context, browseItems[i], Constants.READ))
|
{
|
||||||
{
|
// only put on list if you can read item
|
||||||
items.put(new Integer(browseItems[i].getID()), browseItems[i]);
|
if (AuthorizeManager.authorizeActionBoolean(context, browseItems[i], Constants.READ))
|
||||||
}
|
{
|
||||||
}
|
items.put(new Integer(browseItems[i].getID()), browseItems[i]);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (itr != null)
|
||||||
|
itr.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
catch (BrowseException e)
|
catch (BrowseException e)
|
||||||
{
|
{
|
||||||
log.error("caught exception: ", e);
|
log.error("caught exception: ", e);
|
||||||
@@ -424,21 +438,28 @@ public class ItemMapServlet extends DSpaceServlet
|
|||||||
|
|
||||||
// now find all imported items from that collection
|
// now find all imported items from that collection
|
||||||
// seemingly inefficient, but database should have this query cached
|
// seemingly inefficient, but database should have this query cached
|
||||||
|
Map items = new HashMap();
|
||||||
ItemIterator i = myCollection.getItems();
|
ItemIterator i = myCollection.getItems();
|
||||||
Map items = new HashMap();
|
try
|
||||||
|
{
|
||||||
|
while (i.hasNext())
|
||||||
|
{
|
||||||
|
Item myItem = i.next();
|
||||||
|
|
||||||
|
if (myItem.isOwningCollection(targetCollection))
|
||||||
|
{
|
||||||
|
Integer myKey = new Integer(myItem.getID());
|
||||||
|
items.put(myKey, myItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (i != null)
|
||||||
|
i.close();
|
||||||
|
}
|
||||||
|
|
||||||
while (i.hasNext())
|
request.setAttribute("collection", myCollection);
|
||||||
{
|
|
||||||
Item myItem = i.next();
|
|
||||||
|
|
||||||
if (myItem.isOwningCollection(targetCollection))
|
|
||||||
{
|
|
||||||
Integer myKey = new Integer(myItem.getID());
|
|
||||||
items.put(myKey, myItem);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
request.setAttribute("collection", myCollection);
|
|
||||||
request.setAttribute("browsetext", targetCollection
|
request.setAttribute("browsetext", targetCollection
|
||||||
.getMetadata("name"));
|
.getMetadata("name"));
|
||||||
request.setAttribute("items", items);
|
request.setAttribute("items", items);
|
||||||
|
@@ -160,12 +160,21 @@ class DAVCollection extends DAVDSpaceObject
|
|||||||
{
|
{
|
||||||
Vector result = new Vector();
|
Vector result = new Vector();
|
||||||
ItemIterator ii = this.collection.getItems();
|
ItemIterator ii = this.collection.getItems();
|
||||||
while (ii.hasNext())
|
try
|
||||||
{
|
{
|
||||||
Item item = ii.next();
|
while (ii.hasNext())
|
||||||
result.add(new DAVItem(this.context, this.request, this.response,
|
{
|
||||||
makeChildPath(item), item));
|
Item item = ii.next();
|
||||||
|
result.add(new DAVItem(this.context, this.request, this.response,
|
||||||
|
makeChildPath(item), item));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (ii != null)
|
||||||
|
ii.close();
|
||||||
|
}
|
||||||
|
|
||||||
return (DAVResource[]) result.toArray(new DAVResource[result.size()]);
|
return (DAVResource[]) result.toArray(new DAVResource[result.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -195,13 +195,20 @@ public class BrowseItemForm extends AbstractDSpaceTransformer {
|
|||||||
|
|
||||||
// get all items from that collection
|
// get all items from that collection
|
||||||
ItemIterator iterator = collection.getItems();
|
ItemIterator iterator = collection.getItems();
|
||||||
|
try
|
||||||
while (iterator.hasNext())
|
|
||||||
{
|
{
|
||||||
Item item = iterator.next();
|
while (iterator.hasNext())
|
||||||
|
{
|
||||||
|
Item item = iterator.next();
|
||||||
|
|
||||||
if (! item.isOwningCollection(collection))
|
if (! item.isOwningCollection(collection))
|
||||||
items.add(item);
|
items.add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (iterator != null)
|
||||||
|
iterator.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
return items;
|
return items;
|
||||||
|
@@ -157,18 +157,26 @@ public class MapperMain extends AbstractDSpaceTransformer {
|
|||||||
// get all items from that collection
|
// get all items from that collection
|
||||||
ItemIterator iterator = collection.getItems();
|
ItemIterator iterator = collection.getItems();
|
||||||
|
|
||||||
// iterate through the items in this collection, and count how many
|
try
|
||||||
// are native, and how many are imports, and which collections they
|
|
||||||
// came from
|
|
||||||
while (iterator.hasNext())
|
|
||||||
{
|
{
|
||||||
Item item = iterator.next();
|
// iterate through the items in this collection, and count how many
|
||||||
|
// are native, and how many are imports, and which collections they
|
||||||
|
// came from
|
||||||
|
while (iterator.hasNext())
|
||||||
|
{
|
||||||
|
Item item = iterator.next();
|
||||||
|
|
||||||
if (item.isOwningCollection(collection))
|
if (item.isOwningCollection(collection))
|
||||||
count_native++;
|
count_native++;
|
||||||
else
|
else
|
||||||
count_import++;
|
count_import++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (iterator != null)
|
||||||
|
iterator.close();
|
||||||
|
}
|
||||||
|
|
||||||
int[] counts = new int[2];
|
int[] counts = new int[2];
|
||||||
counts[0] = count_native;
|
counts[0] = count_native;
|
||||||
|
Reference in New Issue
Block a user