mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-11 20:13:17 +00:00
Fix various problems with resources potentially not being freed, and other minor fixes suggested by FindBugs
git-svn-id: http://scm.dspace.org/svn/repo/branches/dspace-1_5_x@3036 9c30dcfa-912a-0410-8fc2-9e0234be79fd
This commit is contained in:
@@ -242,10 +242,19 @@ public class METSExport
|
|||||||
+ File.separator + "config" + File.separator + "dc2mods.cfg";
|
+ File.separator + "config" + File.separator + "dc2mods.cfg";
|
||||||
|
|
||||||
// Read it in
|
// Read it in
|
||||||
InputStream is = new FileInputStream(configFile);
|
InputStream is = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
is = new FileInputStream(configFile);
|
||||||
dcToMODS = new Properties();
|
dcToMODS = new Properties();
|
||||||
dcToMODS.load(is);
|
dcToMODS.load(is);
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (is != null)
|
||||||
|
try { is.close(); } catch (IOException ioe) { }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write out the AIP for the given item to the given directory. A new
|
* Write out the AIP for the given item to the given directory. A new
|
||||||
|
@@ -563,6 +563,8 @@ public class ReportGenerator
|
|||||||
FileReader fr = null;
|
FileReader fr = null;
|
||||||
BufferedReader br = null;
|
BufferedReader br = null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
// read in the map file, printing a warning if none is found
|
// read in the map file, printing a warning if none is found
|
||||||
String record = null;
|
String record = null;
|
||||||
try
|
try
|
||||||
@@ -588,6 +590,15 @@ public class ReportGenerator
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (br != null)
|
||||||
|
try { br.close(); } catch (IOException ioe) { }
|
||||||
|
|
||||||
|
if (fr != null)
|
||||||
|
try { fr.close(); } catch (IOException ioe) { }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -140,12 +140,13 @@ public class X509Authentication
|
|||||||
// First look for keystore full of trusted certs.
|
// First look for keystore full of trusted certs.
|
||||||
if (keystorePath != null)
|
if (keystorePath != null)
|
||||||
{
|
{
|
||||||
|
FileInputStream fis = null;
|
||||||
if (keystorePassword == null)
|
if (keystorePassword == null)
|
||||||
keystorePassword = "";
|
keystorePassword = "";
|
||||||
try {
|
try {
|
||||||
KeyStore ks = KeyStore.getInstance("JKS");
|
KeyStore ks = KeyStore.getInstance("JKS");
|
||||||
ks.load(new FileInputStream(keystorePath),
|
fis = new FileInputStream(keystorePath);
|
||||||
keystorePassword.toCharArray());
|
ks.load(fis, keystorePassword.toCharArray());
|
||||||
caCertKeyStore = ks;
|
caCertKeyStore = ks;
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
@@ -158,14 +159,22 @@ public class X509Authentication
|
|||||||
log.error("X509Authentication: Failed to extract CA keystore, file="+
|
log.error("X509Authentication: Failed to extract CA keystore, file="+
|
||||||
keystorePath+", error="+e.toString());
|
keystorePath+", error="+e.toString());
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (fis != null)
|
||||||
|
try { fis.close(); } catch (IOException ioe) { }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Second, try getting public key out of CA cert, if that's configured.
|
// Second, try getting public key out of CA cert, if that's configured.
|
||||||
if (caCertPath != null)
|
if (caCertPath != null)
|
||||||
{
|
{
|
||||||
|
InputStream is = null;
|
||||||
|
FileInputStream fis = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
InputStream is = new BufferedInputStream(new FileInputStream(caCertPath));
|
fis = new FileInputStream(caCertPath);
|
||||||
|
is = new BufferedInputStream(fis);
|
||||||
X509Certificate cert = (X509Certificate) CertificateFactory
|
X509Certificate cert = (X509Certificate) CertificateFactory
|
||||||
.getInstance("X.509").generateCertificate(is);
|
.getInstance("X.509").generateCertificate(is);
|
||||||
if (cert != null)
|
if (cert != null)
|
||||||
@@ -181,6 +190,14 @@ public class X509Authentication
|
|||||||
log.error("X509Authentication: Failed to extract CA cert, file="+
|
log.error("X509Authentication: Failed to extract CA cert, file="+
|
||||||
caCertPath+", error="+e.toString());
|
caCertPath+", error="+e.toString());
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (is != null)
|
||||||
|
try { is.close(); } catch (IOException ioe) { }
|
||||||
|
|
||||||
|
if (fis != null)
|
||||||
|
try { fis.close(); } catch (IOException ioe) { }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -424,6 +424,8 @@ public class AuthorizeManager
|
|||||||
|
|
||||||
List<ResourcePolicy> policies = new ArrayList();
|
List<ResourcePolicy> policies = new ArrayList();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
while (tri.hasNext())
|
while (tri.hasNext())
|
||||||
{
|
{
|
||||||
TableRow row = tri.next();
|
TableRow row = tri.next();
|
||||||
@@ -441,7 +443,12 @@ public class AuthorizeManager
|
|||||||
policies.add(new ResourcePolicy(c, row));
|
policies.add(new ResourcePolicy(c, row));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (tri != null)
|
||||||
tri.close();
|
tri.close();
|
||||||
|
}
|
||||||
|
|
||||||
return policies;
|
return policies;
|
||||||
}
|
}
|
||||||
@@ -463,6 +470,8 @@ public class AuthorizeManager
|
|||||||
|
|
||||||
List<ResourcePolicy> policies = new ArrayList<ResourcePolicy>();
|
List<ResourcePolicy> policies = new ArrayList<ResourcePolicy>();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
while (tri.hasNext())
|
while (tri.hasNext())
|
||||||
{
|
{
|
||||||
TableRow row = tri.next();
|
TableRow row = tri.next();
|
||||||
@@ -480,7 +489,12 @@ public class AuthorizeManager
|
|||||||
policies.add(new ResourcePolicy(c, row));
|
policies.add(new ResourcePolicy(c, row));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (tri != null)
|
||||||
tri.close();
|
tri.close();
|
||||||
|
}
|
||||||
|
|
||||||
return policies;
|
return policies;
|
||||||
}
|
}
|
||||||
@@ -507,6 +521,8 @@ public class AuthorizeManager
|
|||||||
|
|
||||||
List<ResourcePolicy> policies = new ArrayList<ResourcePolicy>();
|
List<ResourcePolicy> policies = new ArrayList<ResourcePolicy>();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
while (tri.hasNext())
|
while (tri.hasNext())
|
||||||
{
|
{
|
||||||
TableRow row = tri.next();
|
TableRow row = tri.next();
|
||||||
@@ -524,7 +540,12 @@ public class AuthorizeManager
|
|||||||
policies.add(new ResourcePolicy(c, row));
|
policies.add(new ResourcePolicy(c, row));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (tri != null)
|
||||||
tri.close();
|
tri.close();
|
||||||
|
}
|
||||||
|
|
||||||
return policies;
|
return policies;
|
||||||
}
|
}
|
||||||
@@ -699,6 +720,8 @@ public class AuthorizeManager
|
|||||||
"AND resource_id= ? AND action_id= ? ",o.getType(),o.getID(),actionID);
|
"AND resource_id= ? AND action_id= ? ",o.getType(),o.getID(),actionID);
|
||||||
|
|
||||||
List<Group> groups = new ArrayList<Group>();
|
List<Group> groups = new ArrayList<Group>();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
|
||||||
while (tri.hasNext())
|
while (tri.hasNext())
|
||||||
{
|
{
|
||||||
@@ -727,7 +750,12 @@ public class AuthorizeManager
|
|||||||
groups.add(myGroup);
|
groups.add(myGroup);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (tri != null)
|
||||||
tri.close();
|
tri.close();
|
||||||
|
}
|
||||||
|
|
||||||
Group[] groupArray = new Group[groups.size()];
|
Group[] groupArray = new Group[groups.size()];
|
||||||
groupArray = groups.toArray(groupArray);
|
groupArray = groups.toArray(groupArray);
|
||||||
|
@@ -96,11 +96,12 @@ public class ItemCountDAOOracle implements ItemCountDAO
|
|||||||
public void collectionCount(Collection collection, int count)
|
public void collectionCount(Collection collection, int count)
|
||||||
throws ItemCountException
|
throws ItemCountException
|
||||||
{
|
{
|
||||||
|
TableRowIterator tri = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// first find out if we have a record
|
// first find out if we have a record
|
||||||
Object[] sparams = { new Integer(collection.getID()) };
|
Object[] sparams = { new Integer(collection.getID()) };
|
||||||
TableRowIterator tri = DatabaseManager.query(context, collectionSelect, sparams);
|
tri = DatabaseManager.query(context, collectionSelect, sparams);
|
||||||
|
|
||||||
if (tri.hasNext())
|
if (tri.hasNext())
|
||||||
{
|
{
|
||||||
@@ -112,14 +113,17 @@ public class ItemCountDAOOracle implements ItemCountDAO
|
|||||||
Object[] params = { new Integer(collection.getID()), new Integer(count) };
|
Object[] params = { new Integer(collection.getID()), new Integer(count) };
|
||||||
DatabaseManager.updateQuery(context, collectionInsert, params);
|
DatabaseManager.updateQuery(context, collectionInsert, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
tri.close();
|
|
||||||
}
|
}
|
||||||
catch (SQLException e)
|
catch (SQLException e)
|
||||||
{
|
{
|
||||||
log.error("caught exception: ", e);
|
log.error("caught exception: ", e);
|
||||||
throw new ItemCountException(e);
|
throw new ItemCountException(e);
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (tri != null)
|
||||||
|
tri.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -132,11 +136,12 @@ public class ItemCountDAOOracle implements ItemCountDAO
|
|||||||
public void communityCount(Community community, int count)
|
public void communityCount(Community community, int count)
|
||||||
throws ItemCountException
|
throws ItemCountException
|
||||||
{
|
{
|
||||||
|
TableRowIterator tri = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// first find out if we have a record
|
// first find out if we have a record
|
||||||
Object[] sparams = { new Integer(community.getID()) };
|
Object[] sparams = { new Integer(community.getID()) };
|
||||||
TableRowIterator tri = DatabaseManager.query(context, communitySelect, sparams);
|
tri = DatabaseManager.query(context, communitySelect, sparams);
|
||||||
|
|
||||||
if (tri.hasNext())
|
if (tri.hasNext())
|
||||||
{
|
{
|
||||||
@@ -148,14 +153,17 @@ public class ItemCountDAOOracle implements ItemCountDAO
|
|||||||
Object[] params = { new Integer(community.getID()), new Integer(count) };
|
Object[] params = { new Integer(community.getID()), new Integer(count) };
|
||||||
DatabaseManager.updateQuery(context, communityInsert, params);
|
DatabaseManager.updateQuery(context, communityInsert, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
tri.close();
|
|
||||||
}
|
}
|
||||||
catch (SQLException e)
|
catch (SQLException e)
|
||||||
{
|
{
|
||||||
log.error("caught exception: ", e);
|
log.error("caught exception: ", e);
|
||||||
throw new ItemCountException(e);
|
throw new ItemCountException(e);
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (tri != null)
|
||||||
|
tri.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -268,10 +276,11 @@ public class ItemCountDAOOracle implements ItemCountDAO
|
|||||||
private int getCollectionCount(Collection collection)
|
private int getCollectionCount(Collection collection)
|
||||||
throws ItemCountException
|
throws ItemCountException
|
||||||
{
|
{
|
||||||
|
TableRowIterator tri = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Object[] params = { new Integer(collection.getID()) };
|
Object[] params = { new Integer(collection.getID()) };
|
||||||
TableRowIterator tri = DatabaseManager.query(context, collectionSelect, params);
|
tri = DatabaseManager.query(context, collectionSelect, params);
|
||||||
|
|
||||||
if (!tri.hasNext())
|
if (!tri.hasNext())
|
||||||
{
|
{
|
||||||
@@ -285,8 +294,6 @@ public class ItemCountDAOOracle implements ItemCountDAO
|
|||||||
throw new ItemCountException("More than one count row in the database");
|
throw new ItemCountException("More than one count row in the database");
|
||||||
}
|
}
|
||||||
|
|
||||||
tri.close();
|
|
||||||
|
|
||||||
return tr.getIntColumn("count");
|
return tr.getIntColumn("count");
|
||||||
}
|
}
|
||||||
catch (SQLException e)
|
catch (SQLException e)
|
||||||
@@ -294,6 +301,11 @@ public class ItemCountDAOOracle implements ItemCountDAO
|
|||||||
log.error("caught exception: ", e);
|
log.error("caught exception: ", e);
|
||||||
throw new ItemCountException(e);
|
throw new ItemCountException(e);
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (tri != null)
|
||||||
|
tri.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -306,10 +318,11 @@ public class ItemCountDAOOracle implements ItemCountDAO
|
|||||||
private int getCommunityCount(Community community)
|
private int getCommunityCount(Community community)
|
||||||
throws ItemCountException
|
throws ItemCountException
|
||||||
{
|
{
|
||||||
|
TableRowIterator tri = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Object[] params = { new Integer(community.getID()) };
|
Object[] params = { new Integer(community.getID()) };
|
||||||
TableRowIterator tri = DatabaseManager.query(context, communitySelect, params);
|
tri = DatabaseManager.query(context, communitySelect, params);
|
||||||
|
|
||||||
if (!tri.hasNext())
|
if (!tri.hasNext())
|
||||||
{
|
{
|
||||||
@@ -323,8 +336,6 @@ public class ItemCountDAOOracle implements ItemCountDAO
|
|||||||
throw new ItemCountException("More than one count row in the database");
|
throw new ItemCountException("More than one count row in the database");
|
||||||
}
|
}
|
||||||
|
|
||||||
tri.close();
|
|
||||||
|
|
||||||
return tr.getIntColumn("count");
|
return tr.getIntColumn("count");
|
||||||
}
|
}
|
||||||
catch (SQLException e)
|
catch (SQLException e)
|
||||||
@@ -332,5 +343,10 @@ public class ItemCountDAOOracle implements ItemCountDAO
|
|||||||
log.error("caught exception: ", e);
|
log.error("caught exception: ", e);
|
||||||
throw new ItemCountException(e);
|
throw new ItemCountException(e);
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (tri != null)
|
||||||
|
tri.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -96,11 +96,12 @@ public class ItemCountDAOPostgres implements ItemCountDAO
|
|||||||
public void collectionCount(Collection collection, int count)
|
public void collectionCount(Collection collection, int count)
|
||||||
throws ItemCountException
|
throws ItemCountException
|
||||||
{
|
{
|
||||||
|
TableRowIterator tri = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// first find out if we have a record
|
// first find out if we have a record
|
||||||
Object[] sparams = { new Integer(collection.getID()) };
|
Object[] sparams = { new Integer(collection.getID()) };
|
||||||
TableRowIterator tri = DatabaseManager.query(context, collectionSelect, sparams);
|
tri = DatabaseManager.query(context, collectionSelect, sparams);
|
||||||
|
|
||||||
if (tri.hasNext())
|
if (tri.hasNext())
|
||||||
{
|
{
|
||||||
@@ -112,14 +113,17 @@ public class ItemCountDAOPostgres implements ItemCountDAO
|
|||||||
Object[] params = { new Integer(collection.getID()), new Integer(count) };
|
Object[] params = { new Integer(collection.getID()), new Integer(count) };
|
||||||
DatabaseManager.updateQuery(context, collectionInsert, params);
|
DatabaseManager.updateQuery(context, collectionInsert, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
tri.close();
|
|
||||||
}
|
}
|
||||||
catch (SQLException e)
|
catch (SQLException e)
|
||||||
{
|
{
|
||||||
log.error("caught exception: ", e);
|
log.error("caught exception: ", e);
|
||||||
throw new ItemCountException(e);
|
throw new ItemCountException(e);
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (tri != null)
|
||||||
|
tri.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -132,11 +136,12 @@ public class ItemCountDAOPostgres implements ItemCountDAO
|
|||||||
public void communityCount(Community community, int count)
|
public void communityCount(Community community, int count)
|
||||||
throws ItemCountException
|
throws ItemCountException
|
||||||
{
|
{
|
||||||
|
TableRowIterator tri = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// first find out if we have a record
|
// first find out if we have a record
|
||||||
Object[] sparams = { new Integer(community.getID()) };
|
Object[] sparams = { new Integer(community.getID()) };
|
||||||
TableRowIterator tri = DatabaseManager.query(context, communitySelect, sparams);
|
tri = DatabaseManager.query(context, communitySelect, sparams);
|
||||||
|
|
||||||
if (tri.hasNext())
|
if (tri.hasNext())
|
||||||
{
|
{
|
||||||
@@ -148,14 +153,17 @@ public class ItemCountDAOPostgres implements ItemCountDAO
|
|||||||
Object[] params = { new Integer(community.getID()), new Integer(count) };
|
Object[] params = { new Integer(community.getID()), new Integer(count) };
|
||||||
DatabaseManager.updateQuery(context, communityInsert, params);
|
DatabaseManager.updateQuery(context, communityInsert, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
tri.close();
|
|
||||||
}
|
}
|
||||||
catch (SQLException e)
|
catch (SQLException e)
|
||||||
{
|
{
|
||||||
log.error("caught exception: ", e);
|
log.error("caught exception: ", e);
|
||||||
throw new ItemCountException(e);
|
throw new ItemCountException(e);
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (tri != null)
|
||||||
|
tri.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -268,10 +276,11 @@ public class ItemCountDAOPostgres implements ItemCountDAO
|
|||||||
private int getCollectionCount(Collection collection)
|
private int getCollectionCount(Collection collection)
|
||||||
throws ItemCountException
|
throws ItemCountException
|
||||||
{
|
{
|
||||||
|
TableRowIterator tri = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Object[] params = { new Integer(collection.getID()) };
|
Object[] params = { new Integer(collection.getID()) };
|
||||||
TableRowIterator tri = DatabaseManager.query(context, collectionSelect, params);
|
tri = DatabaseManager.query(context, collectionSelect, params);
|
||||||
|
|
||||||
if (!tri.hasNext())
|
if (!tri.hasNext())
|
||||||
{
|
{
|
||||||
@@ -285,8 +294,6 @@ public class ItemCountDAOPostgres implements ItemCountDAO
|
|||||||
throw new ItemCountException("More than one count row in the database");
|
throw new ItemCountException("More than one count row in the database");
|
||||||
}
|
}
|
||||||
|
|
||||||
tri.close();
|
|
||||||
|
|
||||||
return tr.getIntColumn("count");
|
return tr.getIntColumn("count");
|
||||||
}
|
}
|
||||||
catch (SQLException e)
|
catch (SQLException e)
|
||||||
@@ -294,6 +301,11 @@ public class ItemCountDAOPostgres implements ItemCountDAO
|
|||||||
log.error("caught exception: ", e);
|
log.error("caught exception: ", e);
|
||||||
throw new ItemCountException(e);
|
throw new ItemCountException(e);
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (tri != null)
|
||||||
|
tri.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -306,10 +318,11 @@ public class ItemCountDAOPostgres implements ItemCountDAO
|
|||||||
private int getCommunityCount(Community community)
|
private int getCommunityCount(Community community)
|
||||||
throws ItemCountException
|
throws ItemCountException
|
||||||
{
|
{
|
||||||
|
TableRowIterator tri = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Object[] params = { new Integer(community.getID()) };
|
Object[] params = { new Integer(community.getID()) };
|
||||||
TableRowIterator tri = DatabaseManager.query(context, communitySelect, params);
|
tri = DatabaseManager.query(context, communitySelect, params);
|
||||||
|
|
||||||
if (!tri.hasNext())
|
if (!tri.hasNext())
|
||||||
{
|
{
|
||||||
@@ -323,8 +336,6 @@ public class ItemCountDAOPostgres implements ItemCountDAO
|
|||||||
throw new ItemCountException("More than one count row in the database");
|
throw new ItemCountException("More than one count row in the database");
|
||||||
}
|
}
|
||||||
|
|
||||||
tri.close();
|
|
||||||
|
|
||||||
return tr.getIntColumn("count");
|
return tr.getIntColumn("count");
|
||||||
}
|
}
|
||||||
catch (SQLException e)
|
catch (SQLException e)
|
||||||
@@ -332,5 +343,10 @@ public class ItemCountDAOPostgres implements ItemCountDAO
|
|||||||
log.error("caught exception: ", e);
|
log.error("caught exception: ", e);
|
||||||
throw new ItemCountException(e);
|
throw new ItemCountException(e);
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (tri != null)
|
||||||
|
tri.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -98,7 +98,9 @@ public class HandleDispatcher implements BitstreamDispatcher
|
|||||||
* @throws SQLException
|
* @throws SQLException
|
||||||
* if database access fails.
|
* if database access fails.
|
||||||
*/
|
*/
|
||||||
private void init()
|
private synchronized void init()
|
||||||
|
{
|
||||||
|
if (init == Boolean.FALSE)
|
||||||
{
|
{
|
||||||
Context context = null;
|
Context context = null;
|
||||||
int dsoType = -1;
|
int dsoType = -1;
|
||||||
@@ -152,6 +154,7 @@ public class HandleDispatcher implements BitstreamDispatcher
|
|||||||
delegate = new ListDispatcher(ids);
|
delegate = new ListDispatcher(ids);
|
||||||
init = Boolean.TRUE;
|
init = Boolean.TRUE;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes this dispatcher on first execution.
|
* Initializes this dispatcher on first execution.
|
||||||
@@ -159,14 +162,11 @@ public class HandleDispatcher implements BitstreamDispatcher
|
|||||||
* @see org.dspace.checker.BitstreamDispatcher#next()
|
* @see org.dspace.checker.BitstreamDispatcher#next()
|
||||||
*/
|
*/
|
||||||
public int next()
|
public int next()
|
||||||
{
|
|
||||||
synchronized (init)
|
|
||||||
{
|
{
|
||||||
if (init == Boolean.FALSE)
|
if (init == Boolean.FALSE)
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return delegate.next();
|
return delegate.next();
|
||||||
}
|
}
|
||||||
|
@@ -581,7 +581,8 @@ public class Bitstream extends DSpaceObject
|
|||||||
|
|
||||||
// Build a list of Bundle objects
|
// Build a list of Bundle objects
|
||||||
List<Bundle> bundles = new ArrayList<Bundle>();
|
List<Bundle> bundles = new ArrayList<Bundle>();
|
||||||
|
try
|
||||||
|
{
|
||||||
while (tri.hasNext())
|
while (tri.hasNext())
|
||||||
{
|
{
|
||||||
TableRow r = tri.next();
|
TableRow r = tri.next();
|
||||||
@@ -599,9 +600,13 @@ public class Bitstream extends DSpaceObject
|
|||||||
bundles.add(new Bundle(bContext, r));
|
bundles.add(new Bundle(bContext, r));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
// close the TableRowIterator to free up resources
|
// close the TableRowIterator to free up resources
|
||||||
|
if (tri != null)
|
||||||
tri.close();
|
tri.close();
|
||||||
|
}
|
||||||
|
|
||||||
Bundle[] bundleArray = new Bundle[bundles.size()];
|
Bundle[] bundleArray = new Bundle[bundles.size()];
|
||||||
bundleArray = (Bundle[]) bundles.toArray(bundleArray);
|
bundleArray = (Bundle[]) bundles.toArray(bundleArray);
|
||||||
|
@@ -114,12 +114,19 @@ public class BitstreamFormat
|
|||||||
"SELECT * FROM fileextension WHERE bitstream_format_id= ? ",
|
"SELECT * FROM fileextension WHERE bitstream_format_id= ? ",
|
||||||
getID());
|
getID());
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
while (tri.hasNext())
|
while (tri.hasNext())
|
||||||
{
|
{
|
||||||
extensions.add(tri.next().getStringColumn("extension"));
|
extensions.add(tri.next().getStringColumn("extension"));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
// close the TableRowIterator to free up resources
|
// close the TableRowIterator to free up resources
|
||||||
|
if (tri != null)
|
||||||
tri.close();
|
tri.close();
|
||||||
|
}
|
||||||
|
|
||||||
// Cache ourselves
|
// Cache ourselves
|
||||||
context.cache(this, row.getIntColumn("bitstream_format_id"));
|
context.cache(this, row.getIntColumn("bitstream_format_id"));
|
||||||
@@ -298,6 +305,8 @@ public class BitstreamFormat
|
|||||||
TableRowIterator tri = DatabaseManager.queryTable(context, "bitstreamformatregistry",
|
TableRowIterator tri = DatabaseManager.queryTable(context, "bitstreamformatregistry",
|
||||||
"SELECT * FROM bitstreamformatregistry ORDER BY bitstream_format_id");
|
"SELECT * FROM bitstreamformatregistry ORDER BY bitstream_format_id");
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
while (tri.hasNext())
|
while (tri.hasNext())
|
||||||
{
|
{
|
||||||
TableRow row = tri.next();
|
TableRow row = tri.next();
|
||||||
@@ -316,8 +325,13 @@ public class BitstreamFormat
|
|||||||
formats.add(new BitstreamFormat(context, row));
|
formats.add(new BitstreamFormat(context, row));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
// close the TableRowIterator to free up resources
|
// close the TableRowIterator to free up resources
|
||||||
|
if (tri != null)
|
||||||
tri.close();
|
tri.close();
|
||||||
|
}
|
||||||
|
|
||||||
// Return the formats as an array
|
// Return the formats as an array
|
||||||
BitstreamFormat[] formatArray = new BitstreamFormat[formats.size()];
|
BitstreamFormat[] formatArray = new BitstreamFormat[formats.size()];
|
||||||
@@ -349,6 +363,8 @@ public class BitstreamFormat
|
|||||||
TableRowIterator tri = DatabaseManager.queryTable(context,
|
TableRowIterator tri = DatabaseManager.queryTable(context,
|
||||||
"bitstreamformatregistry", myQuery);
|
"bitstreamformatregistry", myQuery);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
while (tri.hasNext())
|
while (tri.hasNext())
|
||||||
{
|
{
|
||||||
TableRow row = tri.next();
|
TableRow row = tri.next();
|
||||||
@@ -367,8 +383,13 @@ public class BitstreamFormat
|
|||||||
formats.add(new BitstreamFormat(context, row));
|
formats.add(new BitstreamFormat(context, row));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
// close the TableRowIterator to free up resources
|
// close the TableRowIterator to free up resources
|
||||||
|
if (tri != null)
|
||||||
tri.close();
|
tri.close();
|
||||||
|
}
|
||||||
|
|
||||||
// Return the formats as an array
|
// Return the formats as an array
|
||||||
BitstreamFormat[] formatArray = new BitstreamFormat[formats.size()];
|
BitstreamFormat[] formatArray = new BitstreamFormat[formats.size()];
|
||||||
|
@@ -111,6 +111,8 @@ public class Bundle extends DSpaceObject
|
|||||||
+ "bundle2bitstream.bundle_id= ? ",
|
+ "bundle2bitstream.bundle_id= ? ",
|
||||||
bundleRow.getIntColumn("bundle_id"));
|
bundleRow.getIntColumn("bundle_id"));
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
while (tri.hasNext())
|
while (tri.hasNext())
|
||||||
{
|
{
|
||||||
TableRow r = (TableRow) tri.next();
|
TableRow r = (TableRow) tri.next();
|
||||||
@@ -128,8 +130,13 @@ public class Bundle extends DSpaceObject
|
|||||||
bitstreams.add(new Bitstream(ourContext, r));
|
bitstreams.add(new Bitstream(ourContext, r));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
// close the TableRowIterator to free up resources
|
// close the TableRowIterator to free up resources
|
||||||
|
if (tri != null)
|
||||||
tri.close();
|
tri.close();
|
||||||
|
}
|
||||||
|
|
||||||
// Cache ourselves
|
// Cache ourselves
|
||||||
context.cache(this, row.getIntColumn("bundle_id"));
|
context.cache(this, row.getIntColumn("bundle_id"));
|
||||||
@@ -332,6 +339,8 @@ public class Bundle extends DSpaceObject
|
|||||||
"item2bundle.bundle_id= ? ",
|
"item2bundle.bundle_id= ? ",
|
||||||
bundleRow.getIntColumn("bundle_id"));
|
bundleRow.getIntColumn("bundle_id"));
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
while (tri.hasNext())
|
while (tri.hasNext())
|
||||||
{
|
{
|
||||||
TableRow r = (TableRow) tri.next();
|
TableRow r = (TableRow) tri.next();
|
||||||
@@ -349,8 +358,13 @@ public class Bundle extends DSpaceObject
|
|||||||
items.add(new Item(ourContext, r));
|
items.add(new Item(ourContext, r));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
// close the TableRowIterator to free up resources
|
// close the TableRowIterator to free up resources
|
||||||
|
if (tri != null)
|
||||||
tri.close();
|
tri.close();
|
||||||
|
}
|
||||||
|
|
||||||
Item[] itemArray = new Item[items.size()];
|
Item[] itemArray = new Item[items.size()];
|
||||||
itemArray = (Item[]) items.toArray(itemArray);
|
itemArray = (Item[]) items.toArray(itemArray);
|
||||||
@@ -503,14 +517,21 @@ public class Bundle extends DSpaceObject
|
|||||||
"SELECT * FROM bundle2bitstream WHERE bitstream_id= ? ",
|
"SELECT * FROM bundle2bitstream WHERE bitstream_id= ? ",
|
||||||
b.getID());
|
b.getID());
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
if (!tri.hasNext())
|
if (!tri.hasNext())
|
||||||
{
|
{
|
||||||
// The bitstream is an orphan, delete it
|
// The bitstream is an orphan, delete it
|
||||||
b.delete();
|
b.delete();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
// close the TableRowIterator to free up resources
|
// close the TableRowIterator to free up resources
|
||||||
|
if (tri != null)
|
||||||
tri.close();
|
tri.close();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the bundle metadata
|
* Update the bundle metadata
|
||||||
|
@@ -289,6 +289,8 @@ public class Collection extends DSpaceObject
|
|||||||
|
|
||||||
List<Collection> collections = new ArrayList<Collection>();
|
List<Collection> collections = new ArrayList<Collection>();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
while (tri.hasNext())
|
while (tri.hasNext())
|
||||||
{
|
{
|
||||||
TableRow row = tri.next();
|
TableRow row = tri.next();
|
||||||
@@ -306,8 +308,13 @@ public class Collection extends DSpaceObject
|
|||||||
collections.add(new Collection(context, row));
|
collections.add(new Collection(context, row));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
// close the TableRowIterator to free up resources
|
// close the TableRowIterator to free up resources
|
||||||
|
if (tri != null)
|
||||||
tri.close();
|
tri.close();
|
||||||
|
}
|
||||||
|
|
||||||
Collection[] collectionArray = new Collection[collections.size()];
|
Collection[] collectionArray = new Collection[collections.size()];
|
||||||
collectionArray = (Collection[]) collections.toArray(collectionArray);
|
collectionArray = (Collection[]) collections.toArray(collectionArray);
|
||||||
@@ -924,6 +931,8 @@ public class Collection extends DSpaceObject
|
|||||||
"SELECT * FROM collection2item WHERE item_id= ? ",
|
"SELECT * FROM collection2item WHERE item_id= ? ",
|
||||||
item.getID());
|
item.getID());
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
if (!tri.hasNext())
|
if (!tri.hasNext())
|
||||||
{
|
{
|
||||||
//make the right to remove the item explicit because the implicit
|
//make the right to remove the item explicit because the implicit
|
||||||
@@ -940,9 +949,14 @@ public class Collection extends DSpaceObject
|
|||||||
// Orphan; delete it
|
// Orphan; delete it
|
||||||
item.delete();
|
item.delete();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
// close the TableRowIterator to free up resources
|
// close the TableRowIterator to free up resources
|
||||||
|
if (tri != null)
|
||||||
tri.close();
|
tri.close();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the collection metadata (including logo, and workflow groups) to
|
* Update the collection metadata (including logo, and workflow groups) to
|
||||||
@@ -1181,6 +1195,8 @@ public class Collection extends DSpaceObject
|
|||||||
// Build a list of Community objects
|
// Build a list of Community objects
|
||||||
List<Community> communities = new ArrayList<Community>();
|
List<Community> communities = new ArrayList<Community>();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
while (tri.hasNext())
|
while (tri.hasNext())
|
||||||
{
|
{
|
||||||
TableRow row = tri.next();
|
TableRow row = tri.next();
|
||||||
@@ -1204,8 +1220,13 @@ public class Collection extends DSpaceObject
|
|||||||
communities.add(parents[i]);
|
communities.add(parents[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
// close the TableRowIterator to free up resources
|
// close the TableRowIterator to free up resources
|
||||||
|
if (tri != null)
|
||||||
tri.close();
|
tri.close();
|
||||||
|
}
|
||||||
|
|
||||||
Community[] communityArray = new Community[communities.size()];
|
Community[] communityArray = new Community[communities.size()];
|
||||||
communityArray = (Community[]) communities.toArray(communityArray);
|
communityArray = (Community[]) communities.toArray(communityArray);
|
||||||
@@ -1315,21 +1336,40 @@ public class Collection extends DSpaceObject
|
|||||||
*/
|
*/
|
||||||
public int countItems()
|
public int countItems()
|
||||||
throws SQLException
|
throws SQLException
|
||||||
|
{
|
||||||
|
int itemcount = 0;
|
||||||
|
PreparedStatement statement = null;
|
||||||
|
ResultSet rs = null;
|
||||||
|
|
||||||
|
try
|
||||||
{
|
{
|
||||||
String query = "SELECT count(*) FROM collection2item, item WHERE "
|
String query = "SELECT count(*) FROM collection2item, item WHERE "
|
||||||
+ "collection2item.collection_id = ? "
|
+ "collection2item.collection_id = ? "
|
||||||
+ "AND collection2item.item_id = item.item_id "
|
+ "AND collection2item.item_id = item.item_id "
|
||||||
+ "AND in_archive ='1' AND item.withdrawn='0' ";
|
+ "AND in_archive ='1' AND item.withdrawn='0' ";
|
||||||
|
|
||||||
PreparedStatement statement = ourContext.getDBConnection().prepareStatement(query);
|
statement = ourContext.getDBConnection().prepareStatement(query);
|
||||||
statement.setInt(1,getID());
|
statement.setInt(1,getID());
|
||||||
|
|
||||||
ResultSet rs = statement.executeQuery();
|
rs = statement.executeQuery();
|
||||||
|
if (rs != null)
|
||||||
|
{
|
||||||
rs.next();
|
rs.next();
|
||||||
int itemcount = rs.getInt(1);
|
itemcount = rs.getInt(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (rs != null)
|
||||||
|
{
|
||||||
|
try { rs.close(); } catch (SQLException sqle) { }
|
||||||
|
}
|
||||||
|
|
||||||
statement.close();
|
if (statement != null)
|
||||||
|
{
|
||||||
|
try { statement.close(); } catch (SQLException sqle) { }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return itemcount;
|
return itemcount;
|
||||||
}
|
}
|
||||||
|
@@ -237,6 +237,8 @@ public class Community extends DSpaceObject
|
|||||||
|
|
||||||
List<Community> communities = new ArrayList<Community>();
|
List<Community> communities = new ArrayList<Community>();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
while (tri.hasNext())
|
while (tri.hasNext())
|
||||||
{
|
{
|
||||||
TableRow row = tri.next();
|
TableRow row = tri.next();
|
||||||
@@ -254,8 +256,13 @@ public class Community extends DSpaceObject
|
|||||||
communities.add(new Community(context, row));
|
communities.add(new Community(context, row));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
// close the TableRowIterator to free up resources
|
// close the TableRowIterator to free up resources
|
||||||
|
if (tri != null)
|
||||||
tri.close();
|
tri.close();
|
||||||
|
}
|
||||||
|
|
||||||
Community[] communityArray = new Community[communities.size()];
|
Community[] communityArray = new Community[communities.size()];
|
||||||
communityArray = (Community[]) communities.toArray(communityArray);
|
communityArray = (Community[]) communities.toArray(communityArray);
|
||||||
@@ -283,6 +290,8 @@ public class Community extends DSpaceObject
|
|||||||
|
|
||||||
List<Community> topCommunities = new ArrayList<Community>();
|
List<Community> topCommunities = new ArrayList<Community>();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
while (tri.hasNext())
|
while (tri.hasNext())
|
||||||
{
|
{
|
||||||
TableRow row = tri.next();
|
TableRow row = tri.next();
|
||||||
@@ -300,8 +309,13 @@ public class Community extends DSpaceObject
|
|||||||
topCommunities.add(new Community(context, row));
|
topCommunities.add(new Community(context, row));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
// close the TableRowIterator to free up resources
|
// close the TableRowIterator to free up resources
|
||||||
|
if (tri != null)
|
||||||
tri.close();
|
tri.close();
|
||||||
|
}
|
||||||
|
|
||||||
Community[] communityArray = new Community[topCommunities.size()];
|
Community[] communityArray = new Community[topCommunities.size()];
|
||||||
communityArray = (Community[]) topCommunities.toArray(communityArray);
|
communityArray = (Community[]) topCommunities.toArray(communityArray);
|
||||||
@@ -514,6 +528,8 @@ public class Community extends DSpaceObject
|
|||||||
getID());
|
getID());
|
||||||
|
|
||||||
// Make Collection objects
|
// Make Collection objects
|
||||||
|
try
|
||||||
|
{
|
||||||
while (tri.hasNext())
|
while (tri.hasNext())
|
||||||
{
|
{
|
||||||
TableRow row = tri.next();
|
TableRow row = tri.next();
|
||||||
@@ -531,8 +547,13 @@ public class Community extends DSpaceObject
|
|||||||
collections.add(new Collection(ourContext, row));
|
collections.add(new Collection(ourContext, row));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
// close the TableRowIterator to free up resources
|
// close the TableRowIterator to free up resources
|
||||||
|
if (tri != null)
|
||||||
tri.close();
|
tri.close();
|
||||||
|
}
|
||||||
|
|
||||||
// Put them in an array
|
// Put them in an array
|
||||||
Collection[] collectionArray = new Collection[collections.size()];
|
Collection[] collectionArray = new Collection[collections.size()];
|
||||||
@@ -562,6 +583,8 @@ public class Community extends DSpaceObject
|
|||||||
|
|
||||||
|
|
||||||
// Make Community objects
|
// Make Community objects
|
||||||
|
try
|
||||||
|
{
|
||||||
while (tri.hasNext())
|
while (tri.hasNext())
|
||||||
{
|
{
|
||||||
TableRow row = tri.next();
|
TableRow row = tri.next();
|
||||||
@@ -579,8 +602,13 @@ public class Community extends DSpaceObject
|
|||||||
subcommunities.add(new Community(ourContext, row));
|
subcommunities.add(new Community(ourContext, row));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
// close the TableRowIterator to free up resources
|
// close the TableRowIterator to free up resources
|
||||||
|
if (tri != null)
|
||||||
tri.close();
|
tri.close();
|
||||||
|
}
|
||||||
|
|
||||||
// Put them in an array
|
// Put them in an array
|
||||||
Community[] communityArray = new Community[subcommunities.size()];
|
Community[] communityArray = new Community[subcommunities.size()];
|
||||||
@@ -608,6 +636,8 @@ public class Community extends DSpaceObject
|
|||||||
getID());
|
getID());
|
||||||
|
|
||||||
// Make Community object
|
// Make Community object
|
||||||
|
try
|
||||||
|
{
|
||||||
if (tri.hasNext())
|
if (tri.hasNext())
|
||||||
{
|
{
|
||||||
TableRow row = tri.next();
|
TableRow row = tri.next();
|
||||||
@@ -625,8 +655,13 @@ public class Community extends DSpaceObject
|
|||||||
parentCommunity = new Community(ourContext, row);
|
parentCommunity = new Community(ourContext, row);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
// close the TableRowIterator to free up resources
|
// close the TableRowIterator to free up resources
|
||||||
|
if (tri != null)
|
||||||
tri.close();
|
tri.close();
|
||||||
|
}
|
||||||
|
|
||||||
return parentCommunity;
|
return parentCommunity;
|
||||||
}
|
}
|
||||||
@@ -694,6 +729,8 @@ public class Community extends DSpaceObject
|
|||||||
"SELECT * FROM community2collection WHERE " +
|
"SELECT * FROM community2collection WHERE " +
|
||||||
"community_id= ? AND collection_id= ? ",getID(),c.getID());
|
"community_id= ? AND collection_id= ? ",getID(),c.getID());
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
if (!tri.hasNext())
|
if (!tri.hasNext())
|
||||||
{
|
{
|
||||||
// No existing mapping, so add one
|
// No existing mapping, so add one
|
||||||
@@ -707,9 +744,14 @@ public class Community extends DSpaceObject
|
|||||||
|
|
||||||
DatabaseManager.update(ourContext, mappingRow);
|
DatabaseManager.update(ourContext, mappingRow);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
// close the TableRowIterator to free up resources
|
// close the TableRowIterator to free up resources
|
||||||
|
if (tri != null)
|
||||||
tri.close();
|
tri.close();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new sub-community within this community.
|
* Create a new sub-community within this community.
|
||||||
@@ -749,6 +791,8 @@ public class Community extends DSpaceObject
|
|||||||
"SELECT * FROM community2community WHERE parent_comm_id= ? "+
|
"SELECT * FROM community2community WHERE parent_comm_id= ? "+
|
||||||
"AND child_comm_id= ? ",getID(), c.getID());
|
"AND child_comm_id= ? ",getID(), c.getID());
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
if (!tri.hasNext())
|
if (!tri.hasNext())
|
||||||
{
|
{
|
||||||
// No existing mapping, so add one
|
// No existing mapping, so add one
|
||||||
@@ -762,9 +806,14 @@ public class Community extends DSpaceObject
|
|||||||
|
|
||||||
DatabaseManager.update(ourContext, mappingRow);
|
DatabaseManager.update(ourContext, mappingRow);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
// close the TableRowIterator to free up resources
|
// close the TableRowIterator to free up resources
|
||||||
|
if (tri != null)
|
||||||
tri.close();
|
tri.close();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove a collection. Any items then orphaned are deleted.
|
* Remove a collection. Any items then orphaned are deleted.
|
||||||
@@ -793,6 +842,8 @@ public class Community extends DSpaceObject
|
|||||||
"SELECT * FROM community2collection WHERE collection_id= ? ",
|
"SELECT * FROM community2collection WHERE collection_id= ? ",
|
||||||
c.getID());
|
c.getID());
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
if (!tri.hasNext())
|
if (!tri.hasNext())
|
||||||
{
|
{
|
||||||
//make the right to remove the collection explicit because the
|
//make the right to remove the collection explicit because the
|
||||||
@@ -810,9 +861,14 @@ public class Community extends DSpaceObject
|
|||||||
// Orphan; delete it
|
// Orphan; delete it
|
||||||
c.delete();
|
c.delete();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
// close the TableRowIterator to free up resources
|
// close the TableRowIterator to free up resources
|
||||||
|
if (tri != null)
|
||||||
tri.close();
|
tri.close();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove a subcommunity. Any substructure then orphaned is deleted.
|
* Remove a subcommunity. Any substructure then orphaned is deleted.
|
||||||
@@ -841,6 +897,8 @@ public class Community extends DSpaceObject
|
|||||||
"SELECT * FROM community2community WHERE child_comm_id= ? ",
|
"SELECT * FROM community2community WHERE child_comm_id= ? ",
|
||||||
c.getID());
|
c.getID());
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
if (!tri.hasNext())
|
if (!tri.hasNext())
|
||||||
{
|
{
|
||||||
//make the right to remove the sub explicit because the implicit
|
//make the right to remove the sub explicit because the implicit
|
||||||
@@ -858,9 +916,14 @@ public class Community extends DSpaceObject
|
|||||||
// Orphan; delete it
|
// Orphan; delete it
|
||||||
c.delete();
|
c.delete();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
// close the TableRowIterator to free up resources
|
// close the TableRowIterator to free up resources
|
||||||
|
if (tri != null)
|
||||||
tri.close();
|
tri.close();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete the community, including the metadata and logo. Collections and
|
* Delete the community, including the metadata and logo. Collections and
|
||||||
|
@@ -105,6 +105,8 @@ public class FormatIdentifier
|
|||||||
extension);
|
extension);
|
||||||
|
|
||||||
BitstreamFormat retFormat = null;
|
BitstreamFormat retFormat = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
if (tri.hasNext())
|
if (tri.hasNext())
|
||||||
{
|
{
|
||||||
// Return first match
|
// Return first match
|
||||||
@@ -114,8 +116,13 @@ public class FormatIdentifier
|
|||||||
{
|
{
|
||||||
retFormat = null;
|
retFormat = null;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
// close the TableRowIterator to free up resources
|
// close the TableRowIterator to free up resources
|
||||||
|
if (tri != null)
|
||||||
tri.close();
|
tri.close();
|
||||||
|
}
|
||||||
return retFormat;
|
return retFormat;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -143,6 +143,8 @@ public class Item extends DSpaceObject
|
|||||||
// Get Dublin Core metadata
|
// Get Dublin Core metadata
|
||||||
TableRowIterator tri = retrieveMetadata();
|
TableRowIterator tri = retrieveMetadata();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
while (tri.hasNext())
|
while (tri.hasNext())
|
||||||
{
|
{
|
||||||
TableRow resultRow = tri.next();
|
TableRow resultRow = tri.next();
|
||||||
@@ -174,8 +176,13 @@ public class Item extends DSpaceObject
|
|||||||
dublinCore.add(dcv);
|
dublinCore.add(dcv);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
// close the TableRowIterator to free up resources
|
// close the TableRowIterator to free up resources
|
||||||
|
if (tri != null)
|
||||||
tri.close();
|
tri.close();
|
||||||
|
}
|
||||||
|
|
||||||
// Get our Handle if any
|
// Get our Handle if any
|
||||||
handle = HandleManager.findHandle(context, this);
|
handle = HandleManager.findHandle(context, this);
|
||||||
@@ -918,6 +925,8 @@ public class Item extends DSpaceObject
|
|||||||
"collection2item.item_id= ? ",
|
"collection2item.item_id= ? ",
|
||||||
itemRow.getIntColumn("item_id"));
|
itemRow.getIntColumn("item_id"));
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
while (tri.hasNext())
|
while (tri.hasNext())
|
||||||
{
|
{
|
||||||
TableRow row = tri.next();
|
TableRow row = tri.next();
|
||||||
@@ -935,8 +944,13 @@ public class Item extends DSpaceObject
|
|||||||
collections.add(new Collection(ourContext, row));
|
collections.add(new Collection(ourContext, row));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
// close the TableRowIterator to free up resources
|
// close the TableRowIterator to free up resources
|
||||||
|
if (tri != null)
|
||||||
tri.close();
|
tri.close();
|
||||||
|
}
|
||||||
|
|
||||||
Collection[] collectionArray = new Collection[collections.size()];
|
Collection[] collectionArray = new Collection[collections.size()];
|
||||||
collectionArray = (Collection[]) collections.toArray(collectionArray);
|
collectionArray = (Collection[]) collections.toArray(collectionArray);
|
||||||
@@ -963,6 +977,8 @@ public class Item extends DSpaceObject
|
|||||||
"AND community2item.item_id= ? ",
|
"AND community2item.item_id= ? ",
|
||||||
itemRow.getIntColumn("item_id"));
|
itemRow.getIntColumn("item_id"));
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
while (tri.hasNext())
|
while (tri.hasNext())
|
||||||
{
|
{
|
||||||
TableRow row = tri.next();
|
TableRow row = tri.next();
|
||||||
@@ -986,8 +1002,13 @@ public class Item extends DSpaceObject
|
|||||||
communities.add(parents[i]);
|
communities.add(parents[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
// close the TableRowIterator to free up resources
|
// close the TableRowIterator to free up resources
|
||||||
|
if (tri != null)
|
||||||
tri.close();
|
tri.close();
|
||||||
|
}
|
||||||
|
|
||||||
Community[] communityArray = new Community[communities.size()];
|
Community[] communityArray = new Community[communities.size()];
|
||||||
communityArray = (Community[]) communities.toArray(communityArray);
|
communityArray = (Community[]) communities.toArray(communityArray);
|
||||||
@@ -1012,6 +1033,8 @@ public class Item extends DSpaceObject
|
|||||||
"item2bundle.item_id= ? ",
|
"item2bundle.item_id= ? ",
|
||||||
itemRow.getIntColumn("item_id"));
|
itemRow.getIntColumn("item_id"));
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
while (tri.hasNext())
|
while (tri.hasNext())
|
||||||
{
|
{
|
||||||
TableRow r = tri.next();
|
TableRow r = tri.next();
|
||||||
@@ -1029,9 +1052,14 @@ public class Item extends DSpaceObject
|
|||||||
bundles.add(new Bundle(ourContext, r));
|
bundles.add(new Bundle(ourContext, r));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
// close the TableRowIterator to free up resources
|
// close the TableRowIterator to free up resources
|
||||||
|
if (tri != null)
|
||||||
tri.close();
|
tri.close();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Bundle[] bundleArray = new Bundle[bundles.size()];
|
Bundle[] bundleArray = new Bundle[bundles.size()];
|
||||||
bundleArray = (Bundle[]) bundles.toArray(bundleArray);
|
bundleArray = (Bundle[]) bundles.toArray(bundleArray);
|
||||||
@@ -1184,6 +1212,8 @@ public class Item extends DSpaceObject
|
|||||||
"SELECT * FROM item2bundle WHERE bundle_id= ? ",
|
"SELECT * FROM item2bundle WHERE bundle_id= ? ",
|
||||||
b.getID());
|
b.getID());
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
if (!tri.hasNext())
|
if (!tri.hasNext())
|
||||||
{
|
{
|
||||||
//make the right to remove the bundle explicit because the implicit
|
//make the right to remove the bundle explicit because the implicit
|
||||||
@@ -1201,9 +1231,14 @@ public class Item extends DSpaceObject
|
|||||||
// The bundle is an orphan, delete it
|
// The bundle is an orphan, delete it
|
||||||
b.delete();
|
b.delete();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
// close the TableRowIterator to free up resources
|
// close the TableRowIterator to free up resources
|
||||||
|
if (tri != null)
|
||||||
tri.close();
|
tri.close();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a single bitstream in a new bundle. Provided as a convenience
|
* Create a single bitstream in a new bundle. Provided as a convenience
|
||||||
|
@@ -320,15 +320,20 @@ public class MetadataField
|
|||||||
schemaID, element, qualifier);
|
schemaID, element, qualifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TableRow row = null;
|
TableRow row = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
if (tri.hasNext())
|
if (tri.hasNext())
|
||||||
{
|
{
|
||||||
row = tri.next();
|
row = tri.next();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
// close the TableRowIterator to free up resources
|
// close the TableRowIterator to free up resources
|
||||||
|
if (tri != null)
|
||||||
tri.close();
|
tri.close();
|
||||||
|
}
|
||||||
|
|
||||||
if (row == null)
|
if (row == null)
|
||||||
{
|
{
|
||||||
@@ -355,13 +360,20 @@ public class MetadataField
|
|||||||
TableRowIterator tri = DatabaseManager.queryTable(context, "MetadataFieldRegistry",
|
TableRowIterator tri = DatabaseManager.queryTable(context, "MetadataFieldRegistry",
|
||||||
"SELECT mfr.* FROM MetadataFieldRegistry mfr, MetadataSchemaRegistry msr where mfr.metadata_schema_id= msr.metadata_schema_id ORDER BY msr.short_id, mfr.element, mfr.qualifier");
|
"SELECT mfr.* FROM MetadataFieldRegistry mfr, MetadataSchemaRegistry msr where mfr.metadata_schema_id= msr.metadata_schema_id ORDER BY msr.short_id, mfr.element, mfr.qualifier");
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
// Make into DC Type objects
|
// Make into DC Type objects
|
||||||
while (tri.hasNext())
|
while (tri.hasNext())
|
||||||
{
|
{
|
||||||
fields.add(new MetadataField(tri.next()));
|
fields.add(new MetadataField(tri.next()));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
// close the TableRowIterator to free up resources
|
// close the TableRowIterator to free up resources
|
||||||
|
if (tri != null)
|
||||||
tri.close();
|
tri.close();
|
||||||
|
}
|
||||||
|
|
||||||
// Convert list into an array
|
// Convert list into an array
|
||||||
MetadataField[] typeArray = new MetadataField[fields.size()];
|
MetadataField[] typeArray = new MetadataField[fields.size()];
|
||||||
@@ -386,13 +398,20 @@ public class MetadataField
|
|||||||
"SELECT * FROM MetadataFieldRegistry WHERE metadata_schema_id= ? " +
|
"SELECT * FROM MetadataFieldRegistry WHERE metadata_schema_id= ? " +
|
||||||
" ORDER BY element, qualifier", schemaID);
|
" ORDER BY element, qualifier", schemaID);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
// Make into DC Type objects
|
// Make into DC Type objects
|
||||||
while (tri.hasNext())
|
while (tri.hasNext())
|
||||||
{
|
{
|
||||||
fields.add(new MetadataField(tri.next()));
|
fields.add(new MetadataField(tri.next()));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
// close the TableRowIterator to free up resources
|
// close the TableRowIterator to free up resources
|
||||||
|
if (tri != null)
|
||||||
tri.close();
|
tri.close();
|
||||||
|
}
|
||||||
|
|
||||||
// Convert list into an array
|
// Convert list into an array
|
||||||
MetadataField[] typeArray = new MetadataField[fields.size()];
|
MetadataField[] typeArray = new MetadataField[fields.size()];
|
||||||
@@ -509,7 +528,14 @@ public class MetadataField
|
|||||||
String qualifier) throws IOException, SQLException,
|
String qualifier) throws IOException, SQLException,
|
||||||
AuthorizeException
|
AuthorizeException
|
||||||
{
|
{
|
||||||
Connection con = context.getDBConnection();
|
int count = 0;
|
||||||
|
Connection con = null;
|
||||||
|
PreparedStatement statement = null;
|
||||||
|
ResultSet rs = null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
con = context.getDBConnection();
|
||||||
TableRow reg = DatabaseManager.row("MetadataFieldRegistry");
|
TableRow reg = DatabaseManager.row("MetadataFieldRegistry");
|
||||||
|
|
||||||
String qualifierClause = "";
|
String qualifierClause = "";
|
||||||
@@ -528,7 +554,7 @@ public class MetadataField
|
|||||||
+ " and metadata_field_id != ? "
|
+ " and metadata_field_id != ? "
|
||||||
+ " and element= ? " + qualifierClause;
|
+ " and element= ? " + qualifierClause;
|
||||||
|
|
||||||
PreparedStatement statement = con.prepareStatement(query);
|
statement = con.prepareStatement(query);
|
||||||
statement.setInt(1,schemaID);
|
statement.setInt(1,schemaID);
|
||||||
statement.setInt(2,fieldID);
|
statement.setInt(2,fieldID);
|
||||||
statement.setString(3,element);
|
statement.setString(3,element);
|
||||||
@@ -538,13 +564,25 @@ public class MetadataField
|
|||||||
statement.setString(4,qualifier);
|
statement.setString(4,qualifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultSet rs = statement.executeQuery();
|
rs = statement.executeQuery();
|
||||||
|
|
||||||
int count = 0;
|
|
||||||
if (rs.next())
|
if (rs.next())
|
||||||
{
|
{
|
||||||
count = rs.getInt(1);
|
count = rs.getInt(1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (rs != null)
|
||||||
|
{
|
||||||
|
try { rs.close(); } catch (SQLException sqle) { }
|
||||||
|
}
|
||||||
|
|
||||||
|
if (statement != null)
|
||||||
|
{
|
||||||
|
try { statement.close(); } catch (SQLException sqle) { }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return (count == 0);
|
return (count == 0);
|
||||||
}
|
}
|
||||||
@@ -604,21 +642,36 @@ public class MetadataField
|
|||||||
{
|
{
|
||||||
if (id2field != null)
|
if (id2field != null)
|
||||||
return;
|
return;
|
||||||
id2field = new HashMap();
|
|
||||||
|
synchronized (MetadataField.class)
|
||||||
|
{
|
||||||
|
if (id2field == null)
|
||||||
|
{
|
||||||
|
HashMap new_id2field = new HashMap();
|
||||||
log.info("Loading MetadataField elements into cache.");
|
log.info("Loading MetadataField elements into cache.");
|
||||||
|
|
||||||
// Grab rows from DB
|
// Grab rows from DB
|
||||||
TableRowIterator tri = DatabaseManager.queryTable(context,"MetadataFieldRegistry",
|
TableRowIterator tri = DatabaseManager.queryTable(context,"MetadataFieldRegistry",
|
||||||
"SELECT * from MetadataFieldRegistry");
|
"SELECT * from MetadataFieldRegistry");
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
while (tri.hasNext())
|
while (tri.hasNext())
|
||||||
{
|
{
|
||||||
TableRow row = tri.next();
|
TableRow row = tri.next();
|
||||||
int fieldID = row.getIntColumn("metadata_field_id");
|
int fieldID = row.getIntColumn("metadata_field_id");
|
||||||
id2field.put(new Integer(fieldID), new MetadataField(row));
|
new_id2field.put(new Integer(fieldID), new MetadataField(row));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
// close the TableRowIterator to free up resources
|
// close the TableRowIterator to free up resources
|
||||||
|
if (tri != null)
|
||||||
tri.close();
|
tri.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
id2field = new_id2field;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -262,13 +262,19 @@ public class MetadataSchema
|
|||||||
namespace);
|
namespace);
|
||||||
|
|
||||||
TableRow row = null;
|
TableRow row = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
if (tri.hasNext())
|
if (tri.hasNext())
|
||||||
{
|
{
|
||||||
row = tri.next();
|
row = tri.next();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
// close the TableRowIterator to free up resources
|
// close the TableRowIterator to free up resources
|
||||||
|
if (tri != null)
|
||||||
tri.close();
|
tri.close();
|
||||||
|
}
|
||||||
|
|
||||||
if (row == null)
|
if (row == null)
|
||||||
{
|
{
|
||||||
@@ -360,13 +366,20 @@ public class MetadataSchema
|
|||||||
TableRowIterator tri = DatabaseManager.queryTable(context, "MetadataSchemaRegistry",
|
TableRowIterator tri = DatabaseManager.queryTable(context, "MetadataSchemaRegistry",
|
||||||
"SELECT * FROM MetadataSchemaRegistry ORDER BY metadata_schema_id");
|
"SELECT * FROM MetadataSchemaRegistry ORDER BY metadata_schema_id");
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
// Make into DC Type objects
|
// Make into DC Type objects
|
||||||
while (tri.hasNext())
|
while (tri.hasNext())
|
||||||
{
|
{
|
||||||
schemas.add(new MetadataSchema(tri.next()));
|
schemas.add(new MetadataSchema(tri.next()));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
// close the TableRowIterator to free up resources
|
// close the TableRowIterator to free up resources
|
||||||
|
if (tri != null)
|
||||||
tri.close();
|
tri.close();
|
||||||
|
}
|
||||||
|
|
||||||
// Convert list into an array
|
// Convert list into an array
|
||||||
MetadataSchema[] typeArray = new MetadataSchema[schemas.size()];
|
MetadataSchema[] typeArray = new MetadataSchema[schemas.size()];
|
||||||
@@ -385,23 +398,42 @@ public class MetadataSchema
|
|||||||
private boolean uniqueNamespace(Context context, String namespace)
|
private boolean uniqueNamespace(Context context, String namespace)
|
||||||
throws SQLException
|
throws SQLException
|
||||||
{
|
{
|
||||||
|
int count = 0;
|
||||||
Connection con = context.getDBConnection();
|
Connection con = context.getDBConnection();
|
||||||
|
PreparedStatement statement = null;
|
||||||
|
ResultSet rs = null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
TableRow reg = DatabaseManager.row("MetadataSchemaRegistry");
|
TableRow reg = DatabaseManager.row("MetadataSchemaRegistry");
|
||||||
|
|
||||||
String query = "SELECT COUNT(*) FROM " + reg.getTable() + " " +
|
String query = "SELECT COUNT(*) FROM " + reg.getTable() + " " +
|
||||||
"WHERE metadata_schema_id != ? " +
|
"WHERE metadata_schema_id != ? " +
|
||||||
"AND namespace= ? ";
|
"AND namespace= ? ";
|
||||||
PreparedStatement statement = con.prepareStatement(query);
|
|
||||||
|
statement = con.prepareStatement(query);
|
||||||
statement.setInt(1,schemaID);
|
statement.setInt(1,schemaID);
|
||||||
statement.setString(2,namespace);
|
statement.setString(2,namespace);
|
||||||
|
|
||||||
ResultSet rs = statement.executeQuery();
|
rs = statement.executeQuery();
|
||||||
|
|
||||||
int count = 0;
|
|
||||||
if (rs.next())
|
if (rs.next())
|
||||||
{
|
{
|
||||||
count = rs.getInt(1);
|
count = rs.getInt(1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (rs != null)
|
||||||
|
{
|
||||||
|
try { rs.close(); } catch (SQLException sqle) { }
|
||||||
|
}
|
||||||
|
|
||||||
|
if (statement != null)
|
||||||
|
{
|
||||||
|
try { statement.close(); } catch (SQLException sqle) { }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return (count == 0);
|
return (count == 0);
|
||||||
}
|
}
|
||||||
@@ -417,24 +449,42 @@ public class MetadataSchema
|
|||||||
private boolean uniqueShortName(Context context, String name)
|
private boolean uniqueShortName(Context context, String name)
|
||||||
throws SQLException
|
throws SQLException
|
||||||
{
|
{
|
||||||
|
int count = 0;
|
||||||
Connection con = context.getDBConnection();
|
Connection con = context.getDBConnection();
|
||||||
|
PreparedStatement statement = null;
|
||||||
|
ResultSet rs = null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
TableRow reg = DatabaseManager.row("MetadataSchemaRegistry");
|
TableRow reg = DatabaseManager.row("MetadataSchemaRegistry");
|
||||||
|
|
||||||
String query = "SELECT COUNT(*) FROM " + reg.getTable() + " " +
|
String query = "SELECT COUNT(*) FROM " + reg.getTable() + " " +
|
||||||
"WHERE metadata_schema_id != ? " +
|
"WHERE metadata_schema_id != ? " +
|
||||||
"AND short_id = ? ";
|
"AND short_id = ? ";
|
||||||
|
|
||||||
PreparedStatement statement = con.prepareStatement(query);
|
statement = con.prepareStatement(query);
|
||||||
statement.setInt(1,schemaID);
|
statement.setInt(1,schemaID);
|
||||||
statement.setString(2,name);
|
statement.setString(2,name);
|
||||||
|
|
||||||
ResultSet rs = statement.executeQuery();
|
rs = statement.executeQuery();
|
||||||
|
|
||||||
int count = 0;
|
|
||||||
if (rs.next())
|
if (rs.next())
|
||||||
{
|
{
|
||||||
count = rs.getInt(1);
|
count = rs.getInt(1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (rs != null)
|
||||||
|
{
|
||||||
|
try { rs.close(); } catch (SQLException sqle) { }
|
||||||
|
}
|
||||||
|
|
||||||
|
if (statement != null)
|
||||||
|
{
|
||||||
|
try { statement.close(); } catch (SQLException sqle) { }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return (count == 0);
|
return (count == 0);
|
||||||
}
|
}
|
||||||
@@ -501,21 +551,38 @@ public class MetadataSchema
|
|||||||
if (id2schema != null && name2schema != null)
|
if (id2schema != null && name2schema != null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
synchronized (MetadataSchema.class)
|
||||||
|
{
|
||||||
|
if (id2schema == null && name2schema == null)
|
||||||
|
{
|
||||||
log.info("Loading schema cache for fast finds");
|
log.info("Loading schema cache for fast finds");
|
||||||
id2schema = new HashMap();
|
HashMap new_id2schema = new HashMap();
|
||||||
name2schema = new HashMap();
|
HashMap new_name2schema = new HashMap();
|
||||||
|
|
||||||
TableRowIterator tri = DatabaseManager.queryTable(context,"MetadataSchemaRegistry",
|
TableRowIterator tri = DatabaseManager.queryTable(context,"MetadataSchemaRegistry",
|
||||||
"SELECT * from MetadataSchemaRegistry");
|
"SELECT * from MetadataSchemaRegistry");
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
while (tri.hasNext())
|
while (tri.hasNext())
|
||||||
{
|
{
|
||||||
TableRow row = tri.next();
|
TableRow row = tri.next();
|
||||||
|
|
||||||
MetadataSchema s = new MetadataSchema(row);
|
MetadataSchema s = new MetadataSchema(row);
|
||||||
id2schema.put(new Integer(s.schemaID), s);
|
new_id2schema.put(new Integer(s.schemaID), s);
|
||||||
name2schema.put(s.name, s);
|
new_name2schema.put(s.name, s);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
// close the TableRowIterator to free up resources
|
// close the TableRowIterator to free up resources
|
||||||
|
if (tri != null)
|
||||||
tri.close();
|
tri.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
id2schema = new_id2schema;
|
||||||
|
name2schema = new_name2schema;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -278,13 +278,19 @@ public class MetadataValue
|
|||||||
valueId);
|
valueId);
|
||||||
|
|
||||||
TableRow row = null;
|
TableRow row = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
if (tri.hasNext())
|
if (tri.hasNext())
|
||||||
{
|
{
|
||||||
row = tri.next();
|
row = tri.next();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
// close the TableRowIterator to free up resources
|
// close the TableRowIterator to free up resources
|
||||||
|
if (tri != null)
|
||||||
tri.close();
|
tri.close();
|
||||||
|
}
|
||||||
|
|
||||||
if (row == null)
|
if (row == null)
|
||||||
{
|
{
|
||||||
@@ -316,14 +322,20 @@ public class MetadataValue
|
|||||||
|
|
||||||
TableRow row = null;
|
TableRow row = null;
|
||||||
java.util.Collection ret = new ArrayList();
|
java.util.Collection ret = new ArrayList();
|
||||||
|
try
|
||||||
|
{
|
||||||
while (tri.hasNext())
|
while (tri.hasNext())
|
||||||
{
|
{
|
||||||
row = tri.next();
|
row = tri.next();
|
||||||
ret.add(new MetadataValue(row));
|
ret.add(new MetadataValue(row));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
// close the TableRowIterator to free up resources
|
// close the TableRowIterator to free up resources
|
||||||
|
if (tri != null)
|
||||||
tri.close();
|
tri.close();
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@@ -122,6 +122,8 @@ public class SupervisedItem extends WorkspaceItem
|
|||||||
"workspaceitem",
|
"workspaceitem",
|
||||||
query);
|
query);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
while (tri.hasNext())
|
while (tri.hasNext())
|
||||||
{
|
{
|
||||||
TableRow row = tri.next();
|
TableRow row = tri.next();
|
||||||
@@ -129,8 +131,13 @@ public class SupervisedItem extends WorkspaceItem
|
|||||||
|
|
||||||
sItems.add(si);
|
sItems.add(si);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
// close the TableRowIterator to free up resources
|
||||||
|
if (tri != null)
|
||||||
tri.close();
|
tri.close();
|
||||||
|
}
|
||||||
|
|
||||||
SupervisedItem[] siArray = new SupervisedItem[sItems.size()];
|
SupervisedItem[] siArray = new SupervisedItem[sItems.size()];
|
||||||
siArray = (SupervisedItem[]) sItems.toArray(siArray);
|
siArray = (SupervisedItem[]) sItems.toArray(siArray);
|
||||||
@@ -160,6 +167,8 @@ public class SupervisedItem extends WorkspaceItem
|
|||||||
|
|
||||||
TableRowIterator tri = DatabaseManager.queryTable(c,"epersongroup",query, wi);
|
TableRowIterator tri = DatabaseManager.queryTable(c,"epersongroup",query, wi);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
while (tri.hasNext())
|
while (tri.hasNext())
|
||||||
{
|
{
|
||||||
TableRow row = tri.next();
|
TableRow row = tri.next();
|
||||||
@@ -167,8 +176,13 @@ public class SupervisedItem extends WorkspaceItem
|
|||||||
|
|
||||||
groupList.add(group);
|
groupList.add(group);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
// close the TableRowIterator to free up resources
|
||||||
|
if (tri != null)
|
||||||
tri.close();
|
tri.close();
|
||||||
|
}
|
||||||
|
|
||||||
Group[] groupArray = new Group[groupList.size()];
|
Group[] groupArray = new Group[groupList.size()];
|
||||||
groupArray = (Group[]) groupList.toArray(groupArray);
|
groupArray = (Group[]) groupList.toArray(groupArray);
|
||||||
@@ -202,6 +216,8 @@ public class SupervisedItem extends WorkspaceItem
|
|||||||
"epersongroup",
|
"epersongroup",
|
||||||
query, this.getID());
|
query, this.getID());
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
while (tri.hasNext())
|
while (tri.hasNext())
|
||||||
{
|
{
|
||||||
TableRow row = tri.next();
|
TableRow row = tri.next();
|
||||||
@@ -210,8 +226,13 @@ public class SupervisedItem extends WorkspaceItem
|
|||||||
|
|
||||||
groupList.add(group);
|
groupList.add(group);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
// close the TableRowIterator to free up resources
|
||||||
|
if (tri != null)
|
||||||
tri.close();
|
tri.close();
|
||||||
|
}
|
||||||
|
|
||||||
Group[] groupArray = new Group[groupList.size()];
|
Group[] groupArray = new Group[groupList.size()];
|
||||||
groupArray = (Group[]) groupList.toArray(groupArray);
|
groupArray = (Group[]) groupList.toArray(groupArray);
|
||||||
@@ -245,14 +266,21 @@ public class SupervisedItem extends WorkspaceItem
|
|||||||
"workspaceitem",
|
"workspaceitem",
|
||||||
query,ep.getID());
|
query,ep.getID());
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
while (tri.hasNext())
|
while (tri.hasNext())
|
||||||
{
|
{
|
||||||
TableRow row = tri.next();
|
TableRow row = tri.next();
|
||||||
SupervisedItem si = new SupervisedItem(context, row);
|
SupervisedItem si = new SupervisedItem(context, row);
|
||||||
sItems.add(si);
|
sItems.add(si);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
// close the TableRowIterator to free up resources
|
||||||
|
if (tri != null)
|
||||||
tri.close();
|
tri.close();
|
||||||
|
}
|
||||||
|
|
||||||
SupervisedItem[] siArray = new SupervisedItem[sItems.size()];
|
SupervisedItem[] siArray = new SupervisedItem[sItems.size()];
|
||||||
siArray = (SupervisedItem[]) sItems.toArray(siArray);
|
siArray = (SupervisedItem[]) sItems.toArray(siArray);
|
||||||
|
@@ -312,6 +312,8 @@ public class WorkspaceItem implements InProgressSubmission
|
|||||||
"ORDER BY workspaceitem.workspace_item_id",
|
"ORDER BY workspaceitem.workspace_item_id",
|
||||||
ep.getID());
|
ep.getID());
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
while (tri.hasNext())
|
while (tri.hasNext())
|
||||||
{
|
{
|
||||||
TableRow row = tri.next();
|
TableRow row = tri.next();
|
||||||
@@ -327,8 +329,13 @@ public class WorkspaceItem implements InProgressSubmission
|
|||||||
|
|
||||||
wsItems.add(wi);
|
wsItems.add(wi);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
// close the TableRowIterator to free up resources
|
// close the TableRowIterator to free up resources
|
||||||
|
if (tri != null)
|
||||||
tri.close();
|
tri.close();
|
||||||
|
}
|
||||||
|
|
||||||
WorkspaceItem[] wsArray = new WorkspaceItem[wsItems.size()];
|
WorkspaceItem[] wsArray = new WorkspaceItem[wsItems.size()];
|
||||||
wsArray = (WorkspaceItem[]) wsItems.toArray(wsArray);
|
wsArray = (WorkspaceItem[]) wsItems.toArray(wsArray);
|
||||||
@@ -356,6 +363,8 @@ public class WorkspaceItem implements InProgressSubmission
|
|||||||
"workspaceitem.collection_id= ? ",
|
"workspaceitem.collection_id= ? ",
|
||||||
c.getID());
|
c.getID());
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
while (tri.hasNext())
|
while (tri.hasNext())
|
||||||
{
|
{
|
||||||
TableRow row = tri.next();
|
TableRow row = tri.next();
|
||||||
@@ -372,8 +381,13 @@ public class WorkspaceItem implements InProgressSubmission
|
|||||||
|
|
||||||
wsItems.add(wi);
|
wsItems.add(wi);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
// close the TableRowIterator to free up resources
|
// close the TableRowIterator to free up resources
|
||||||
|
if (tri != null)
|
||||||
tri.close();
|
tri.close();
|
||||||
|
}
|
||||||
|
|
||||||
WorkspaceItem[] wsArray = new WorkspaceItem[wsItems.size()];
|
WorkspaceItem[] wsArray = new WorkspaceItem[wsItems.size()];
|
||||||
wsArray = (WorkspaceItem[]) wsItems.toArray(wsArray);
|
wsArray = (WorkspaceItem[]) wsItems.toArray(wsArray);
|
||||||
@@ -397,6 +411,8 @@ public class WorkspaceItem implements InProgressSubmission
|
|||||||
"workspaceitem",
|
"workspaceitem",
|
||||||
query);
|
query);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
while (tri.hasNext())
|
while (tri.hasNext())
|
||||||
{
|
{
|
||||||
TableRow row = tri.next();
|
TableRow row = tri.next();
|
||||||
@@ -413,8 +429,13 @@ public class WorkspaceItem implements InProgressSubmission
|
|||||||
|
|
||||||
wsItems.add(wi);
|
wsItems.add(wi);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
// close the TableRowIterator to free up resources
|
||||||
|
if (tri != null)
|
||||||
tri.close();
|
tri.close();
|
||||||
|
}
|
||||||
|
|
||||||
WorkspaceItem[] wsArray = new WorkspaceItem[wsItems.size()];
|
WorkspaceItem[] wsArray = new WorkspaceItem[wsItems.size()];
|
||||||
wsArray = (WorkspaceItem[]) wsItems.toArray(wsArray);
|
wsArray = (WorkspaceItem[]) wsItems.toArray(wsArray);
|
||||||
|
@@ -260,9 +260,11 @@ public class MODSDisseminationCrosswalk extends SelfNamedPlugin
|
|||||||
File.separator + "config" + File.separator;
|
File.separator + "config" + File.separator;
|
||||||
File propsFile = new File(parent, propsFilename);
|
File propsFile = new File(parent, propsFilename);
|
||||||
Properties modsConfig = new Properties();
|
Properties modsConfig = new Properties();
|
||||||
|
FileInputStream pfs = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
modsConfig.load(new FileInputStream(propsFile));
|
pfs = new FileInputStream(propsFile);
|
||||||
|
modsConfig.load(pfs);
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
@@ -270,6 +272,12 @@ public class MODSDisseminationCrosswalk extends SelfNamedPlugin
|
|||||||
throw new CrosswalkInternalException("MODS crosswalk cannot "+
|
throw new CrosswalkInternalException("MODS crosswalk cannot "+
|
||||||
"open config file: "+e.toString());
|
"open config file: "+e.toString());
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (pfs != null)
|
||||||
|
try { pfs.close(); } catch (IOException ioe) { }
|
||||||
|
}
|
||||||
|
|
||||||
modsMap = new HashMap();
|
modsMap = new HashMap();
|
||||||
Enumeration pe = modsConfig.propertyNames();
|
Enumeration pe = modsConfig.propertyNames();
|
||||||
while (pe.hasMoreElements())
|
while (pe.hasMoreElements())
|
||||||
|
@@ -280,7 +280,17 @@ public class QDCCrosswalk extends SelfNamedPlugin
|
|||||||
File.separator + "config" + File.separator;
|
File.separator + "config" + File.separator;
|
||||||
File propsFile = new File(parent, propsFilename);
|
File propsFile = new File(parent, propsFilename);
|
||||||
Properties qdcProps = new Properties();
|
Properties qdcProps = new Properties();
|
||||||
qdcProps.load(new FileInputStream(propsFile));
|
FileInputStream pfs = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
pfs = new FileInputStream(propsFile);
|
||||||
|
qdcProps.load(pfs);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (pfs != null)
|
||||||
|
try { pfs.close(); } catch (IOException ioe) { }
|
||||||
|
}
|
||||||
|
|
||||||
// grovel properties to initialize qdc->element and element->qdc maps.
|
// grovel properties to initialize qdc->element and element->qdc maps.
|
||||||
// evaluate the XML fragment with a wrapper including namespaces.
|
// evaluate the XML fragment with a wrapper including namespaces.
|
||||||
|
@@ -120,7 +120,16 @@ public class XHTMLHeadDisseminationCrosswalk extends SelfNamedPlugin implements
|
|||||||
|
|
||||||
// Read in configuration
|
// Read in configuration
|
||||||
Properties crosswalkProps = new Properties();
|
Properties crosswalkProps = new Properties();
|
||||||
crosswalkProps.load(new FileInputStream(config));
|
FileInputStream fis = new FileInputStream(config);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
crosswalkProps.load(fis);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (fis != null)
|
||||||
|
try { fis.close(); } catch (IOException ioe) { }
|
||||||
|
}
|
||||||
|
|
||||||
Enumeration e = crosswalkProps.keys();
|
Enumeration e = crosswalkProps.keys();
|
||||||
while (e.hasMoreElements())
|
while (e.hasMoreElements())
|
||||||
|
@@ -177,9 +177,12 @@ public class ConfigurationManager
|
|||||||
{
|
{
|
||||||
// Load in default license
|
// Load in default license
|
||||||
|
|
||||||
|
FileReader fr = null;
|
||||||
|
BufferedReader br = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
BufferedReader br = new BufferedReader(new FileReader(licenseFile));
|
fr = new FileReader(licenseFile);
|
||||||
|
br = new BufferedReader(fr);
|
||||||
String lineIn;
|
String lineIn;
|
||||||
license = "";
|
license = "";
|
||||||
while ((lineIn = br.readLine()) != null)
|
while ((lineIn = br.readLine()) != null)
|
||||||
@@ -195,6 +198,15 @@ public class ConfigurationManager
|
|||||||
// configuration we can't do anything
|
// configuration we can't do anything
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (br != null)
|
||||||
|
try { br.close(); } catch (IOException ioe) { }
|
||||||
|
|
||||||
|
if (fr != null)
|
||||||
|
try { fr.close(); } catch (IOException ioe) { }
|
||||||
|
}
|
||||||
|
|
||||||
return license;
|
return license;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -480,6 +492,7 @@ public class ConfigurationManager
|
|||||||
protected static File getConfigurationFile()
|
protected static File getConfigurationFile()
|
||||||
{
|
{
|
||||||
// in case it hasn't been done yet.
|
// in case it hasn't been done yet.
|
||||||
|
if (loadedFile == null)
|
||||||
loadConfig(null);
|
loadConfig(null);
|
||||||
|
|
||||||
return loadedFile;
|
return loadedFile;
|
||||||
@@ -494,7 +507,7 @@ public class ConfigurationManager
|
|||||||
* The <code>dspace.cfg</code> configuration file to use, or
|
* The <code>dspace.cfg</code> configuration file to use, or
|
||||||
* <code>null</code> to try default locations
|
* <code>null</code> to try default locations
|
||||||
*/
|
*/
|
||||||
public static void loadConfig(String configFile)
|
public static synchronized void loadConfig(String configFile)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (properties != null)
|
if (properties != null)
|
||||||
@@ -505,6 +518,7 @@ public class ConfigurationManager
|
|||||||
|
|
||||||
URL url = null;
|
URL url = null;
|
||||||
|
|
||||||
|
InputStream is = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
String configProperty = null;
|
String configProperty = null;
|
||||||
@@ -556,7 +570,8 @@ public class ConfigurationManager
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
properties = new Properties();
|
properties = new Properties();
|
||||||
properties.load(url.openStream());
|
is = url.openStream();
|
||||||
|
properties.load(is);
|
||||||
|
|
||||||
// walk values, interpolating any embedded references.
|
// walk values, interpolating any embedded references.
|
||||||
for (Enumeration pe = properties.propertyNames(); pe.hasMoreElements(); )
|
for (Enumeration pe = properties.propertyNames(); pe.hasMoreElements(); )
|
||||||
@@ -577,16 +592,25 @@ public class ConfigurationManager
|
|||||||
// configuration we can't do anything
|
// configuration we can't do anything
|
||||||
throw new RuntimeException("Cannot load configuration: " + url, e);
|
throw new RuntimeException("Cannot load configuration: " + url, e);
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (is != null)
|
||||||
|
try { is.close(); } catch (IOException ioe) { }
|
||||||
|
}
|
||||||
|
|
||||||
// Load in default license
|
// Load in default license
|
||||||
File licenseFile = new File(getProperty("dspace.dir") + File.separator
|
File licenseFile = new File(getProperty("dspace.dir") + File.separator
|
||||||
+ "config" + File.separator + "default.license");
|
+ "config" + File.separator + "default.license");
|
||||||
|
|
||||||
|
FileInputStream fir = null;
|
||||||
|
InputStreamReader ir = null;
|
||||||
|
BufferedReader br = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
||||||
FileInputStream fir = new FileInputStream(licenseFile);
|
fir = new FileInputStream(licenseFile);
|
||||||
InputStreamReader ir = new InputStreamReader(fir, "UTF-8");
|
ir = new InputStreamReader(fir, "UTF-8");
|
||||||
BufferedReader br = new BufferedReader(ir);
|
br = new BufferedReader(ir);
|
||||||
String lineIn;
|
String lineIn;
|
||||||
license = "";
|
license = "";
|
||||||
|
|
||||||
@@ -606,6 +630,17 @@ public class ConfigurationManager
|
|||||||
// configuration we can't do anything
|
// configuration we can't do anything
|
||||||
throw new RuntimeException("Cannot load license: " + licenseFile.toString(),e);
|
throw new RuntimeException("Cannot load license: " + licenseFile.toString(),e);
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (br != null)
|
||||||
|
try { br.close(); } catch (IOException ioe) { }
|
||||||
|
|
||||||
|
if (ir != null)
|
||||||
|
try { ir.close(); } catch (IOException ioe) { }
|
||||||
|
|
||||||
|
if (fir != null)
|
||||||
|
try { fir.close(); } catch (IOException ioe) { }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -84,9 +84,8 @@ public class LogManager
|
|||||||
contextExtraInfo = "no_context";
|
contextExtraInfo = "no_context";
|
||||||
}
|
}
|
||||||
|
|
||||||
String result = new String(email + ":" + contextExtraInfo + ":"
|
StringBuilder result = new StringBuilder();
|
||||||
+ action + ":" + extrainfo);
|
result.append(email).append(":").append(contextExtraInfo).append(":").append(action).append(":").append(extrainfo);
|
||||||
|
return result.toString();
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -564,6 +564,9 @@ public class PluginManager
|
|||||||
public static void checkConfiguration()
|
public static void checkConfiguration()
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
|
FileReader fr = null;
|
||||||
|
BufferedReader cr = null;
|
||||||
|
|
||||||
/* XXX TODO: (maybe) test that implementation class is really a
|
/* XXX TODO: (maybe) test that implementation class is really a
|
||||||
* subclass or impl of the plugin "interface"
|
* subclass or impl of the plugin "interface"
|
||||||
*/
|
*/
|
||||||
@@ -574,15 +577,18 @@ public class PluginManager
|
|||||||
Map namedKey = new HashMap();
|
Map namedKey = new HashMap();
|
||||||
Map selfnamedKey = new HashMap();
|
Map selfnamedKey = new HashMap();
|
||||||
Map reusableKey = new HashMap();
|
Map reusableKey = new HashMap();
|
||||||
|
HashMap keyMap = new HashMap();
|
||||||
|
|
||||||
// 1. First pass -- grovel the actual config file to check for
|
// 1. First pass -- grovel the actual config file to check for
|
||||||
// duplicate keys, since Properties class hides them from us.
|
// duplicate keys, since Properties class hides them from us.
|
||||||
// Also build lists of each type of key, check for misspellings.
|
// Also build lists of each type of key, check for misspellings.
|
||||||
File config = ConfigurationManager.getConfigurationFile();
|
File config = ConfigurationManager.getConfigurationFile();
|
||||||
BufferedReader cr = new BufferedReader(new FileReader(config));
|
try
|
||||||
|
{
|
||||||
|
fr = new FileReader(config);
|
||||||
|
cr = new BufferedReader(fr);
|
||||||
String line = null;
|
String line = null;
|
||||||
boolean continued = false;
|
boolean continued = false;
|
||||||
HashMap keyMap = new HashMap();
|
|
||||||
Pattern keyPattern = Pattern.compile("([^\\s\\=\\:]+)");
|
Pattern keyPattern = Pattern.compile("([^\\s\\=\\:]+)");
|
||||||
while ((line = cr.readLine()) != null)
|
while ((line = cr.readLine()) != null)
|
||||||
{
|
{
|
||||||
@@ -619,6 +625,15 @@ public class PluginManager
|
|||||||
continued = line.length() > 0 && line.charAt(line.length()-1) == '\\';
|
continued = line.length() > 0 && line.charAt(line.length()-1) == '\\';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (cr != null)
|
||||||
|
try { cr.close(); } catch (IOException ioe) { }
|
||||||
|
|
||||||
|
if (fr != null)
|
||||||
|
try { fr.close(); } catch (IOException ioe) { }
|
||||||
|
}
|
||||||
|
|
||||||
// 1.1 Sanity check, make sure keyMap == set of keys from Configuration
|
// 1.1 Sanity check, make sure keyMap == set of keys from Configuration
|
||||||
Enumeration pne = ConfigurationManager.propertyNames();
|
Enumeration pne = ConfigurationManager.propertyNames();
|
||||||
|
@@ -908,36 +908,57 @@ public class EPerson extends DSpaceObject
|
|||||||
"SELECT * from item where submitter_id= ? ",
|
"SELECT * from item where submitter_id= ? ",
|
||||||
getID());
|
getID());
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
if (tri.hasNext())
|
if (tri.hasNext())
|
||||||
{
|
{
|
||||||
tableList.add("item");
|
tableList.add("item");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
// close the TableRowIterator to free up resources
|
||||||
|
if (tri != null)
|
||||||
tri.close();
|
tri.close();
|
||||||
|
}
|
||||||
|
|
||||||
// check for eperson in workflowitem table
|
// check for eperson in workflowitem table
|
||||||
tri = DatabaseManager.query(myContext,
|
tri = DatabaseManager.query(myContext,
|
||||||
"SELECT * from workflowitem where owner= ? ",
|
"SELECT * from workflowitem where owner= ? ",
|
||||||
getID());
|
getID());
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
if (tri.hasNext())
|
if (tri.hasNext())
|
||||||
{
|
{
|
||||||
tableList.add("workflowitem");
|
tableList.add("workflowitem");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
// close the TableRowIterator to free up resources
|
||||||
|
if (tri != null)
|
||||||
tri.close();
|
tri.close();
|
||||||
|
}
|
||||||
|
|
||||||
// check for eperson in tasklistitem table
|
// check for eperson in tasklistitem table
|
||||||
tri = DatabaseManager.query(myContext,
|
tri = DatabaseManager.query(myContext,
|
||||||
"SELECT * from tasklistitem where eperson_id= ? ",
|
"SELECT * from tasklistitem where eperson_id= ? ",
|
||||||
getID());
|
getID());
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
if (tri.hasNext())
|
if (tri.hasNext())
|
||||||
{
|
{
|
||||||
tableList.add("tasklistitem");
|
tableList.add("tasklistitem");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
// close the TableRowIterator to free up resources
|
||||||
|
if (tri != null)
|
||||||
tri.close();
|
tri.close();
|
||||||
|
}
|
||||||
|
|
||||||
// the list of tables can be used to construct an error message
|
// the list of tables can be used to construct an error message
|
||||||
// explaining to the user why the eperson cannot be deleted.
|
// explaining to the user why the eperson cannot be deleted.
|
||||||
|
@@ -141,6 +141,8 @@ public class Group extends DSpaceObject
|
|||||||
"epersongroup2eperson.eperson_group_id= ?",
|
"epersongroup2eperson.eperson_group_id= ?",
|
||||||
myRow.getIntColumn("eperson_group_id"));
|
myRow.getIntColumn("eperson_group_id"));
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
while (tri.hasNext())
|
while (tri.hasNext())
|
||||||
{
|
{
|
||||||
TableRow r = (TableRow) tri.next();
|
TableRow r = (TableRow) tri.next();
|
||||||
@@ -158,8 +160,13 @@ public class Group extends DSpaceObject
|
|||||||
epeople.add(new EPerson(myContext, r));
|
epeople.add(new EPerson(myContext, r));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
// close the TableRowIterator to free up resources
|
||||||
|
if (tri != null)
|
||||||
tri.close();
|
tri.close();
|
||||||
|
}
|
||||||
|
|
||||||
// now get Group objects
|
// now get Group objects
|
||||||
tri = DatabaseManager.queryTable(myContext,"epersongroup",
|
tri = DatabaseManager.queryTable(myContext,"epersongroup",
|
||||||
@@ -168,6 +175,8 @@ public class Group extends DSpaceObject
|
|||||||
"group2group.parent_id= ? ",
|
"group2group.parent_id= ? ",
|
||||||
myRow.getIntColumn("eperson_group_id"));
|
myRow.getIntColumn("eperson_group_id"));
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
while (tri.hasNext())
|
while (tri.hasNext())
|
||||||
{
|
{
|
||||||
TableRow r = (TableRow) tri.next();
|
TableRow r = (TableRow) tri.next();
|
||||||
@@ -185,8 +194,13 @@ public class Group extends DSpaceObject
|
|||||||
groups.add(new Group(myContext, r));
|
groups.add(new Group(myContext, r));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
// close the TableRowIterator to free up resources
|
||||||
|
if (tri != null)
|
||||||
tri.close();
|
tri.close();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
@@ -449,6 +463,8 @@ public class Group extends DSpaceObject
|
|||||||
|
|
||||||
Set<Integer> groupIDs = new HashSet<Integer>();
|
Set<Integer> groupIDs = new HashSet<Integer>();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
while (tri.hasNext())
|
while (tri.hasNext())
|
||||||
{
|
{
|
||||||
TableRow row = tri.next();
|
TableRow row = tri.next();
|
||||||
@@ -457,8 +473,13 @@ public class Group extends DSpaceObject
|
|||||||
|
|
||||||
groupIDs.add(new Integer(childID));
|
groupIDs.add(new Integer(childID));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
// close the TableRowIterator to free up resources
|
||||||
|
if (tri != null)
|
||||||
tri.close();
|
tri.close();
|
||||||
|
}
|
||||||
|
|
||||||
// Also need to get all "Special Groups" user is a member of!
|
// Also need to get all "Special Groups" user is a member of!
|
||||||
// Otherwise, you're ignoring the user's membership to these groups!
|
// Otherwise, you're ignoring the user's membership to these groups!
|
||||||
@@ -501,6 +522,8 @@ public class Group extends DSpaceObject
|
|||||||
"SELECT * FROM group2groupcache WHERE " + groupQuery,
|
"SELECT * FROM group2groupcache WHERE " + groupQuery,
|
||||||
parameters);
|
parameters);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
while (tri.hasNext())
|
while (tri.hasNext())
|
||||||
{
|
{
|
||||||
TableRow row = tri.next();
|
TableRow row = tri.next();
|
||||||
@@ -509,8 +532,13 @@ public class Group extends DSpaceObject
|
|||||||
|
|
||||||
groupIDs.add(new Integer(parentID));
|
groupIDs.add(new Integer(parentID));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
// close the TableRowIterator to free up resources
|
||||||
|
if (tri != null)
|
||||||
tri.close();
|
tri.close();
|
||||||
|
}
|
||||||
|
|
||||||
return groupIDs;
|
return groupIDs;
|
||||||
}
|
}
|
||||||
@@ -570,6 +598,8 @@ public class Group extends DSpaceObject
|
|||||||
|
|
||||||
Set<Integer> groupIDs = new HashSet<Integer>();
|
Set<Integer> groupIDs = new HashSet<Integer>();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
while (tri.hasNext())
|
while (tri.hasNext())
|
||||||
{
|
{
|
||||||
TableRow row = tri.next();
|
TableRow row = tri.next();
|
||||||
@@ -578,8 +608,13 @@ public class Group extends DSpaceObject
|
|||||||
|
|
||||||
groupIDs.add(new Integer(childID));
|
groupIDs.add(new Integer(childID));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
// close the TableRowIterator to free up resources
|
||||||
|
if (tri != null)
|
||||||
tri.close();
|
tri.close();
|
||||||
|
}
|
||||||
|
|
||||||
// now we have all the groups (including this one)
|
// now we have all the groups (including this one)
|
||||||
// it is time to find all the EPeople who belong to those groups
|
// it is time to find all the EPeople who belong to those groups
|
||||||
@@ -612,6 +647,8 @@ public class Group extends DSpaceObject
|
|||||||
"SELECT * FROM epersongroup2eperson WHERE " + epersonQuery,
|
"SELECT * FROM epersongroup2eperson WHERE " + epersonQuery,
|
||||||
parameters);
|
parameters);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
while (tri.hasNext())
|
while (tri.hasNext())
|
||||||
{
|
{
|
||||||
TableRow row = tri.next();
|
TableRow row = tri.next();
|
||||||
@@ -620,8 +657,13 @@ public class Group extends DSpaceObject
|
|||||||
|
|
||||||
epeopleIDs.add(new Integer(epersonID));
|
epeopleIDs.add(new Integer(epersonID));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
// close the TableRowIterator to free up resources
|
||||||
|
if (tri != null)
|
||||||
tri.close();
|
tri.close();
|
||||||
|
}
|
||||||
|
|
||||||
return epeopleIDs;
|
return epeopleIDs;
|
||||||
}
|
}
|
||||||
@@ -1135,6 +1177,8 @@ public class Group extends DSpaceObject
|
|||||||
|
|
||||||
Map<Integer,Set<Integer>> parents = new HashMap<Integer,Set<Integer>>();
|
Map<Integer,Set<Integer>> parents = new HashMap<Integer,Set<Integer>>();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
while (tri.hasNext())
|
while (tri.hasNext())
|
||||||
{
|
{
|
||||||
TableRow row = (TableRow) tri.next();
|
TableRow row = (TableRow) tri.next();
|
||||||
@@ -1159,8 +1203,13 @@ public class Group extends DSpaceObject
|
|||||||
children.add(childID);
|
children.add(childID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
// close the TableRowIterator to free up resources
|
||||||
|
if (tri != null)
|
||||||
tri.close();
|
tri.close();
|
||||||
|
}
|
||||||
|
|
||||||
// now parents is a hash of all of the IDs of groups that are parents
|
// now parents is a hash of all of the IDs of groups that are parents
|
||||||
// and each hash entry is a hash of all of the IDs of children of those
|
// and each hash entry is a hash of all of the IDs of children of those
|
||||||
|
@@ -112,6 +112,8 @@ public class Subscribe
|
|||||||
" AND collection_id= ? ",
|
" AND collection_id= ? ",
|
||||||
eperson.getID(),collection.getID());
|
eperson.getID(),collection.getID());
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
if (!r.hasNext())
|
if (!r.hasNext())
|
||||||
{
|
{
|
||||||
// Not subscribed, so add them
|
// Not subscribed, so add them
|
||||||
@@ -124,9 +126,14 @@ public class Subscribe
|
|||||||
"eperson_id=" + eperson.getID() + ",collection_id="
|
"eperson_id=" + eperson.getID() + ",collection_id="
|
||||||
+ collection.getID()));
|
+ collection.getID()));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
// close the TableRowIterator to free up resources
|
||||||
|
if (r != null)
|
||||||
r.close();
|
r.close();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new AuthorizeException(
|
throw new AuthorizeException(
|
||||||
@@ -198,6 +205,8 @@ public class Subscribe
|
|||||||
|
|
||||||
List collections = new ArrayList();
|
List collections = new ArrayList();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
while (tri.hasNext())
|
while (tri.hasNext())
|
||||||
{
|
{
|
||||||
TableRow row = tri.next();
|
TableRow row = tri.next();
|
||||||
@@ -205,8 +214,13 @@ public class Subscribe
|
|||||||
collections.add(Collection.find(context, row
|
collections.add(Collection.find(context, row
|
||||||
.getIntColumn("collection_id")));
|
.getIntColumn("collection_id")));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
// close the TableRowIterator to free up resources
|
||||||
|
if (tri != null)
|
||||||
tri.close();
|
tri.close();
|
||||||
|
}
|
||||||
|
|
||||||
Collection[] collArray = new Collection[collections.size()];
|
Collection[] collArray = new Collection[collections.size()];
|
||||||
|
|
||||||
@@ -232,10 +246,16 @@ public class Subscribe
|
|||||||
"AND collection_id= ? ",
|
"AND collection_id= ? ",
|
||||||
eperson.getID(),collection.getID());
|
eperson.getID(),collection.getID());
|
||||||
|
|
||||||
boolean result = tri.hasNext();
|
try
|
||||||
|
{
|
||||||
|
return tri.hasNext();
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
// close the TableRowIterator to free up resources
|
||||||
|
if (tri != null)
|
||||||
tri.close();
|
tri.close();
|
||||||
|
}
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -265,6 +285,8 @@ public class Subscribe
|
|||||||
EPerson currentEPerson = null;
|
EPerson currentEPerson = null;
|
||||||
List collections = null; // List of Collections
|
List collections = null; // List of Collections
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
// Go through the list collating subscriptions for each e-person
|
// Go through the list collating subscriptions for each e-person
|
||||||
while (tri.hasNext())
|
while (tri.hasNext())
|
||||||
{
|
{
|
||||||
@@ -299,8 +321,13 @@ public class Subscribe
|
|||||||
collections.add(Collection.find(context, row
|
collections.add(Collection.find(context, row
|
||||||
.getIntColumn("collection_id")));
|
.getIntColumn("collection_id")));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
// close the TableRowIterator to free up resources
|
||||||
|
if (tri != null)
|
||||||
tri.close();
|
tri.close();
|
||||||
|
}
|
||||||
|
|
||||||
// Process the last person
|
// Process the last person
|
||||||
if (currentEPerson != null)
|
if (currentEPerson != null)
|
||||||
|
@@ -109,9 +109,16 @@ public class Supervisor {
|
|||||||
"epersongroup2workspaceitem",
|
"epersongroup2workspaceitem",
|
||||||
query,groupID,wsItemID);
|
query,groupID,wsItemID);
|
||||||
|
|
||||||
boolean result = tri.hasNext();
|
try
|
||||||
|
{
|
||||||
|
return tri.hasNext();
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
// close the TableRowIterator to free up resources
|
||||||
|
if (tri != null)
|
||||||
tri.close();
|
tri.close();
|
||||||
return result;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -327,13 +327,20 @@ public class HandleManager
|
|||||||
TableRowIterator iterator = DatabaseManager.queryTable(context, null, sql, prefix+"%");
|
TableRowIterator iterator = DatabaseManager.queryTable(context, null, sql, prefix+"%");
|
||||||
List results = new ArrayList();
|
List results = new ArrayList();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
while (iterator.hasNext())
|
while (iterator.hasNext())
|
||||||
{
|
{
|
||||||
TableRow row = (TableRow) iterator.next();
|
TableRow row = (TableRow) iterator.next();
|
||||||
results.add(row.getStringColumn("handle"));
|
results.add(row.getStringColumn("handle"));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
// close the TableRowIterator to free up resources
|
||||||
|
if (iterator != null)
|
||||||
iterator.close();
|
iterator.close();
|
||||||
|
}
|
||||||
|
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
@@ -228,6 +228,8 @@ public class Harvest
|
|||||||
List infoObjects = new LinkedList();
|
List infoObjects = new LinkedList();
|
||||||
int index = 0;
|
int index = 0;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
// Process results of query into HarvestedItemInfo objects
|
// Process results of query into HarvestedItemInfo objects
|
||||||
while (tri.hasNext())
|
while (tri.hasNext())
|
||||||
{
|
{
|
||||||
@@ -264,7 +266,13 @@ public class Harvest
|
|||||||
|
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
// close the TableRowIterator to free up resources
|
||||||
|
if (tri != null)
|
||||||
tri.close();
|
tri.close();
|
||||||
|
}
|
||||||
|
|
||||||
return infoObjects;
|
return infoObjects;
|
||||||
}
|
}
|
||||||
|
@@ -107,7 +107,6 @@ public class OrderFormat
|
|||||||
{
|
{
|
||||||
return delegate.makeSortString(value, language);
|
return delegate.makeSortString(value, language);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// No delegates found, so apply defaults
|
// No delegates found, so apply defaults
|
||||||
if (type.equalsIgnoreCase(OrderFormat.AUTHOR) && authorDelegate != null)
|
if (type.equalsIgnoreCase(OrderFormat.AUTHOR) && authorDelegate != null)
|
||||||
@@ -124,6 +123,7 @@ public class OrderFormat
|
|||||||
{
|
{
|
||||||
return textDelegate.makeSortString(value, language);
|
return textDelegate.makeSortString(value, language);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
@@ -305,12 +305,17 @@ public class SortOption
|
|||||||
if (SortOption.sortOptionsMap != null)
|
if (SortOption.sortOptionsMap != null)
|
||||||
return SortOption.sortOptionsMap;
|
return SortOption.sortOptionsMap;
|
||||||
|
|
||||||
SortOption.sortOptionsMap = new HashMap<Integer, SortOption>();
|
synchronized (SortOption.class)
|
||||||
synchronized (SortOption.sortOptionsMap)
|
|
||||||
{
|
{
|
||||||
|
if (SortOption.sortOptionsMap == null)
|
||||||
|
{
|
||||||
|
Map<Integer, SortOption> newSortOptionsMap = new HashMap<Integer, SortOption>();
|
||||||
for (SortOption so : SortOption.getSortOptions())
|
for (SortOption so : SortOption.getSortOptions())
|
||||||
{
|
{
|
||||||
SortOption.sortOptionsMap.put(new Integer(so.getNumber()), so);
|
newSortOptionsMap.put(new Integer(so.getNumber()), so);
|
||||||
|
}
|
||||||
|
|
||||||
|
SortOption.sortOptionsMap = newSortOptionsMap;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -327,18 +332,23 @@ public class SortOption
|
|||||||
if (SortOption.sortOptionsSet != null)
|
if (SortOption.sortOptionsSet != null)
|
||||||
return SortOption.sortOptionsSet;
|
return SortOption.sortOptionsSet;
|
||||||
|
|
||||||
SortOption.sortOptionsSet = new HashSet<SortOption>();
|
synchronized (SortOption.class)
|
||||||
synchronized (SortOption.sortOptionsSet)
|
|
||||||
{
|
{
|
||||||
|
if (SortOption.sortOptionsSet == null)
|
||||||
|
{
|
||||||
|
Set<SortOption> newSortOptionsSet = new HashSet<SortOption>();
|
||||||
int idx = 1;
|
int idx = 1;
|
||||||
String option;
|
String option;
|
||||||
|
|
||||||
while ( ((option = ConfigurationManager.getProperty("webui.itemlist.sort-option." + idx))) != null)
|
while ( ((option = ConfigurationManager.getProperty("webui.itemlist.sort-option." + idx))) != null)
|
||||||
{
|
{
|
||||||
SortOption so = new SortOption(idx, option);
|
SortOption so = new SortOption(idx, option);
|
||||||
SortOption.sortOptionsSet.add(so);
|
newSortOptionsSet.add(so);
|
||||||
idx++;
|
idx++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SortOption.sortOptionsSet = newSortOptionsSet;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return SortOption.sortOptionsSet;
|
return SortOption.sortOptionsSet;
|
||||||
|
@@ -352,9 +352,13 @@ public class BitstreamStorageManager
|
|||||||
|
|
||||||
bitstream.setColumn("size_bytes", file.length());
|
bitstream.setColumn("size_bytes", file.length());
|
||||||
|
|
||||||
|
if (dis != null)
|
||||||
|
{
|
||||||
bitstream.setColumn("checksum", Utils.toHex(dis.getMessageDigest()
|
bitstream.setColumn("checksum", Utils.toHex(dis.getMessageDigest()
|
||||||
.digest()));
|
.digest()));
|
||||||
bitstream.setColumn("checksum_algorithm", "MD5");
|
bitstream.setColumn("checksum_algorithm", "MD5");
|
||||||
|
}
|
||||||
|
|
||||||
bitstream.setColumn("deleted", false);
|
bitstream.setColumn("deleted", false);
|
||||||
DatabaseManager.update(context, bitstream);
|
DatabaseManager.update(context, bitstream);
|
||||||
|
|
||||||
|
@@ -276,10 +276,19 @@ public class DatabaseManager
|
|||||||
public static TableRow querySingle(Context context, String query,
|
public static TableRow querySingle(Context context, String query,
|
||||||
Object... parameters) throws SQLException
|
Object... parameters) throws SQLException
|
||||||
{
|
{
|
||||||
TableRowIterator iterator = query(context, query, parameters);
|
TableRow retRow = null;
|
||||||
|
TableRowIterator iterator = null;
|
||||||
TableRow retRow = (!iterator.hasNext()) ? null : iterator.next();
|
try
|
||||||
|
{
|
||||||
|
iterator = query(context, query, parameters);
|
||||||
|
retRow = (!iterator.hasNext()) ? null : iterator.next();
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (iterator != null)
|
||||||
iterator.close();
|
iterator.close();
|
||||||
|
}
|
||||||
|
|
||||||
return (retRow);
|
return (retRow);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -304,10 +313,18 @@ public class DatabaseManager
|
|||||||
public static TableRow querySingleTable(Context context, String table,
|
public static TableRow querySingleTable(Context context, String table,
|
||||||
String query, Object... parameters) throws SQLException
|
String query, Object... parameters) throws SQLException
|
||||||
{
|
{
|
||||||
|
TableRow retRow = null;
|
||||||
TableRowIterator iterator = queryTable(context, canonicalize(table), query, parameters);
|
TableRowIterator iterator = queryTable(context, canonicalize(table), query, parameters);
|
||||||
|
|
||||||
TableRow retRow = (!iterator.hasNext()) ? null : iterator.next();
|
try
|
||||||
|
{
|
||||||
|
retRow = (!iterator.hasNext()) ? null : iterator.next();
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (iterator != null)
|
||||||
iterator.close();
|
iterator.close();
|
||||||
|
}
|
||||||
return (retRow);
|
return (retRow);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -564,8 +581,13 @@ public class DatabaseManager
|
|||||||
public static void insert(Context context, TableRow row)
|
public static void insert(Context context, TableRow row)
|
||||||
throws SQLException
|
throws SQLException
|
||||||
{
|
{
|
||||||
|
int newID = -1;
|
||||||
String table = canonicalize(row.getTable());
|
String table = canonicalize(row.getTable());
|
||||||
|
Statement statement = null;
|
||||||
|
ResultSet rs = null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
// Get an ID (primary key) for this row by using the "getnextid"
|
// Get an ID (primary key) for this row by using the "getnextid"
|
||||||
// SQL function in Postgres, or directly with sequences in Oracle
|
// SQL function in Postgres, or directly with sequences in Oracle
|
||||||
String myQuery = "SELECT getnextid('" + table + "') AS result";
|
String myQuery = "SELECT getnextid('" + table + "') AS result";
|
||||||
@@ -575,15 +597,28 @@ public class DatabaseManager
|
|||||||
myQuery = "SELECT " + table + "_seq" + ".nextval FROM dual";
|
myQuery = "SELECT " + table + "_seq" + ".nextval FROM dual";
|
||||||
}
|
}
|
||||||
|
|
||||||
Statement statement = context.getDBConnection().createStatement();
|
statement = context.getDBConnection().createStatement();
|
||||||
ResultSet rs = statement.executeQuery(myQuery);
|
rs = statement.executeQuery(myQuery);
|
||||||
|
|
||||||
rs.next();
|
rs.next();
|
||||||
|
|
||||||
int newID = rs.getInt(1);
|
newID = rs.getInt(1);
|
||||||
rs.close();
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (rs != null)
|
||||||
|
{
|
||||||
|
try { rs.close(); } catch (SQLException sqle) { }
|
||||||
|
}
|
||||||
|
|
||||||
statement.close();
|
if (statement != null)
|
||||||
|
{
|
||||||
|
try { statement.close(); } catch (SQLException sqle) { }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (newID < 0)
|
||||||
|
throw new SQLException("Unable to retrieve sequence ID");
|
||||||
|
|
||||||
// Set the ID in the table row object
|
// Set the ID in the table row object
|
||||||
row.setColumn(getPrimaryKeyColumn(table), newID);
|
row.setColumn(getPrimaryKeyColumn(table), newID);
|
||||||
@@ -1354,6 +1389,8 @@ public class DatabaseManager
|
|||||||
private static Map retrieveColumnInfo(String table) throws SQLException
|
private static Map retrieveColumnInfo(String table) throws SQLException
|
||||||
{
|
{
|
||||||
Connection connection = null;
|
Connection connection = null;
|
||||||
|
ResultSet pkcolumns = null;
|
||||||
|
ResultSet columns = null;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -1367,13 +1404,13 @@ public class DatabaseManager
|
|||||||
String tname = (table.length() >= max) ? table
|
String tname = (table.length() >= max) ? table
|
||||||
.substring(0, max - 1) : table;
|
.substring(0, max - 1) : table;
|
||||||
|
|
||||||
ResultSet pkcolumns = metadata.getPrimaryKeys(null, schema, tname);
|
pkcolumns = metadata.getPrimaryKeys(null, schema, tname);
|
||||||
Set pks = new HashSet();
|
Set pks = new HashSet();
|
||||||
|
|
||||||
while (pkcolumns.next())
|
while (pkcolumns.next())
|
||||||
pks.add(pkcolumns.getString(4));
|
pks.add(pkcolumns.getString(4));
|
||||||
|
|
||||||
ResultSet columns = metadata.getColumns(null, schema, tname, null);
|
columns = metadata.getColumns(null, schema, tname, null);
|
||||||
|
|
||||||
while (columns.next())
|
while (columns.next())
|
||||||
{
|
{
|
||||||
@@ -1394,9 +1431,19 @@ public class DatabaseManager
|
|||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
if (pkcolumns != null)
|
||||||
|
{
|
||||||
|
try { pkcolumns.close(); } catch (SQLException sqle) { }
|
||||||
|
}
|
||||||
|
|
||||||
|
if (columns != null)
|
||||||
|
{
|
||||||
|
try { columns.close(); } catch (SQLException sqle) { }
|
||||||
|
}
|
||||||
|
|
||||||
if (connection != null)
|
if (connection != null)
|
||||||
{
|
{
|
||||||
connection.close();
|
try { connection.close(); } catch (SQLException sqle) { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -108,7 +108,7 @@ public class TableRowIterator
|
|||||||
/**
|
/**
|
||||||
* Finalize -- this method is called when this object is GC-ed.
|
* Finalize -- this method is called when this object is GC-ed.
|
||||||
*/
|
*/
|
||||||
public void finalize()
|
protected void finalize()
|
||||||
{
|
{
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
@@ -171,6 +171,8 @@ public class WorkflowItem implements InProgressSubmission
|
|||||||
TableRowIterator tri = DatabaseManager.queryTable(c, "workflowitem",
|
TableRowIterator tri = DatabaseManager.queryTable(c, "workflowitem",
|
||||||
"SELECT * FROM workflowitem");
|
"SELECT * FROM workflowitem");
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
// make a list of workflow items
|
// make a list of workflow items
|
||||||
while (tri.hasNext())
|
while (tri.hasNext())
|
||||||
{
|
{
|
||||||
@@ -178,8 +180,12 @@ public class WorkflowItem implements InProgressSubmission
|
|||||||
WorkflowItem wi = new WorkflowItem(c, row);
|
WorkflowItem wi = new WorkflowItem(c, row);
|
||||||
wfItems.add(wi);
|
wfItems.add(wi);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (tri != null)
|
||||||
tri.close();
|
tri.close();
|
||||||
|
}
|
||||||
|
|
||||||
WorkflowItem[] wfArray = new WorkflowItem[wfItems.size()];
|
WorkflowItem[] wfArray = new WorkflowItem[wfItems.size()];
|
||||||
wfArray = (WorkflowItem[]) wfItems.toArray(wfArray);
|
wfArray = (WorkflowItem[]) wfItems.toArray(wfArray);
|
||||||
@@ -211,6 +217,8 @@ public class WorkflowItem implements InProgressSubmission
|
|||||||
"ORDER BY workflowitem.workflow_id",
|
"ORDER BY workflowitem.workflow_id",
|
||||||
ep.getID());
|
ep.getID());
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
while (tri.hasNext())
|
while (tri.hasNext())
|
||||||
{
|
{
|
||||||
TableRow row = tri.next();
|
TableRow row = tri.next();
|
||||||
@@ -226,8 +234,12 @@ public class WorkflowItem implements InProgressSubmission
|
|||||||
|
|
||||||
wfItems.add(wi);
|
wfItems.add(wi);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (tri != null)
|
||||||
tri.close();
|
tri.close();
|
||||||
|
}
|
||||||
|
|
||||||
WorkflowItem[] wfArray = new WorkflowItem[wfItems.size()];
|
WorkflowItem[] wfArray = new WorkflowItem[wfItems.size()];
|
||||||
wfArray = (WorkflowItem[]) wfItems.toArray(wfArray);
|
wfArray = (WorkflowItem[]) wfItems.toArray(wfArray);
|
||||||
@@ -255,6 +267,8 @@ public class WorkflowItem implements InProgressSubmission
|
|||||||
"workflowitem.collection_id= ? ",
|
"workflowitem.collection_id= ? ",
|
||||||
c.getID());
|
c.getID());
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
while (tri.hasNext())
|
while (tri.hasNext())
|
||||||
{
|
{
|
||||||
TableRow row = tri.next();
|
TableRow row = tri.next();
|
||||||
@@ -271,8 +285,12 @@ public class WorkflowItem implements InProgressSubmission
|
|||||||
|
|
||||||
wsItems.add(wi);
|
wsItems.add(wi);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (tri != null)
|
||||||
tri.close();
|
tri.close();
|
||||||
|
}
|
||||||
|
|
||||||
WorkflowItem[] wsArray = new WorkflowItem[wsItems.size()];
|
WorkflowItem[] wsArray = new WorkflowItem[wsItems.size()];
|
||||||
wsArray = (WorkflowItem[]) wsItems.toArray(wsArray);
|
wsArray = (WorkflowItem[]) wsItems.toArray(wsArray);
|
||||||
|
@@ -237,12 +237,18 @@ public class WorkflowManager
|
|||||||
TableRowIterator tri = DatabaseManager.queryTable(c,
|
TableRowIterator tri = DatabaseManager.queryTable(c,
|
||||||
"workflowitem", myquery,e.getID());
|
"workflowitem", myquery,e.getID());
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
while (tri.hasNext())
|
while (tri.hasNext())
|
||||||
{
|
{
|
||||||
mylist.add(new WorkflowItem(c, tri.next()));
|
mylist.add(new WorkflowItem(c, tri.next()));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (tri != null)
|
||||||
tri.close();
|
tri.close();
|
||||||
|
}
|
||||||
|
|
||||||
return mylist;
|
return mylist;
|
||||||
}
|
}
|
||||||
@@ -265,12 +271,18 @@ public class WorkflowManager
|
|||||||
TableRowIterator tri = DatabaseManager
|
TableRowIterator tri = DatabaseManager
|
||||||
.queryTable(c, "workflowitem", myquery, e.getID());
|
.queryTable(c, "workflowitem", myquery, e.getID());
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
while (tri.hasNext())
|
while (tri.hasNext())
|
||||||
{
|
{
|
||||||
mylist.add(new WorkflowItem(c, tri.next()));
|
mylist.add(new WorkflowItem(c, tri.next()));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (tri != null)
|
||||||
tri.close();
|
tri.close();
|
||||||
|
}
|
||||||
|
|
||||||
return mylist;
|
return mylist;
|
||||||
}
|
}
|
||||||
|
@@ -190,7 +190,7 @@ public class FeedServlet extends DSpaceServlet
|
|||||||
|
|
||||||
//as long as this is not a site wide feed,
|
//as long as this is not a site wide feed,
|
||||||
//attempt to retrieve the Collection or Community object
|
//attempt to retrieve the Collection or Community object
|
||||||
if(!handle.equals(SITE_FEED_KEY))
|
if(handle != null && !handle.equals(SITE_FEED_KEY))
|
||||||
{
|
{
|
||||||
// Determine if handle is a valid reference
|
// Determine if handle is a valid reference
|
||||||
dso = HandleManager.resolveToObject(context, handle);
|
dso = HandleManager.resolveToObject(context, handle);
|
||||||
@@ -371,7 +371,7 @@ public class FeedServlet extends DSpaceServlet
|
|||||||
: HandleManager.getCanonicalForm(dso.getHandle());
|
: HandleManager.getCanonicalForm(dso.getHandle());
|
||||||
|
|
||||||
// put in container-level data
|
// put in container-level data
|
||||||
channel.setDescription(description.replaceAll("\\p{Cntrl}", ""));
|
channel.setDescription(description == null ? "" : description.replaceAll("\\p{Cntrl}", ""));
|
||||||
channel.setLink(objectUrl);
|
channel.setLink(objectUrl);
|
||||||
//build channel title by passing in type and title
|
//build channel title by passing in type and title
|
||||||
String channelTitle = MessageFormat.format(labels.getString(clazz + ".feed.title"),
|
String channelTitle = MessageFormat.format(labels.getString(clazz + ".feed.title"),
|
||||||
|
@@ -122,6 +122,7 @@ public class StatisticsServlet extends org.dspace.app.webui.servlet.DSpaceServle
|
|||||||
HttpServletRequest request, HttpServletResponse response)
|
HttpServletRequest request, HttpServletResponse response)
|
||||||
throws ServletException, IOException, SQLException, AuthorizeException
|
throws ServletException, IOException, SQLException, AuthorizeException
|
||||||
{
|
{
|
||||||
|
StringBuffer report = new StringBuffer();
|
||||||
String date = (String) request.getParameter("date");
|
String date = (String) request.getParameter("date");
|
||||||
request.setAttribute("date", date);
|
request.setAttribute("date", date);
|
||||||
|
|
||||||
@@ -136,6 +137,8 @@ public class StatisticsServlet extends org.dspace.app.webui.servlet.DSpaceServle
|
|||||||
InputStreamReader ir = null;
|
InputStreamReader ir = null;
|
||||||
BufferedReader br = null;
|
BufferedReader br = null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
List monthsList = new ArrayList();
|
List monthsList = new ArrayList();
|
||||||
|
|
||||||
Pattern monthly = Pattern.compile("report-([0-9][0-9][0-9][0-9]-[0-9]+)\\.html");
|
Pattern monthly = Pattern.compile("report-([0-9][0-9][0-9][0-9]-[0-9]+)\\.html");
|
||||||
@@ -175,7 +178,7 @@ public class StatisticsServlet extends org.dspace.app.webui.servlet.DSpaceServle
|
|||||||
reportFile = reports[i];
|
reportFile = reports[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parsedDate.compareTo(mostRecentDate) > 0)
|
if (parsedDate != null && parsedDate.compareTo(mostRecentDate) > 0)
|
||||||
{
|
{
|
||||||
mostRecentDate = parsedDate;
|
mostRecentDate = parsedDate;
|
||||||
reportFile = reports[i];
|
reportFile = reports[i];
|
||||||
@@ -245,13 +248,23 @@ public class StatisticsServlet extends org.dspace.app.webui.servlet.DSpaceServle
|
|||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: there's got to be a better way of doing this
|
// FIXME: there's got to be a better way of doing this
|
||||||
StringBuffer report = new StringBuffer();
|
|
||||||
String line = null;
|
String line = null;
|
||||||
while ((line = br.readLine()) != null)
|
while ((line = br.readLine()) != null)
|
||||||
{
|
{
|
||||||
report.append(line);
|
report.append(line);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (br != null)
|
||||||
|
try { br.close(); } catch (IOException ioe) { }
|
||||||
|
|
||||||
|
if (ir != null)
|
||||||
|
try { ir.close(); } catch (IOException ioe) { }
|
||||||
|
|
||||||
|
if (fir != null)
|
||||||
|
try { fir.close(); } catch (IOException ioe) { }
|
||||||
|
}
|
||||||
// set the report to be displayed
|
// set the report to be displayed
|
||||||
request.setAttribute("report", report.toString());
|
request.setAttribute("report", report.toString());
|
||||||
|
|
||||||
|
@@ -93,7 +93,7 @@ public class SuggestServlet extends DSpaceServlet
|
|||||||
if (item != null)
|
if (item != null)
|
||||||
{
|
{
|
||||||
DCValue[] titleDC = item.getDC("title", null, Item.ANY);
|
DCValue[] titleDC = item.getDC("title", null, Item.ANY);
|
||||||
if (titleDC != null || titleDC.length > 0)
|
if (titleDC != null && titleDC.length > 0)
|
||||||
{
|
{
|
||||||
title = titleDC[0].value;
|
title = titleDC[0].value;
|
||||||
}
|
}
|
||||||
|
@@ -231,8 +231,21 @@ public class DIDLCrosswalk extends Crosswalk
|
|||||||
byte[] buffer = new byte[intSize];
|
byte[] buffer = new byte[intSize];
|
||||||
|
|
||||||
Context contextl= new Context();
|
Context contextl= new Context();
|
||||||
BufferedInputStream bis=new BufferedInputStream(BitstreamStorageManager.retrieve(contextl,bitstreams[k].getID()));
|
InputStream is = BitstreamStorageManager.retrieve(contextl,bitstreams[k].getID());
|
||||||
|
BufferedInputStream bis = new BufferedInputStream(is);
|
||||||
|
try
|
||||||
|
{
|
||||||
int size=bis.read(buffer);
|
int size=bis.read(buffer);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (bis != null)
|
||||||
|
try { bis.close(); } catch (IOException ioe) { }
|
||||||
|
|
||||||
|
if (is != null)
|
||||||
|
try { is.close(); } catch (IOException ioe) { }
|
||||||
|
}
|
||||||
|
|
||||||
contextl.complete();
|
contextl.complete();
|
||||||
|
|
||||||
String encoding = new String(Base64.encodeBase64(buffer), "ASCII");
|
String encoding = new String(Base64.encodeBase64(buffer), "ASCII");
|
||||||
|
Reference in New Issue
Block a user