Revision: 3127
http://dspace.svn.sourceforge.net/dspace/?rev=3127&view=rev
Author: grahamtriggs
Date: 2008-09-11 15:06:38 +0000 (Thu, 11 Sep 2008)
Log Message:
-----------
integrated from branch 1.5
Fix various problems with resources potentially not being freed, and other minor fixes suggested by FindBugs
Modified Paths:
--------------
trunk/dspace-api/src/main/java/org/dspace/app/mets/METSExport.java
trunk/dspace-api/src/main/java/org/dspace/app/statistics/ReportGenerator.java
trunk/dspace-api/src/main/java/org/dspace/authenticate/X509Authentication.java
trunk/dspace-api/src/main/java/org/dspace/authorize/AuthorizeManager.java
trunk/dspace-api/src/main/java/org/dspace/browse/ItemCountDAOOracle.java
trunk/dspace-api/src/main/java/org/dspace/browse/ItemCountDAOPostgres.java
trunk/dspace-api/src/main/java/org/dspace/content/Bitstream.java
trunk/dspace-api/src/main/java/org/dspace/content/BitstreamFormat.java
trunk/dspace-api/src/main/java/org/dspace/content/Bundle.java
trunk/dspace-api/src/main/java/org/dspace/content/Collection.java
trunk/dspace-api/src/main/java/org/dspace/content/Community.java
trunk/dspace-api/src/main/java/org/dspace/content/FormatIdentifier.java
trunk/dspace-api/src/main/java/org/dspace/content/MetadataField.java
trunk/dspace-api/src/main/java/org/dspace/content/SupervisedItem.java
trunk/dspace-api/src/main/java/org/dspace/content/WorkspaceItem.java
trunk/dspace-api/src/main/java/org/dspace/content/crosswalk/MODSDisseminationCrosswalk.java
trunk/dspace-api/src/main/java/org/dspace/content/crosswalk/QDCCrosswalk.java
trunk/dspace-api/src/main/java/org/dspace/content/crosswalk/XHTMLHeadDisseminationCrosswalk.java
trunk/dspace-api/src/main/java/org/dspace/core/LogManager.java
trunk/dspace-api/src/main/java/org/dspace/core/PluginManager.java
trunk/dspace-api/src/main/java/org/dspace/eperson/EPerson.java
trunk/dspace-api/src/main/java/org/dspace/eperson/Group.java
trunk/dspace-api/src/main/java/org/dspace/search/Harvest.java
trunk/dspace-api/src/main/java/org/dspace/sort/OrderFormat.java
trunk/dspace-api/src/main/java/org/dspace/sort/SortOption.java
trunk/dspace-api/src/main/java/org/dspace/storage/bitstore/BitstreamStorageManager.java
trunk/dspace-api/src/main/java/org/dspace/storage/rdbms/DatabaseManager.java
trunk/dspace-api/src/main/java/org/dspace/storage/rdbms/TableRowIterator.java
trunk/dspace-api/src/main/java/org/dspace/workflow/WorkflowItem.java
trunk/dspace-api/src/main/java/org/dspace/workflow/WorkflowManager.java
trunk/dspace-jspui/dspace-jspui-api/src/main/java/org/dspace/app/webui/servlet/FeedServlet.java
trunk/dspace-jspui/dspace-jspui-api/src/main/java/org/dspace/app/webui/servlet/StatisticsServlet.java
trunk/dspace-oai/dspace-oai-api/src/main/java/org/dspace/app/oai/DIDLCrosswalk.java
Property Changed:
----------------
trunk/
Property changes on: trunk
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/dspace-1_5_x:2946,2948,2951,2955,2957-2958,2963,2976,2986,2995,3027,3033
+ /branches/dspace-1_5_x:2946,2948,2951,2955,2957-2958,2963,2976,2986,2995,3027,3033,3036
Modified: trunk/dspace-api/src/main/java/org/dspace/app/mets/METSExport.java
===================================================================
--- trunk/dspace-api/src/main/java/org/dspace/app/mets/METSExport.java 2008-09-11 01:18:03 UTC (rev 3126)
+++ trunk/dspace-api/src/main/java/org/dspace/app/mets/METSExport.java 2008-09-11 15:06:38 UTC (rev 3127)
@@ -299,9 +299,18 @@
+ File.separator + "config" + File.separator + "dc2mods.cfg";
// Read it in
- InputStream is = new FileInputStream(configFile);
- dcToMODS = new Properties();
- dcToMODS.load(is);
+ InputStream is = null;
+ try
+ {
+ is = new FileInputStream(configFile);
+ dcToMODS = new Properties();
+ dcToMODS.load(is);
+ }
+ finally
+ {
+ if (is != null)
+ try { is.close(); } catch (IOException ioe) { }
+ }
}
/**
Modified: trunk/dspace-api/src/main/java/org/dspace/app/statistics/ReportGenerator.java
===================================================================
--- trunk/dspace-api/src/main/java/org/dspace/app/statistics/ReportGenerator.java 2008-09-11 01:18:03 UTC (rev 3126)
+++ trunk/dspace-api/src/main/java/org/dspace/app/statistics/ReportGenerator.java 2008-09-11 15:06:38 UTC (rev 3127)
@@ -564,31 +564,42 @@
{
FileReader fr = null;
BufferedReader br = null;
-
- // read in the map file, printing a warning if none is found
- String record = null;
- try
- {
- fr = new FileReader(map);
- br = new BufferedReader(fr);
- }
- catch (IOException e)
- {
- System.err.println("Failed to read map file: log file actions will be displayed without translation");
- return;
- }
-
- // loop through the map file and read in the values
- while ((record = br.readLine()) != null)
+
+ try
{
- Matcher matchReal = real.matcher(record);
-
- // if the line is real then read it in
- if (matchReal.matches())
+ // read in the map file, printing a warning if none is found
+ String record = null;
+ try
{
- actionMap.put(matchReal.group(1).trim(), matchReal.group(2).trim());
+ fr = new FileReader(map);
+ br = new BufferedReader(fr);
}
+ catch (IOException e)
+ {
+ System.err.println("Failed to read map file: log file actions will be displayed without translation");
+ return;
+ }
+
+ // loop through the map file and read in the values
+ while ((record = br.readLine()) != null)
+ {
+ Matcher matchReal = real.matcher(record);
+
+ // if the line is real then read it in
+ if (matchReal.matches())
+ {
+ actionMap.put(matchReal.group(1).trim(), matchReal.group(2).trim());
+ }
+ }
}
+ finally
+ {
+ if (br != null)
+ try { br.close(); } catch (IOException ioe) { }
+
+ if (fr != null)
+ try { fr.close(); } catch (IOException ioe) { }
+ }
}
Modified: trunk/dspace-api/src/main/java/org/dspace/authenticate/X509Authentication.java
===================================================================
--- trunk/dspace-api/src/main/java/org/dspace/authenticate/X509Authentication.java 2008-09-11 01:18:03 UTC (rev 3126)
+++ trunk/dspace-api/src/main/java/org/dspace/authenticate/X509Authentication.java 2008-09-11 15:06:38 UTC (rev 3127)
@@ -139,12 +139,13 @@
// First look for keystore full of trusted certs.
if (keystorePath != null)
{
+ FileInputStream fis = null;
if (keystorePassword == null)
keystorePassword = "";
try {
KeyStore ks = KeyStore.getInstance("JKS");
- ks.load(new FileInputStream(keystorePath),
- keystorePassword.toCharArray());
+ fis = new FileInputStream(keystorePath);
+ ks.load(fis, keystorePassword.toCharArray());
caCertKeyStore = ks;
}
catch (IOException e)
@@ -157,14 +158,22 @@
log.error("X509Authentication: Failed to extract CA keystore, file="+
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.
if (caCertPath != null)
{
+ InputStream is = null;
+ FileInputStream fis = null;
try
{
- InputStream is = new BufferedInputStream(new FileInputStream(caCertPath));
+ fis = new FileInputStream(caCertPath);
+ is = new BufferedInputStream(fis);
X509Certificate cert = (X509Certificate) CertificateFactory
.getInstance("X.509").generateCertificate(is);
if (cert != null)
@@ -180,6 +189,14 @@
log.error("X509Authentication: Failed to extract CA cert, file="+
caCertPath+", error="+e.toString());
}
+ finally
+ {
+ if (is != null)
+ try { is.close(); } catch (IOException ioe) { }
+
+ if (fis != null)
+ try { fis.close(); } catch (IOException ioe) { }
+ }
}
}
Modified: trunk/dspace-api/src/main/java/org/dspace/authorize/AuthorizeManager.java
===================================================================
--- trunk/dspace-api/src/main/java/org/dspace/authorize/AuthorizeManager.java 2008-09-11 01:18:03 UTC (rev 3126)
+++ trunk/dspace-api/src/main/java/org/dspace/authorize/AuthorizeManager.java 2008-09-11 15:06:38 UTC (rev 3127)
@@ -77,7 +77,7 @@
* Utility method, checks that the current user of the given context can
* perform all of the specified actions on the given object. An
* <code>AuthorizeException</code> if all the authorizations fail.
- *
+ *
* @param c
* context with the current user
* @param o
@@ -118,14 +118,14 @@
* Checks that the context's current user can perform the given action on
* the given object. Throws an exception if the user is not authorized,
* otherwise the method call does nothing.
- *
+ *
* @param c
* context
* @param o
* a DSpaceObject
* @param action
* action to perform from <code>org.dspace.core.Constants</code>
- *
+ *
* @throws AuthorizeException
* if the user is denied
*/
@@ -203,7 +203,7 @@
/**
* same authorize, returns boolean for those who don't want to deal with
* catching exceptions.
- *
+ *
* @param c
* DSpace context, containing current user
* @param o
@@ -211,7 +211,7 @@
* @param a
* action being attempted, from
* <code>org.dspace.core.Constants</code>
- *
+ *
* @return <code>true</code> if the current user in the context is
* authorized to perform the given action on the given object
*/
@@ -241,7 +241,7 @@
* Check to see if the given user can perform the given action on the given
* object. Always returns true if the ignore authorization flat is set in
* the current context.
- *
+ *
* @param c
* current context. User is irrelevant; "ignore authorization"
* flag is relevant
@@ -323,10 +323,10 @@
* Check to see if the current user is an admin. Always return
* <code>true</code> if c.ignoreAuthorization is set. Anonymous users
* can't be Admins (EPerson set to NULL)
- *
+ *
* @param c
* current context
- *
+ *
* @return <code>true</code> if user is an admin or ignore authorization
* flag set
*/
@@ -359,7 +359,7 @@
/**
* Add a policy for an individual eperson
- *
+ *
* @param c
* context. Current user irrelevant
* @param o
@@ -368,7 +368,7 @@
* ID of action from <code>org.dspace.core.Constants</code>
* @param e
* eperson who can perform the action
- *
+ *
* @throws AuthorizeException
* if current user in context is not authorized to add policies
*/
@@ -387,7 +387,7 @@
/**
* Add a policy for a group
- *
+ *
* @param c
* current context
* @param o
@@ -414,10 +414,10 @@
/**
* Return a List of the policies for an object
- *
+ *
* @param c current context
* @param o object to retrieve policies for
- *
+ *
* @return List of <code>ResourcePolicy</code> objects
*/
@Deprecated
@@ -438,10 +438,10 @@
{
return ResourcePolicyDAOFactory.getInstance(c).getPolicies(g);
}
-
+
/**
* Return a list of policies for an object that match the action
- *
+ *
* @param c
* context
* @param o
@@ -457,7 +457,7 @@
/**
* Add policies to an object to match those from a previous object
- *
+ *
* @param c context
* @param src
* source of policies
@@ -479,7 +479,7 @@
/**
* Copies policies from a list of resource policies to a given DSpaceObject
- *
+ *
* @param c
* DSpace context
* @param policies
@@ -514,7 +514,7 @@
/**
* removes ALL policies for an object. FIXME doesn't check authorization
- *
+ *
* @param c
* DSpace context
* @param o
@@ -533,7 +533,7 @@
/**
* Remove all policies from an object that match a given action. FIXME
* doesn't check authorization
- *
+ *
* @param context
* current context
* @param dso
@@ -564,7 +564,7 @@
/**
* Removes all policies relating to a particular group. FIXME doesn't check
* authorization
- *
+ *
* @param c
* current context
* @param groupID
@@ -590,7 +590,7 @@
/**
* Removes all policies from a group for a particular object that belong to
* a Group. FIXME doesn't check authorization
- *
+ *
* @param c
* current context
* @param o
@@ -611,7 +611,7 @@
/**
* Returns all groups authorized to perform an action on an object. Returns
* empty array if no matches.
- *
+ *
* @param c
* current context
* @param o
Modified: trunk/dspace-api/src/main/java/org/dspace/browse/ItemCountDAOOracle.java
===================================================================
--- trunk/dspace-api/src/main/java/org/dspace/browse/ItemCountDAOOracle.java 2008-09-11 01:18:03 UTC (rev 3126)
+++ trunk/dspace-api/src/main/java/org/dspace/browse/ItemCountDAOOracle.java 2008-09-11 15:06:38 UTC (rev 3127)
@@ -96,11 +96,12 @@
public void collectionCount(Collection collection, int count)
throws ItemCountException
{
- try
+ TableRowIterator tri = null;
+ try
{
// first find out if we have a record
Object[] sparams = { new Integer(collection.getID()) };
- TableRowIterator tri = DatabaseManager.query(context, collectionSelect, sparams);
+ tri = DatabaseManager.query(context, collectionSelect, sparams);
if (tri.hasNext())
{
@@ -112,15 +113,18 @@
Object[] params = { new Integer(collection.getID()), new Integer(count) };
DatabaseManager.updateQuery(context, collectionInsert, params);
}
-
- tri.close();
}
catch (SQLException e)
{
log.error("caught exception: ", e);
throw new ItemCountException(e);
}
- }
+ finally
+ {
+ if (tri != null)
+ tri.close();
+ }
+ }
/**
* Store the count of the given community
@@ -132,11 +136,12 @@
public void communityCount(Community community, int count)
throws ItemCountException
{
- try
+ TableRowIterator tri = null;
+ try
{
// first find out if we have a record
Object[] sparams = { new Integer(community.getID()) };
- TableRowIterator tri = DatabaseManager.query(context, communitySelect, sparams);
+ tri = DatabaseManager.query(context, communitySelect, sparams);
if (tri.hasNext())
{
@@ -148,15 +153,18 @@
Object[] params = { new Integer(community.getID()), new Integer(count) };
DatabaseManager.updateQuery(context, communityInsert, params);
}
-
- tri.close();
}
catch (SQLException e)
{
log.error("caught exception: ", e);
throw new ItemCountException(e);
}
- }
+ finally
+ {
+ if (tri != null)
+ tri.close();
+ }
+ }
/**
* Set the dspace context to use
@@ -268,10 +276,11 @@
private int getCollectionCount(Collection collection)
throws ItemCountException
{
- try
+ TableRowIterator tri = null;
+ try
{
Object[] params = { new Integer(collection.getID()) };
- TableRowIterator tri = DatabaseManager.query(context, collectionSelect, params);
+ tri = DatabaseManager.query(context, collectionSelect, params);
if (!tri.hasNext())
{
@@ -284,9 +293,7 @@
{
throw new ItemCountException("More than one count row in the database");
}
-
- tri.close();
-
+
return tr.getIntColumn("count");
}
catch (SQLException e)
@@ -294,7 +301,12 @@
log.error("caught exception: ", e);
throw new ItemCountException(e);
}
- }
+ finally
+ {
+ if (tri != null)
+ tri.close();
+ }
+ }
/**
* get the count for the given community
@@ -306,10 +318,11 @@
private int getCommunityCount(Community community)
throws ItemCountException
{
- try
+ TableRowIterator tri = null;
+ try
{
Object[] params = { new Integer(community.getID()) };
- TableRowIterator tri = DatabaseManager.query(context, communitySelect, params);
+ tri = DatabaseManager.query(context, communitySelect, params);
if (!tri.hasNext())
{
@@ -322,9 +335,7 @@
{
throw new ItemCountException("More than one count row in the database");
}
-
- tri.close();
-
+
return tr.getIntColumn("count");
}
catch (SQLException e)
@@ -332,5 +343,10 @@
log.error("caught exception: ", e);
throw new ItemCountException(e);
}
- }
+ finally
+ {
+ if (tri != null)
+ tri.close();
+ }
+ }
}
Modified: trunk/dspace-api/src/main/java/org/dspace/browse/ItemCountDAOPostgres.java
===================================================================
--- trunk/dspace-api/src/main/java/org/dspace/browse/ItemCountDAOPostgres.java 2008-09-11 01:18:03 UTC (rev 3126)
+++ trunk/dspace-api/src/main/java/org/dspace/browse/ItemCountDAOPostgres.java 2008-09-11 15:06:38 UTC (rev 3127)
@@ -96,11 +96,12 @@
public void collectionCount(Collection collection, int count)
throws ItemCountException
{
- try
+ TableRowIterator tri = null;
+ try
{
// first find out if we have a record
Object[] sparams = { new Integer(collection.getID()) };
- TableRowIterator tri = DatabaseManager.query(context, collectionSelect, sparams);
+ tri = DatabaseManager.query(context, collectionSelect, sparams);
if (tri.hasNext())
{
@@ -112,15 +113,18 @@
Object[] params = { new Integer(collection.getID()), new Integer(count) };
DatabaseManager.updateQuery(context, collectionInsert, params);
}
-
- tri.close();
}
catch (SQLException e)
{
log.error("caught exception: ", e);
throw new ItemCountException(e);
}
- }
+ finally
+ {
+ if (tri != null)
+ tri.close();
+ }
+ }
/**
* Store the count of the given community
@@ -132,11 +136,12 @@
public void communityCount(Community community, int count)
throws ItemCountException
{
- try
+ TableRowIterator tri = null;
+ try
{
// first find out if we have a record
Object[] sparams = { new Integer(community.getID()) };
- TableRowIterator tri = DatabaseManager.query(context, communitySelect, sparams);
+ tri = DatabaseManager.query(context, communitySelect, sparams);
if (tri.hasNext())
{
@@ -148,15 +153,18 @@
Object[] params = { new Integer(community.getID()), new Integer(count) };
DatabaseManager.updateQuery(context, communityInsert, params);
}
-
- tri.close();
}
catch (SQLException e)
{
log.error("caught exception: ", e);
throw new ItemCountException(e);
}
- }
+ finally
+ {
+ if (tri != null)
+ tri.close();
+ }
+ }
/**
* Set the dspace context to use
@@ -268,10 +276,11 @@
private int getCollectionCount(Collection collection)
throws ItemCountException
{
- try
+ TableRowIterator tri = null;
+ try
{
Object[] params = { new Integer(collection.getID()) };
- TableRowIterator tri = DatabaseManager.query(context, collectionSelect, params);
+ tri = DatabaseManager.query(context, collectionSelect, params);
if (!tri.hasNext())
{
@@ -284,9 +293,7 @@
{
throw new ItemCountException("More than one count row in the database");
}
-
- tri.close();
-
+
return tr.getIntColumn("count");
}
catch (SQLException e)
@@ -294,7 +301,12 @@
log.error("caught exception: ", e);
throw new ItemCountException(e);
}
- }
+ finally
+ {
+ if (tri != null)
+ tri.close();
+ }
+ }
/**
* get the count for the given community
@@ -306,10 +318,11 @@
private int getCommunityCount(Community community)
throws ItemCountException
{
- try
+ TableRowIterator tri = null;
+ try
{
Object[] params = { new Integer(community.getID()) };
- TableRowIterator tri = DatabaseManager.query(context, communitySelect, params);
+ tri = DatabaseManager.query(context, communitySelect, params);
if (!tri.hasNext())
{
@@ -322,9 +335,7 @@
{
throw new ItemCountException("More than one count row in the database");
}
-
- tri.close();
-
+
return tr.getIntColumn("count");
}
catch (SQLException e)
@@ -332,5 +343,10 @@
log.error("caught exception: ", e);
throw new ItemCountException(e);
}
- }
+ finally
+ {
+ if (tri != null)
+ tri.close();
+ }
+ }
}
Modified: trunk/dspace-api/src/main/java/org/dspace/content/Bitstream.java
===================================================================
--- trunk/dspace-api/src/main/java/org/dspace/content/Bitstream.java 2008-09-11 01:18:03 UTC (rev 3126)
+++ trunk/dspace-api/src/main/java/org/dspace/content/Bitstream.java 2008-09-11 15:06:38 UTC (rev 3127)
@@ -62,7 +62,7 @@
* When modifying the bitstream metadata, changes are not reflected in the
* database until <code>update</code> is called. Note that you cannot alter
* the contents of a bitstream; you need to create a new bitstream.
- *
+ *
* @author Robert Tansley
* @version $Revision$
*/
@@ -139,7 +139,7 @@
/**
* Get the name of this bitstream - typically the filename, without any path
* information
- *
+ *
* @return the name of the bitstream
*/
public String getName()
@@ -158,7 +158,7 @@
* Get the source of this bitstream - typically the filename with path
* information (if originally provided) or the name of the tool that
* generated this bitstream
- *
+ *
* @return the source of the bitstream
*/
public String getSource()
@@ -187,7 +187,7 @@
/**
* Get the checksum of the content of the bitstream.
- *
+ *
* @return the checksum
*/
public String getChecksum()
@@ -203,7 +203,7 @@
/**
* Get the algorithm used to calculate the checksum
- *
+ *
* @return the algorithm, e.g. "MD5"
*/
public String getChecksumAlgorithm()
@@ -219,7 +219,7 @@
/**
* Get the size of the bitstream
- *
+ *
* @return the size in bytes
*/
public long getSize()
@@ -236,7 +236,7 @@
/**
* Set the user's format description. This implies that the format of the
* bitstream is uncertain, and the format is set to "unknown."
- *
+ *
* @param desc the user's description of the format
*/
public void setUserFormatDescription(String desc)
@@ -250,7 +250,7 @@
/**
* Get the user's format description. Returns null if the format is known by
* the system.
- *
+ *
* @return the user's format description.
*/
public String getUserFormatDescription()
@@ -261,7 +261,7 @@
/**
* Get the description of the format - either the user's or the description
* of the format defined by the system.
- *
+ *
* @return a description of the format.
*/
public String getFormatDescription()
@@ -284,7 +284,7 @@
/**
* Get the format of the bitstream
- *
+ *
* @return the format of this bitstream
*/
public BitstreamFormat getFormat()
@@ -296,7 +296,7 @@
* Set the format of the bitstream. If the user has supplied a type
* description, it is cleared. Passing in <code>null</code> sets the type
* of this bitstream to "unknown".
- *
+ *
* @param f
* the format of this bitstream, or <code>null</code> for
* unknown
@@ -330,7 +330,7 @@
/**
* Retrieve the contents of the bitstream
- *
+ *
* @return a stream from which the bitstream can be read.
* @throws AuthorizeException
*/
@@ -341,20 +341,20 @@
return BitstreamStorageManager.retrieve(context, getID());
}
-
+
/**
* Determine if this bitstream is registered
- *
+ *
* @return true if the bitstream is registered, false otherwise
*/
public boolean isRegisteredBitstream()
{
return BitstreamStorageManager.isRegisteredBitstream(internalID);
}
-
+
/**
* Get the asset store number where this bitstream is stored
- *
+ *
* @return the asset store number of the bitstream
*/
public int getStoreNumber()
@@ -407,7 +407,7 @@
static Bitstream register(Context context, int assetstore,
String bitstreamPath) throws AuthorizeException, IOException
{
-
+
Bitstream bitstream = BitstreamDAOFactory.getInstance(context).register(assetstore,
bitstreamPath);
context.addEvent(new Event(Event.CREATE, Constants.BITSTREAM, bitstream.getID(), "REGISTER"));
@@ -418,7 +418,7 @@
public void update() throws AuthorizeException
{
dao.update(this);
-
+
if (modified)
{
context.addEvent(new Event(Event.MODIFY, Constants.BITSTREAM, getID(), null));
Modified: trunk/dspace-api/src/main/java/org/dspace/content/BitstreamFormat.java
===================================================================
--- trunk/dspace-api/src/main/java/org/dspace/content/BitstreamFormat.java 2008-09-11 01:18:03 UTC (rev 3126)
+++ trunk/dspace-api/src/main/java/org/dspace/content/BitstreamFormat.java 2008-09-11 15:06:38 UTC (rev 3127)
@@ -140,10 +140,10 @@
{
// No short_description='Unknown' found in bitstreamformatregistry
// table. On first load of registries this is expected because it
- // hasn't been inserted yet! So, catch but ignore this runtime
+ // hasn't been inserted yet! So, catch but ignore this runtime
// exception thrown by method findUnknown.
}
-
+
// If the exception was thrown, unknown will == null so go ahead and
// load the new description. If not, check that the unknown's
// registry's name is not being reset.
Modified: trunk/dspace-api/src/main/java/org/dspace/content/Bundle.java
===================================================================
--- trunk/dspace-api/src/main/java/org/dspace/content/Bundle.java 2008-09-11 01:18:03 UTC (rev 3126)
+++ trunk/dspace-api/src/main/java/org/dspace/content/Bundle.java 2008-09-11 15:06:38 UTC (rev 3127)
@@ -114,7 +114,6 @@
{
this.name = name;
modifiedMetadata = true;
- modifiedMetadata = true;
}
public void unsetPrimaryBitstreamID()
@@ -210,7 +209,7 @@
AuthorizeManager.inheritPolicies(context, this, b);
bitstreams.add(b);
-
+
context.addEvent(new Event(Event.ADD, Constants.BUNDLE, getID(), Constants.BITSTREAM, b.getID(), String.valueOf(b.getSequenceID())));
}
@@ -223,7 +222,7 @@
if (bitstream.getID() == b.getID())
{
i.remove();
-
+
context.addEvent(new Event(Event.REMOVE, Constants.BUNDLE, getID(), Constants.BITSTREAM, b.getID(), String.valueOf(b.getSequenceID())));
}
}
@@ -260,7 +259,7 @@
public void update() throws AuthorizeException
{
dao.update(this);
-
+
if (modified)
{
context.addEvent(new Event(Event.MODIFY, Constants.BUNDLE, getID(), null));
Modified: trunk/dspace-api/src/main/java/org/dspace/content/Collection.java
===================================================================
--- trunk/dspace-api/src/main/java/org/dspace/content/Collection.java 2008-09-11 01:18:03 UTC (rev 3126)
+++ trunk/dspace-api/src/main/java/org/dspace/content/Collection.java 2008-09-11 15:06:38 UTC (rev 3127)
@@ -110,7 +110,7 @@
/** Flag set when metadata is modified, for events */
private boolean modifiedMetadata;
-
+
// FIXME: Maybe we should be smart about this and only store the IDs. OTOH,
// Groups aren't that heavyweight, and cacheing them may be a good thing
// for performance. A proxy implementation that retrieved them on demand
@@ -173,7 +173,7 @@
setSubmitters(submitters);
AuthorizeManager.addPolicy(context, this, Constants.ADD, submitters);
-
+
modified = true;
return submitters;
}
@@ -227,7 +227,7 @@
public void setMetadata(String field, String value)
{
- if ((field.trim()).equals("name")
+ if ((field.trim()).equals("name")
&& (value == null || value.trim().equals("")))
{
try
@@ -449,7 +449,7 @@
public String getLicense()
{
String license = getMetadata("license");
-
+
if ((license == null) || license.equals(""))
{
// Fallback to site-wide default
@@ -623,7 +623,7 @@
public void update() throws AuthorizeException
{
dao.update(this);
-
+
if (modified)
{
context.addEvent(new Event(Event.MODIFY, Constants.COLLECTION, getID(), null));
Modified: trunk/dspace-api/src/main/java/org/dspace/content/Community.java
===================================================================
--- trunk/dspace-api/src/main/java/org/dspace/content/Community.java 2008-09-11 01:18:03 UTC (rev 3126)
+++ trunk/dspace-api/src/main/java/org/dspace/content/Community.java 2008-09-11 15:06:38 UTC (rev 3127)
@@ -125,7 +125,7 @@
public void setMetadata(String field, String value)
{
- if ((field.trim()).equals("name")
+ if ((field.trim()).equals("name")
&& (value == null || value.trim().equals("")))
{
try
@@ -142,7 +142,7 @@
modifiedMetadata = true;
addDetails(field);
}
-
+
public String getName()
{
return getMetadata("name");
@@ -151,7 +151,7 @@
/**
* Get the logo for the community. <code>null</code> is return if the
* community does not have a logo.
- *
+ *
* @return the logo of the community, or <code>null</code>
*/
public Bitstream getLogo()
@@ -330,11 +330,11 @@
ArchiveManager.move(context, community, null, parent);
context.addEvent(
new Event(
- Event.ADD,
- Constants.COMMUNITY,
+ Event.ADD,
+ Constants.COMMUNITY,
parent.getID(),
- Constants.COMMUNITY,
- community.getID(),
+ Constants.COMMUNITY,
+ community.getID(),
community.getIdentifier().getCanonicalForm()
));
}
@@ -342,16 +342,16 @@
{
context.addEvent(
new Event(
- Event.ADD,
- Constants.SITE,
- Site.SITE_ID,
- Constants.COMMUNITY,
- community.getID(),
+ Event.ADD,
+ Constants.SITE,
+ Site.SITE_ID,
+ Constants.COMMUNITY,
+ community.getID(),
community.getIdentifier().getCanonicalForm()
));
}
-
-
+
+
return community;
}
@@ -438,7 +438,7 @@
public void update() throws AuthorizeException
{
dao.update(this);
-
+
if (modified)
{
context.addEvent(new Event(Event.MODIFY, Constants.COMMUNITY, getID(), null));
Modified: trunk/dspace-api/src/main/java/org/dspace/content/FormatIdentifier.java
===================================================================
--- trunk/dspace-api/src/main/java/org/dspace/content/FormatIdentifier.java 2008-09-11 01:18:03 UTC (rev 3126)
+++ trunk/dspace-api/src/main/java/org/dspace/content/FormatIdentifier.java 2008-09-11 15:06:38 UTC (rev 3127)
@@ -50,7 +50,7 @@
* registry in the database. For the moment, the format identifier simply uses
* file extensions stored in the "BitstreamFormatIdentifier" table. This
* probably isn't a particularly satisfactory long-term solution.
- *
+ *
* @author Robert Tansley
* @version $Revision$
*/
@@ -59,10 +59,10 @@
/**
* Attempt to identify the format of a particular bitstream. If the format
* is unknown, null is returned.
- *
+ *
* @param bitstream
* the bitstream to identify the format of
- *
+ *
* @return a format from the bitstream format registry, or null
*/
public static BitstreamFormat guessFormat(Context context,
@@ -105,7 +105,7 @@
if (!formats.isEmpty())
{
// We can do no better than guess the first if there are multiple
- // results.
+ // results.
retFormat = formats.get(0);
}
Modified: trunk/dspace-api/src/main/java/org/dspace/content/MetadataField.java
===================================================================
--- trunk/dspace-api/src/main/java/org/dspace/content/MetadataField.java 2008-09-11 01:18:03 UTC (rev 3126)
+++ trunk/dspace-api/src/main/java/org/dspace/content/MetadataField.java 2008-09-11 15:06:38 UTC (rev 3127)
@@ -216,7 +216,7 @@
* Return the HTML FORM key for the given field.
*
* FIXME: This is so utterly horrid and wrong I can't quite find the words.
- *
+ *
* @param schema
* @param element
* @param qualifier
Modified: trunk/dspace-api/src/main/java/org/dspace/content/SupervisedItem.java
===================================================================
--- trunk/dspace-api/src/main/java/org/dspace/content/SupervisedItem.java 2008-09-11 01:18:03 UTC (rev 3126)
+++ trunk/dspace-api/src/main/java/org/dspace/content/SupervisedItem.java 2008-09-11 15:06:38 UTC (rev 3127)
@@ -63,7 +63,7 @@
{
private GroupDAO groupDAO;
private WorkspaceItemDAO wsiDAO;
-
+
public SupervisedItem(Context context, int id)
{
// construct a new workspace item
@@ -81,7 +81,7 @@
return items.toArray(new SupervisedItem[0]);
}
-
+
@Deprecated
public static SupervisedItem[] findbyEPerson(Context context, EPerson ep)
{
@@ -90,7 +90,7 @@
return items.toArray(new SupervisedItem[0]);
}
-
+
@Deprecated
public Group[] getSupervisorGroups(Context context, int id)
{
@@ -99,7 +99,7 @@
return groups.toArray(new Group[0]);
}
-
+
@Deprecated
public Group[] getSupervisorGroups()
{
Modified: trunk/dspace-api/src/main/java/org/dspace/content/WorkspaceItem.java
===================================================================
--- trunk/dspace-api/src/main/java/org/dspace/content/WorkspaceItem.java 2008-09-11 01:18:03 UTC (rev 3126)
+++ trunk/dspace-api/src/main/java/org/dspace/content/WorkspaceItem.java 2008-09-11 15:06:38 UTC (rev 3127)
@@ -62,7 +62,7 @@
* aren't fully instantiated unless explicitly required. Could be wasted
* effort, however, as the number of workspace items in memory at any given
* time will typically be very low.
- *
+ *
* @author Robert Tansley
* @version $Revision$
*/
@@ -93,7 +93,7 @@
dao = WorkspaceItemDAOFactory.getInstance(context);
}
-
+
public int getID()
{
return id;
Modified: trunk/dspace-api/src/main/java/org/dspace/content/crosswalk/MODSDisseminationCrosswalk.java
===================================================================
--- trunk/dspace-api/src/main/java/org/dspace/content/crosswalk/MODSDisseminationCrosswalk.java 2008-09-11 01:18:03 UTC (rev 3126)
+++ trunk/dspace-api/src/main/java/org/dspace/content/crosswalk/MODSDisseminationCrosswalk.java 2008-09-11 15:06:38 UTC (rev 3127)
@@ -260,9 +260,11 @@
File.separator + "config" + File.separator;
File propsFile = new File(parent, propsFilename);
Properties modsConfig = new Properties();
+ FileInputStream pfs = null;
try
{
- modsConfig.load(new FileInputStream(propsFile));
+ pfs = new FileInputStream(propsFile);
+ modsConfig.load(pfs);
}
catch (IOException e)
{
@@ -270,6 +272,12 @@
throw new CrosswalkInternalException("MODS crosswalk cannot "+
"open config file: "+e.toString());
}
+ finally
+ {
+ if (pfs != null)
+ try { pfs.close(); } catch (IOException ioe) { }
+ }
+
modsMap = new HashMap();
Enumeration pe = modsConfig.propertyNames();
while (pe.hasMoreElements())
Modified: trunk/dspace-api/src/main/java/org/dspace/content/crosswalk/QDCCrosswalk.java
===================================================================
--- trunk/dspace-api/src/main/java/org/dspace/content/crosswalk/QDCCrosswalk.java 2008-09-11 01:18:03 UTC (rev 3126)
+++ trunk/dspace-api/src/main/java/org/dspace/content/crosswalk/QDCCrosswalk.java 2008-09-11 15:06:38 UTC (rev 3127)
@@ -280,7 +280,17 @@
File.separator + "config" + File.separator;
File propsFile = new File(parent, propsFilename);
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.
// evaluate the XML fragment with a wrapper including namespaces.
Modified: trunk/dspace-api/src/main/java/org/dspace/content/crosswalk/XHTMLHeadDisseminationCrosswalk.java
===================================================================
--- trunk/dspace-api/src/main/java/org/dspace/content/crosswalk/XHTMLHeadDisseminationCrosswalk.java 2008-09-11 01:18:03 UTC (rev 3126)
+++ trunk/dspace-api/src/main/java/org/dspace/content/crosswalk/XHTMLHeadDisseminationCrosswalk.java 2008-09-11 15:06:38 UTC (rev 3127)
@@ -120,7 +120,16 @@
// Read in configuration
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();
while (e.hasMoreElements())
Modified: trunk/dspace-api/src/main/java/org/dspace/core/LogManager.java
===================================================================
--- trunk/dspace-api/src/main/java/org/dspace/core/LogManager.java 2008-09-11 01:18:03 UTC (rev 3126)
+++ trunk/dspace-api/src/main/java/org/dspace/core/LogManager.java 2008-09-11 15:06:38 UTC (rev 3127)
@@ -84,6 +84,8 @@
contextExtraInfo = "no_context";
}
- return email + ":" + contextExtraInfo + ":" + action + ":" + extrainfo;
+ StringBuilder result = new StringBuilder();
+ result.append(email).append(":").append(contextExtraInfo).append(":").append(action).append(":").append(extrainfo);
+ return result.toString();
}
}
Modified: trunk/dspace-api/src/main/java/org/dspace/core/PluginManager.java
===================================================================
--- trunk/dspace-api/src/main/java/org/dspace/core/PluginManager.java 2008-09-11 01:18:03 UTC (rev 3126)
+++ trunk/dspace-api/src/main/java/org/dspace/core/PluginManager.java 2008-09-11 15:06:38 UTC (rev 3127)
@@ -564,6 +564,9 @@
public static void checkConfiguration()
throws IOException
{
+ FileReader fr = null;
+ BufferedReader cr = null;
+
/* XXX TODO: (maybe) test that implementation class is really a
* subclass or impl of the plugin "interface"
*/
@@ -574,52 +577,64 @@
Map namedKey = new HashMap();
Map selfnamedKey = new HashMap();
Map reusableKey = new HashMap();
+ HashMap keyMap = new HashMap();
// 1. First pass -- grovel the actual config file to check for
// duplicate keys, since Properties class hides them from us.
// Also build lists of each type of key, check for misspellings.
File config = ConfigurationManager.getConfigurationFile();
- BufferedReader cr = new BufferedReader(new FileReader(config));
- String line = null;
- boolean continued = false;
- HashMap keyMap = new HashMap();
- Pattern keyPattern = Pattern.compile("([^\\s\\=\\:]+)");
- while ((line = cr.readLine()) != null)
+ try
{
- line = line.trim();
- if (line.startsWith("!") || line.startsWith("#"))
- continued = false;
- else
+ fr = new FileReader(config);
+ cr = new BufferedReader(fr);
+ String line = null;
+ boolean continued = false;
+ Pattern keyPattern = Pattern.compile("([^\\s\\=\\:]+)");
+ while ((line = cr.readLine()) != null)
{
- if (!continued && line.startsWith("plugin."))
+ line = line.trim();
+ if (line.startsWith("!") || line.startsWith("#"))
+ continued = false;
+ else
{
- Matcher km = keyPattern.matcher(line);
- if (km.find())
+ if (!continued && line.startsWith("plugin."))
{
- String key = line.substring(0, km.end(1));
- if (keyMap.containsKey(key))
- log.error("Duplicate key \""+key+"\" in DSpace configuration file="+config.toString());
- else
- keyMap.put(key, key);
+ Matcher km = keyPattern.matcher(line);
+ if (km.find())
+ {
+ String key = line.substring(0, km.end(1));
+ if (keyMap.containsKey(key))
+ log.error("Duplicate key \""+key+"\" in DSpace configuration file="+config.toString());
+ else
+ keyMap.put(key, key);
- if (key.startsWith(SINGLE_PREFIX))
- singleKey.put(key.substring(SINGLE_PREFIX.length()), key);
- else if (key.startsWith(SEQUENCE_PREFIX))
- sequenceKey.put(key.substring(SEQUENCE_PREFIX.length()), key);
- else if (key.startsWith(NAMED_PREFIX))
- namedKey.put(key.substring(NAMED_PREFIX.length()), key);
- else if (key.startsWith(SELFNAMED_PREFIX))
- selfnamedKey.put(key.substring(SELFNAMED_PREFIX.length()), key);
- else if (key.startsWith(REUSABLE_PREFIX))
- reusableKey.put(key.substring(REUSABLE_PREFIX.length()), key);
- else
- log.error("Key with unknown prefix \""+key+"\" in DSpace configuration file="+config.toString());
+ if (key.startsWith(SINGLE_PREFIX))
+ singleKey.put(key.substring(SINGLE_PREFIX.length()), key);
+ else if (key.startsWith(SEQUENCE_PREFIX))
+ sequenceKey.put(key.substring(SEQUENCE_PREFIX.length()), key);
+ else if (key.startsWith(NAMED_PREFIX))
+ namedKey.put(key.substring(NAMED_PREFIX.length()), key);
+ else if (key.startsWith(SELFNAMED_PREFIX))
+ selfnamedKey.put(key.substring(SELFNAMED_PREFIX.length()), key);
+ else if (key.startsWith(REUSABLE_PREFIX))
+ reusableKey.put(key.substring(REUSABLE_PREFIX.length()), key);
+ else
+ log.error("Key with unknown prefix \""+key+"\" in DSpace configuration file="+config.toString());
+ }
}
+ 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
Enumeration pne = ConfigurationManager.propertyNames();
HashSet pn = new HashSet();
Modified: trunk/dspace-api/src/main/java/org/dspace/eperson/EPerson.java
===================================================================
--- trunk/dspace-api/src/main/java/org/dspace/eperson/EPerson.java 2008-09-11 01:18:03 UTC (rev 3126)
+++ trunk/dspace-api/src/main/java/org/dspace/eperson/EPerson.java 2008-09-11 15:06:38 UTC (rev 3127)
@@ -87,7 +87,7 @@
/** Flag set when metadata is modified, for events */
private boolean modifiedMetadata;
-
+
public enum EPersonMetadataField
{
FIRSTNAME ("firstname"),
@@ -136,7 +136,7 @@
String>(EPersonMetadataField.class);
context.cache(this, id);
-
+
modified = modifiedMetadata = false;
clearDetails();
}
@@ -212,7 +212,7 @@
}
// end identifier handling methos
-
+
/**
* Get the e-person's full name, combining first and last name in a
* displayable string.
@@ -278,7 +278,6 @@
{
this.requireCertificate = requireCertificate;
modified = true;
- modified = true;
}
public boolean getRequireCertificate()
@@ -290,7 +289,6 @@
{
this.selfRegistered = selfRegistered;
modified = true;
- modified = true;
}
public boolean getSelfRegistered()
@@ -328,7 +326,6 @@
{
metadata.put(EPersonMetadataField.PASSWORD, Utils.getMD5(password));
modified = true;
- modified = true;
}
public boolean checkPassword(String attempt)
@@ -434,7 +431,5 @@
{
dao.delete(getID());
context.addEvent(new Event(Event.DELETE, Constants.EPERSON, getID(), getEmail()));
-
-
}
}
Modified: trunk/dspace-api/src/main/java/org/dspace/eperson/Group.java
===================================================================
--- trunk/dspace-api/src/main/java/org/dspace/eperson/Group.java 2008-09-11 01:18:03 UTC (rev 3126)
+++ trunk/dspace-api/src/main/java/org/dspace/eperson/Group.java 2008-09-11 15:06:38 UTC (rev 3127)
@@ -89,7 +89,7 @@
/** Flag set when metadata is modified, for events */
private boolean modifiedMetadata;
-
+
public Group(Context context, int id)
{
this.id = id;
@@ -249,9 +249,9 @@
{
GroupDAO dao = GroupDAOFactory.getInstance(context);
Group group = dao.create();
-
+
context.addEvent(new Event(Event.CREATE, Constants.GROUP, group.getID(), null));
-
+
return group;
}
@@ -259,7 +259,7 @@
public void update() throws AuthorizeException
{
dao.update(this);
-
+
if (modifiedMetadata)
{
context.addEvent(new Event(Event.MODIFY_METADATA, Constants.GROUP, getID(), getDetails()));
@@ -273,7 +273,7 @@
{
dao.delete(this.getID());
context.addEvent(new Event(Event.DELETE, Constants.GROUP, getID(), getName()));
-
+
}
@Deprecated
Modified: trunk/dspace-api/src/main/java/org/dspace/search/Harvest.java
===================================================================
--- trunk/dspace-api/src/main/java/org/dspace/search/Harvest.java 2008-09-11 01:18:03 UTC (rev 3126)
+++ trunk/dspace-api/src/main/java/org/dspace/search/Harvest.java 2008-09-11 15:06:38 UTC (rev 3127)
@@ -62,7 +62,7 @@
* Utility class for extracting information about items, possibly just within a
* certain community or collection, that have been created, modified or
* withdrawn within a particular range of dates.
- *
+ *
* @author Robert Tansley
* @version $Revision$
*/
@@ -70,7 +70,7 @@
{
/** log4j logger */
private static Logger log = Logger.getLogger(Harvest.class);
-
+
/**
* Obtain information about items that have been created, modified or
* withdrawn within a given date range. You can also specify 'offset' and
@@ -80,7 +80,7 @@
* (and OAI-PMH).
* <P>
* FIXME: Assumes all in_archive items have public metadata
- *
+ *
* @param context
* DSpace context
* @param scope
@@ -135,7 +135,7 @@
&& ((limit == 0) || (index < (offset + limit))))
{
HarvestedItemInfo itemInfo = new HarvestedItemInfo();
-
+
itemInfo.context = context;
itemInfo.identifier = item.getIdentifier();
itemInfo.itemID = item.getID();
@@ -165,7 +165,7 @@
/**
* Get harvested item info for a single item. <code>item</code> field in
* returned <code>HarvestedItemInfo</code> object is always filled out.
- *
+ *
* @param context
* DSpace context
* @param identifier
@@ -174,7 +174,7 @@
* if <code>true</code> the <code>collectionIdentifiers</code>
* field of the <code>HarvestedItemInfo</code> object is filled
* out
- *
+ *
* @return <code>HarvestedItemInfo</code> object for the single item, or
* <code>null</code>
*/
@@ -218,7 +218,7 @@
/**
* Fill out the containers field of the HarvestedItemInfo object
- *
+ *
* @param context
* DSpace context
* @param itemInfo
Modified: trunk/dspace-api/src/main/java/org/dspace/sort/OrderFormat.java
===================================================================
--- trunk/dspace-api/src/main/java/org/dspace/sort/OrderFormat.java 2008-09-11 01:18:03 UTC (rev 3126)
+++ trunk/dspace-api/src/main/java/org/dspace/sort/OrderFormat.java 2008-09-11 15:06:38 UTC (rev 3127)
@@ -107,24 +107,24 @@
{
return delegate.makeSortString(value, language);
}
- }
-
- // No delegates found, so apply defaults
- if (type.equalsIgnoreCase(OrderFormat.AUTHOR) && authorDelegate != null)
- {
- return authorDelegate.makeSortString(value, language);
- }
- if (type.equalsIgnoreCase(OrderFormat.TITLE) && titleDelegate != null)
- {
- return titleDelegate.makeSortString(value, language);
+ // No delegates found, so apply defaults
+ if (type.equalsIgnoreCase(OrderFormat.AUTHOR) && authorDelegate != null)
+ {
+ return authorDelegate.makeSortString(value, language);
+ }
+
+ if (type.equalsIgnoreCase(OrderFormat.TITLE) && titleDelegate != null)
+ {
+ return titleDelegate.makeSortString(value, language);
+ }
+
+ if (type.equalsIgnoreCase(OrderFormat.TEXT) && textDelegate != null)
+ {
+ return textDelegate.makeSortString(value, language);
+ }
}
- if (type.equalsIgnoreCase(OrderFormat.TEXT) && textDelegate != null)
- {
- return textDelegate.makeSortString(value, language);
- }
-
return value;
}
Modified: trunk/dspace-api/src/main/java/org/dspace/sort/SortOption.java
===================================================================
--- trunk/dspace-api/src/main/java/org/dspace/sort/SortOption.java 2008-09-11 01:18:03 UTC (rev 3126)
+++ trunk/dspace-api/src/main/java/org/dspace/sort/SortOption.java 2008-09-11 15:06:38 UTC (rev 3127)
@@ -304,16 +304,21 @@
{
if (SortOption.sortOptionsMap != null)
return SortOption.sortOptionsMap;
-
- SortOption.sortOptionsMap = new HashMap<Integer, SortOption>();
- synchronized (SortOption.sortOptionsMap)
+
+ synchronized (SortOption.class)
{
- for (SortOption so : SortOption.getSortOptions())
+ if (SortOption.sortOptionsMap == null)
{
- SortOption.sortOptionsMap.put(new Integer(so.getNumber()), so);
+ Map<Integer, SortOption> newSortOptionsMap = new HashMap<Integer, SortOption>();
+ for (SortOption so : SortOption.getSortOptions())
+ {
+ newSortOptionsMap.put(new Integer(so.getNumber()), so);
+ }
+
+ SortOption.sortOptionsMap = newSortOptionsMap;
}
}
-
+
return SortOption.sortOptionsMap;
}
@@ -327,17 +332,22 @@
if (SortOption.sortOptionsSet != null)
return SortOption.sortOptionsSet;
- SortOption.sortOptionsSet = new HashSet<SortOption>();
- synchronized (SortOption.sortOptionsSet)
+ synchronized (SortOption.class)
{
- int idx = 1;
- String option;
+ if (SortOption.sortOptionsSet == null)
+ {
+ Set<SortOption> newSortOptionsSet = new HashSet<SortOption>();
+ int idx = 1;
+ String option;
- while ( ((option = ConfigurationManager.getProperty("webui.itemlist.sort-option." + idx))) != null)
- {
- SortOption so = new SortOption(idx, option);
- SortOption.sortOptionsSet.add(so);
- idx++;
+ while ( ((option = ConfigurationManager.getProperty("webui.itemlist.sort-option." + idx))) != null)
+ {
+ SortOption so = new SortOption(idx, option);
+ newSortOptionsSet.add(so);
+ idx++;
+ }
+
+ SortOption.sortOptionsSet = newSortOptionsSet;
}
}
Modified: trunk/dspace-api/src/main/java/org/dspace/storage/bitstore/BitstreamStorageManager.java
===================================================================
--- trunk/dspace-api/src/main/java/org/dspace/storage/bitstore/BitstreamStorageManager.java 2008-09-11 01:18:03 UTC (rev 3126)
+++ trunk/dspace-api/src/main/java/org/dspace/storage/bitstore/BitstreamStorageManager.java 2008-09-11 15:06:38 UTC (rev 3127)
@@ -71,7 +71,7 @@
* <P>
* Stores, retrieves and deletes bitstreams.
* </P>
- *
+ *
* <P>
* Presently, asset stores are specified in <code>dspace.cfg</code>. Since
* Java does not offer a way of detecting free disk space, the asset store to
@@ -80,17 +80,17 @@
* available space in the asset stores, and DSpace (Tomcat) has to be restarted
* when the asset store for new ('incoming') bitstreams is changed.
* </P>
- *
+ *
* <P>
* Mods by David Little, UCSD Libraries 12/21/04 to allow the registration of
* files (bitstreams) into DSpace.
* </P>
- *
- * <p>Cleanup integration with checker package by Nate Sarr 2006-01. N.B. The
- * dependency on the checker package isn't ideal - a Listener pattern would be
+ *
+ * <p>Cleanup integration with checker package by Nate Sarr 2006-01. N.B. The
+ * dependency on the checker package isn't ideal - a Listener pattern would be
* better but was considered overkill for the purposes of integrating the checker.
- * It would be worth re-considering a Listener pattern if another package needs to
- * be notified of BitstreamStorageManager actions.</p>
+ * It would be worth re-considering a Listener pattern if another package needs to
+ * be notified of BitstreamStorageManager actions.</p>
*
* @author Peter Breton, Robert Tansley, David Little, Nathan Sarr
* @version $Revision$
@@ -149,7 +149,7 @@
// 'assetstore.dir' is always store number 0
String sAssetstoreDir = ConfigurationManager
.getProperty("assetstore.dir");
-
+
// see if conventional assetstore or srb
if (sAssetstoreDir != null) {
stores.add(sAssetstoreDir); // conventional (non-srb)
@@ -244,22 +244,22 @@
/**
* Store a stream of bits.
- *
+ *
* <p>
* If this method returns successfully, the bits have been stored, and RDBMS
* metadata entries are in place (the context still needs to be completed to
* finalize the transaction).
* </p>
- *
+ *
* <p>
* If this method returns successfully and the context is aborted, then the
* bits will be stored in the asset store and the RDBMS metadata entries
* will exist, but with the deleted flag set.
* </p>
- *
+ *
* If this method throws an exception, then any of the following may be
* true:
- *
+ *
* <ul>
* <li>Neither bits nor RDBMS metadata entries have been stored.
* <li>RDBMS metadata entries with the deleted flag set have been stored,
@@ -267,14 +267,14 @@
* <li>RDBMS metadata entries with the deleted flag set have been stored,
* and some or all of the bits have also been stored.
* </ul>
- *
+ *
* @param context
* The current context
* @param is
* The stream of bits to store
* @exception IOException
* If a problem occurs while storing the bits
- *
+ *
* @return The ID of the stored bitstream
*/
public static void store(Context context, Bitstream bitstream,
@@ -327,8 +327,11 @@
bitstream.setSize(file.length());
- bitstream.setChecksum(Utils.toHex(dis.getMessageDigest().digest()));
- bitstream.setChecksumAlgorithm("MD5");
+ if (dis != null)
+ {
+ bitstream.setChecksum(Utils.toHex(dis.getMessageDigest().digest()));
+ bitstream.setChecksumAlgorithm("MD5");
+ }
bitstream.setDeleted(false);
dao.update(bitstream);
@@ -371,60 +374,60 @@
//
// DSpace refers to checksum, writes it in METS, and uses it as an
// AIP filename (!), but never seems to validate with it. Furthermore,
- // DSpace appears to hardcode the algorithm to MD5 in some places--see
+ // DSpace appears to hardcode the algorithm to MD5 in some places--see
// METSExport.java.
//
- // To remain compatible with DSpace we calculate an MD5 checksum on
- // LOCAL registered files. But for REMOTE (e.g. SRB) files we
- // calculate an MD5 on just the fileNAME. The reasoning is that in the
+ // To remain compatible with DSpace we calculate an MD5 checksum on
+ // LOCAL registered files. But for REMOTE (e.g. SRB) files we
+ // calculate an MD5 on just the fileNAME. The reasoning is that in the
// case of a remote file, calculating an MD5 on the file itself will
- // generate network traffic to read the file's bytes. In this case it
- // would be better have a proxy process calculate MD5 and store it as
+ // generate network traffic to read the file's bytes. In this case it
+ // would be better have a proxy process calculate MD5 and store it as
// an SRB metadata attribute so it can be retrieved simply from SRB.
//
// TODO set this up as a proxy server process so no net activity
-
+
// FIXME this is a first class HACK! for the reasons described above
- if (file instanceof LocalFile)
+ if (file instanceof LocalFile)
{
// get MD5 on the file for local file
DigestInputStream dis = null;
- try
+ try
{
- dis = new DigestInputStream(FileFactory.newFileInputStream(file),
+ dis = new DigestInputStream(FileFactory.newFileInputStream(file),
MessageDigest.getInstance("MD5"));
- }
- catch (NoSuchAlgorithmException e)
+ }
+ catch (NoSuchAlgorithmException e)
{
log.warn("Caught NoSuchAlgorithmException", e);
throw new IOException("Invalid checksum algorithm");
}
- catch (IOException e)
+ catch (IOException e)
{
- log.error("File: " + file.getAbsolutePath()
+ log.error("File: " + file.getAbsolutePath()
+ " to be registered cannot be opened - is it "
+ "really there?");
throw e;
}
final int BUFFER_SIZE = 1024 * 4;
final byte[] buffer = new byte[BUFFER_SIZE];
- while (true)
+ while (true)
{
final int count = dis.read(buffer, 0, BUFFER_SIZE);
- if (count == -1)
+ if (count == -1)
{
break;
}
}
bitstream.setChecksum(Utils.toHex(dis.getMessageDigest().digest()));
dis.close();
- }
+ }
else if (file instanceof SRBFile)
{
if (!file.exists())
{
- log.error("File: " + file.getAbsolutePath()
+ log.error("File: " + file.getAbsolutePath()
+ " is not in SRB MCAT");
throw new IOException("File is not in SRB MCAT");
}
@@ -433,11 +436,11 @@
int iLastSlash = bitstreamPath.lastIndexOf('/');
String sFilename = bitstreamPath.substring(iLastSlash + 1);
MessageDigest md = null;
- try
+ try
{
md = MessageDigest.getInstance("MD5");
- }
- catch (NoSuchAlgorithmException e)
+ }
+ catch (NoSuchAlgorithmException e)
{
log.error("Caught NoSuchAlgorithmException", e);
throw new IOException("Invalid checksum algorithm");
@@ -457,7 +460,7 @@
dao.update(bitstream);
- if (log.isDebugEnabled())
+ if (log.isDebugEnabled())
{
log.debug("Stored bitstream " + bitstream.getID() + " in file "
+ file.getAbsolutePath());
@@ -473,7 +476,7 @@
*/
public static boolean isRegisteredBitstream(String internalId) {
if (internalId.substring(0, REGISTERED_FLAG.length())
- .equals(REGISTERED_FLAG))
+ .equals(REGISTERED_FLAG))
{
return true;
}
@@ -483,14 +486,14 @@
/**
* Retrieve the bits for the bitstream with ID. If the bitstream does not
* exist, or is marked deleted, returns null.
- *
+ *
* @param context
* The current context
* @param id
* The ID of the bitstream to retrieve
* @exception IOException
* If a problem occurs while retrieving the bits
- *
+ *
* @return The stream of bits, or null
*/
public static InputStream retrieve(Context context, int id)
@@ -511,9 +514,9 @@
* Clean up the bitstream storage area. This method deletes any bitstreams
* which are more than 1 hour old and marked deleted. The deletions cannot
* be undone.
- *
+ *
* @param deleteDbRecords if true deletes the database records otherwise it
- * only deletes the files and directories in the assetstore
+ * only deletes the files and directories in the assetstore
* @exception IOException
* If a problem occurs while cleaning up
*/
@@ -593,7 +596,7 @@
// if the file was deleted then
// try deleting the parents
- // Otherwise the cleanup script is set to
+ // Otherwise the cleanup script is set to
// leave the db records then the file
// and directories have already been deleted
// if this is turned off then it still looks like the
@@ -602,7 +605,7 @@
{
deleteParents(file);
}
-
+
// Make sure to commit our outstanding work every 100
// iterations. Otherwise you risk losing the entire transaction
// if we hit an exception, which isn't useful at all for large
@@ -639,7 +642,7 @@
/**
* Return true if this file is too recent to be deleted, false otherwise.
- *
+ *
* @param file
* The file to check
* @return True if this file is too recent to be deleted
@@ -660,7 +663,7 @@
/**
* Delete empty parent directories.
- *
+ *
* @param file
* The file with parent directories to delete
*/
@@ -670,7 +673,7 @@
{
return;
}
-
+
GeneralFile tmp = file;
for (int i = 0; i < directoryLevels; i++)
@@ -693,12 +696,12 @@
/**
* Return the file corresponding to a bitstream. It's safe to pass in
* <code>null</code>.
- *
+ *
* @param storeNumber the store number that the bitstream is in
* @param sInternalID the internal id of the bitstream
- *
+ *
* @return The corresponding file in the file system, or <code>null</code>
- *
+ *
* @exception IOException
* If a problem occurs while determining the file
*/
@@ -729,7 +732,7 @@
sIntermediatePath = "";
}
else
- {
+ {
// Sanity Check: If the internal ID contains a
// pathname separator, it's probably an attempt to
// make a path traversal attack, so ignore the path
@@ -740,7 +743,7 @@
sInternalId = sInternalId.substring(
sInternalId.lastIndexOf(File.separator)+1);
}
-
+
sIntermediatePath = getIntermediatePath(sInternalId);
}
Modified: trunk/dspace-api/src/main/java/org/dspace/storage/rdbms/DatabaseManager.java
===================================================================
--- trunk/dspace-api/src/main/java/org/dspace/storage/rdbms/DatabaseManager.java 2008-09-11 01:18:03 UTC (rev 3126)
+++ trunk/dspace-api/src/main/java/org/dspace/storage/rdbms/DatabaseManager.java 2008-09-11 15:06:38 UTC (rev 3127)
@@ -276,10 +276,19 @@
public static TableRow querySingle(Context context, String query,
Object... parameters) throws SQLException
{
- TableRowIterator iterator = query(context, query, parameters);
+ TableRow retRow = null;
+ TableRowIterator iterator = null;
+ try
+ {
+ iterator = query(context, query, parameters);
+ retRow = (!iterator.hasNext()) ? null : iterator.next();
+ }
+ finally
+ {
+ if (iterator != null)
+ iterator.close();
+ }
- TableRow retRow = (!iterator.hasNext()) ? null : iterator.next();
- iterator.close();
return (retRow);
}
@@ -304,10 +313,18 @@
public static TableRow querySingleTable(Context context, String table,
String query, Object... parameters) throws SQLException
{
+ TableRow retRow = null;
TableRowIterator iterator = queryTable(context, canonicalize(table), query, parameters);
- TableRow retRow = (!iterator.hasNext()) ? null : iterator.next();
- iterator.close();
+ try
+ {
+ retRow = (!iterator.hasNext()) ? null : iterator.next();
+ }
+ finally
+ {
+ if (iterator != null)
+ iterator.close();
+ }
return (retRow);
}
@@ -564,27 +581,45 @@
public static void insert(Context context, TableRow row)
throws SQLException
{
+ int newID = -1;
String table = canonicalize(row.getTable());
+ Statement statement = null;
+ ResultSet rs = null;
- // Get an ID (primary key) for this row by using the "getnextid"
- // SQL function in Postgres, or directly with sequences in Oracle
- String myQuery = "SELECT getnextid('" + table + "') AS result";
-
- if ("oracle".equals(ConfigurationManager.getProperty("db.name")))
+ try
{
- myQuery = "SELECT " + table + "_seq" + ".nextval FROM dual";
- }
+ // Get an ID (primary key) for this row by using the "getnextid"
+ // SQL function in Postgres, or directly with sequences in Oracle
+ String myQuery = "SELECT getnextid('" + table + "') AS result";
- Statement statement = context.getDBConnection().createStatement();
- ResultSet rs = statement.executeQuery(myQuery);
+ if ("oracle".equals(ConfigurationManager.getProperty("db.name")))
+ {
+ myQuery = "SELECT " + table + "_seq" + ".nextval FROM dual";
+ }
- rs.next();
+ statement = context.getDBConnection().createStatement();
+ rs = statement.executeQuery(myQuery);
- int newID = rs.getInt(1);
- rs.close();
+ rs.next();
- statement.close();
+ newID = rs.getInt(1);
+ }
+ finally
+ {
+ if (rs != null)
+ {
+ try { rs.close(); } catch (SQLException sqle) { }
+ }
+ 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
row.setColumn(getPrimaryKeyColumn(table), newID);
@@ -1354,7 +1389,9 @@
private static Map retrieveColumnInfo(String table) throws SQLException
{
Connection connection = null;
-
+ ResultSet pkcolumns = null;
+ ResultSet columns = null;
+
try
{
String schema = ConfigurationManager.getProperty("db.schema");
@@ -1367,13 +1404,13 @@
String tname = (table.length() >= max) ? table
.substring(0, max - 1) : table;
- ResultSet pkcolumns = metadata.getPrimaryKeys(null, schema, tname);
+ pkcolumns = metadata.getPrimaryKeys(null, schema, tname);
Set pks = new HashSet();
while (pkcolumns.next())
pks.add(pkcolumns.getString(4));
- ResultSet columns = metadata.getColumns(null, schema, tname, null);
+ columns = metadata.getColumns(null, schema, tname, null);
while (columns.next())
{
@@ -1394,9 +1431,19 @@
}
finally
{
+ if (pkcolumns != null)
+ {
+ try { pkcolumns.close(); } catch (SQLException sqle) { }
+ }
+
+ if (columns != null)
+ {
+ try { columns.close(); } catch (SQLException sqle) { }
+ }
+
if (connection != null)
{
- connection.close();
+ try { connection.close(); } catch (SQLException sqle) { }
}
}
}
Modified: trunk/dspace-api/src/main/java/org/dspace/storage/rdbms/TableRowIterator.java
===================================================================
--- trunk/dspace-api/src/main/java/org/dspace/storage/rdbms/TableRowIterator.java 2008-09-11 01:18:03 UTC (rev 3126)
+++ trunk/dspace-api/src/main/java/org/dspace/storage/rdbms/TableRowIterator.java 2008-09-11 15:06:38 UTC (rev 3127)
@@ -108,7 +108,7 @@
/**
* Finalize -- this method is called when this object is GC-ed.
*/
- public void finalize()
+ protected void finalize()
{
close();
}
Modified: trunk/dspace-api/src/main/java/org/dspace/workflow/WorkflowItem.java
===================================================================
--- trunk/dspace-api/src/main/java/org/dspace/workflow/WorkflowItem.java 2008-09-11 01:18:03 UTC (rev 3126)
+++ trunk/dspace-api/src/main/java/org/dspace/workflow/WorkflowItem.java 2008-09-11 15:06:38 UTC (rev 3127)
@@ -55,7 +55,7 @@
/**
* Class representing an item going through the workflow process in DSpace
- *
+ *
* @author Robert Tansley
* @version $Revision$
*/
@@ -109,7 +109,7 @@
/**
* get owner of WorkflowItem
- *
+ *
* @return EPerson owner
*/
public EPerson getOwner()
@@ -132,7 +132,7 @@
/**
* Set the state of WorkflowItem.
- *
+ *
* @param state new state (from <code>WorkflowManager</code>)
*/
public void setState(int state)
@@ -145,7 +145,7 @@
{
return item;
}
-
+
public void setItem(Item item)
{
this.item = item;
@@ -155,7 +155,7 @@
{
return collection;
}
-
+
public void setCollection(Collection collection)
{
this.collection = collection;
Modified: trunk/dspace-api/src/main/java/org/dspace/workflow/WorkflowManager.java
===================================================================
--- trunk/dspace-api/src/main/java/org/dspace/workflow/WorkflowManager.java 2008-09-11 01:18:03 UTC (rev 3126)
+++ trunk/dspace-api/src/main/java/org/dspace/workflow/WorkflowManager.java 2008-09-11 15:06:38 UTC (rev 3127)
@@ -74,26 +74,26 @@
/**
* Workflow state machine
- *
+ *
* Notes:
- *
+ *
* Determining item status from the database:
- *
+ *
* When an item has not been submitted yet, it is in the user's personal
* workspace (there is a row in PersonalWorkspace pointing to it.)
- *
+ *
* When an item is submitted and is somewhere in a workflow, it has a row in the
* WorkflowItem table pointing to it. The state of the workflow can be
* determined by looking at WorkflowItem.getState()
- *
+ *
* When a submission is complete, the WorkflowItem pointing to the item is
* destroyed and the archive() method is called, which hooks the item up to the
* archive.
- *
+ *
* Notification: When an item enters a state that requires notification,
* (WFSTATE_STEP1POOL, WFSTATE_STEP2POOL, WFSTATE_STEP3POOL,) the workflow needs
* to notify the appropriate groups that they have a pending task to claim.
- *
+ *
* Revealing lists of approvers, editors, and reviewers. A method could be added
* to do this, but it isn't strictly necessary. (say public List
* getStateEPeople( WorkflowItem wi, int state ) could return people affected by
@@ -162,7 +162,7 @@
/**
* startWorkflow() begins a workflow - in a single transaction do away with
* the PersonalWorkspace entry and turn it into a WorkflowItem.
- *
+ *
* @param c
* Context
* @param wsi
@@ -211,7 +211,7 @@
* getOwnedTasks() returns a List of WorkflowItems containing the tasks
* claimed and owned by an EPerson. The GUI displays this info on the
* MyDSpace page.
- *
+ *
* @param e
* The EPerson we want to fetch owned tasks for.
*/
@@ -224,7 +224,7 @@
/**
* getPooledTasks() returns a List of WorkflowItems an EPerson could claim
* (as a reviewer, etc.) for display on a user's MyDSpace page.
- *
+ *
* @param e
* The Eperson we want to fetch the pooled tasks for.
*/
@@ -244,7 +244,7 @@
/**
* claim() claims a workflow task for an EPerson
- *
+ *
* @param wi
* WorkflowItem to do the claim on
* @param e
@@ -295,7 +295,7 @@
* the item arrives at the submit state, then remove the WorkflowItem and
* call the archive() method to put it in the archive, and email notify the
* submitter of a successful submission
- *
+ *
* @param c
* Context
* @param wi
@@ -349,7 +349,7 @@
/**
* unclaim() returns an owned task/item to the pool
- *
+ *
* @param c
* Context
* @param wi
@@ -400,7 +400,7 @@
* abort() aborts a workflow, completely deleting it (administrator do this)
* (it will basically do a reject from any state - the item ends up back in
* the user's PersonalWorkspace
- *
+ *
* @param c
* Context
* @param wi
@@ -455,7 +455,7 @@
{
// get a list of all epeople in group (or any subgroups)
EPerson[] epa = Group.allMembers(c, mygroup);
-
+
// there were reviewers, change the state
// and add them to the list
createTasks(c, wi, epa);
@@ -496,7 +496,7 @@
{
//get a list of all epeople in group (or any subgroups)
EPerson[] epa = Group.allMembers(c, mygroup);
-
+
// there were approvers, change the state
// timestamp, and add them to the list
createTasks(c, wi, epa);
@@ -532,7 +532,7 @@
{
// get a list of all epeople in group (or any subgroups)
EPerson[] epa = Group.allMembers(c, mygroup);
-
+
// there were editors, change the state
// timestamp, and add them to the list
createTasks(c, wi, epa);
@@ -594,7 +594,7 @@
* Commit the contained item to the main archive. The item is associated
* with the relevant collection, added to the search index, and any other
* tasks such as assigning dates are performed.
- *
+ *
* @return the fully archived item.
*/
private static Item archive(Context c, WorkflowItem wfi)
@@ -633,7 +633,7 @@
Email email = ConfigurationManager.getEmail(
I18nUtil.getEmailFilename(supportedLocale,
"submit_archive"));
-
+
// Here, we try to get an external identifier for the item to send
// in the notification email. If no external identifier exists, we
// just send the "local" item URL.
@@ -684,7 +684,7 @@
/**
* Return the workflow item to the workspace of the submitter. The workflow
* item is removed, and a workspace item created.
- *
+ *
* @param c
* Context
* @param wfi
@@ -715,7 +715,7 @@
* rejects an item - rejection means undoing a submit - WorkspaceItem is
* created, and the WorkflowItem is removed, user is emailed
* rejection_message.
- *
+ *
* @param c
* Context
* @param wi
@@ -825,17 +825,17 @@
{
case WFSTATE_STEP1POOL:
message = messages.getString("org.dspace.workflow.WorkflowManager.step1");
-
+
break;
-
+
case WFSTATE_STEP2POOL:
message = messages.getString("org.dspace.workflow.WorkflowManager.step2");
-
+
break;
-
+
case WFSTATE_STEP3POOL:
message = messages.getString("org.dspace.workflow.WorkflowManager.step3");
-
+
break;
}
email.addArgument(message);
@@ -856,7 +856,7 @@
/**
* Add all the specified people to the list of email recipients,
* and send it
- *
+ *
* @param c
* Context
* @param epeople
@@ -925,7 +925,7 @@
/**
* get the title of the item in this workflow
- *
+ *
* @param wi the workflow item object
*/
public static String getItemTitle(WorkflowItem wi)
@@ -946,7 +946,7 @@
/**
* get the name of the eperson who started this workflow
- *
+ *
* @param wi the workflow item
*/
public static String getSubmitterName(WorkflowItem wi)
Modified: trunk/dspace-jspui/dspace-jspui-api/src/main/java/org/dspace/app/webui/servlet/FeedServlet.java
===================================================================
--- trunk/dspace-jspui/dspace-jspui-api/src/main/java/org/dspace/app/webui/servlet/FeedServlet.java 2008-09-11 01:18:03 UTC (rev 3126)
+++ trunk/dspace-jspui/dspace-jspui-api/src/main/java/org/dspace/app/webui/servlet/FeedServlet.java 2008-09-11 15:06:38 UTC (rev 3127)
@@ -93,7 +93,7 @@
* Servlet for handling requests for a syndication feed. The URI of the collection
* or community is extracted from the URL, e.g: <code>/feed/rss_1.0/xyz:1234/5678</code>.
* Currently supports only RSS feed formats.
- *
+ *
* @author Ben Bosman, Richard Rodgers, James Rutherford
* @version $Revision$
*/
@@ -101,14 +101,14 @@
{
// key for site-wide feed
public static final String SITE_FEED_KEY = "site";
-
+
// one hour in milliseconds
private static final long HOUR_MSECS = 60 * 60 * 1000;
/** log4j category */
private static Logger log = Logger.getLogger(FeedServlet.class);
private String clazz = "org.dspace.app.webui.servlet.FeedServlet";
-
+
// are syndication feeds enabled?
private static boolean enabled = false;
// number of DSpace items per feed
@@ -121,19 +121,19 @@
private static int cacheAge = 0;
// supported syndication formats
private static List formats = null;
-
+
// localized resource bundle
private static ResourceBundle labels = null;
-
+
//default fields to display in item description
private static String defaultDescriptionFields = "dc.title, dc.contributor.author, dc.contributor.editor, dc.description.abstract, dc.description";
-
+
static
{
enabled = ConfigurationManager.getBooleanProperty("webui.feed.enable");
}
-
+
public void init()
{
// read rest of config info if enabled
@@ -193,7 +193,7 @@
//as long as this is not a site wide feed,
//attempt to retrieve the Collection or Community object
if(!uri.equals(SITE_FEED_KEY))
- {
+ {
// Determine if the URI is a valid reference
ResolvableIdentifier di = IdentifierService.resolve(context, uri);
dso = (DSpaceObject) IdentifierService.getResource(context, di);
@@ -272,7 +272,7 @@
throw new ServletException(e);
}
}
-
+
private boolean itemsChanged(Context context, DSpaceObject dso, long timeStamp)
throws SQLException
{
@@ -283,7 +283,7 @@
// convert dates to ISO 8601, stripping the time
String startDate = dcStartDate.toString().substring(0, 10);
String endDate = dcEndDate.toString().substring(0, 10);
-
+
// this invocation should return a non-empty list if even 1 item has changed
try {
return (Harvest.harvest(context, dso, startDate, endDate,
@@ -295,15 +295,15 @@
return false;
}
}
-
+
/**
* Generate a syndication feed for a collection or community
* or community
- *
+ *
* @param context the DSpace context object
- *
+ *
* @param dso DSpace object - collection or community
- *
+ *
* @return an object representing the feed
*/
private Channel generateFeed(Context context, DSpaceObject dso)
@@ -311,7 +311,7 @@
{
try
{
- // container-level elements
+ // container-level elements
String dspaceUrl = ConfigurationManager.getProperty("dspace.url");
String type = null;
String description = null;
@@ -319,7 +319,7 @@
Bitstream logo = null;
// browse scope
// BrowseScope scope = new BrowseScope(context);
-
+
// new method of doing the browse:
String idx = ConfigurationManager.getProperty("recent.submissions.sort-option");
if (idx == null)
@@ -331,7 +331,7 @@
{
throw new IOException("There is no browse index with the name: " + idx);
}
-
+
BrowserScope scope = new BrowserScope(context);
scope.setBrowseIndex(bix);
for (SortOption so : SortOption.getSortOptions())
@@ -340,11 +340,11 @@
scope.setSortBy(so.getNumber());
}
scope.setOrder(SortOption.DESCENDING);
-
+
// the feed
Channel channel = new Channel();
-
- //Special Case: if DSpace Object passed in is null,
+
+ //Special Case: if DSpace Object passed in is null,
//generate a feed for the entire DSpace site!
if(dso == null)
{
@@ -361,8 +361,8 @@
description = col.getMetadata("short_description");
title = col.getMetadata("name");
logo = col.getLogo();
- // scope.setScope(col);
- scope.setBrowseContainer(col);
+ // scope.setScope(col);
+ scope.setBrowseContainer(col);
}
else if (dso.getType() == Constants.COMMUNITY)
{
@@ -371,10 +371,10 @@
description = comm.getMetadata("short_description");
title = comm.getMetadata("name");
logo = comm.getLogo();
- // scope.setScope(comm);
- scope.setBrowseContainer(comm);
+ // scope.setScope(comm);
+ scope.setBrowseContainer(comm);
}
-
+
String objectUrl = "";
if (dso.getExternalIdentifier() != null)
{
@@ -389,13 +389,13 @@
}
// put in container-level data
- channel.setDescription(description.replaceAll("\\p{Cntrl}", ""));
+ channel.setDescription(description == null ? "" : description.replaceAll("\\p{Cntrl}", ""));
channel.setLink(objectUrl);
//build channel title by passing in type and title
String channelTitle = MessageFormat.format(labels.getString(clazz + ".feed.title"),
new Object[]{type, title});
channel.setTitle(channelTitle);
-
+
//if collection or community has a logo
if (logo != null)
{
@@ -408,7 +408,7 @@
channel.setImage(image);
}
}
-
+
// this is a direct link to the search-engine of dspace. It searches
// in the current collection. Since the current version of DSpace
// can't search within collections anymore, this works only in older
@@ -416,9 +416,9 @@
TextInput input = new TextInput();
input.setLink(dspaceUrl + "/simple-search");
input.setDescription( labels.getString(clazz + ".search.description") );
-
- String searchTitle = "";
-
+
+ String searchTitle = "";
+
//if a "type" of feed was specified, build search title off that
if(type!=null)
{
@@ -429,14 +429,14 @@
{
searchTitle = labels.getString(clazz + ".search.title.default");
}
-
+
input.setTitle(searchTitle);
input.setName(labels.getString(clazz + ".search.name"));
channel.setTextInput(input);
-
+
// gather & add items to the feed.
scope.setResultsPerPage(itemCount);
-
+
BrowseEngine be = new BrowseEngine(context);
BrowseInfo bi = be.browseMini(scope);
Item[] results = bi.getBrowseItemResults(context);
@@ -445,7 +445,7 @@
{
items.add(itemFromDSpaceItem(context, results[i]));
}
-
+
channel.setItems(items);
// If the description is null, replace it with an empty string
@@ -466,36 +466,36 @@
throw new IOException(e.getMessage());
}
}
-
+
/**
* The metadata fields of the given item will be added to the given feed.
- *
+ *
* @param context DSpace context object
- *
+ *
* @param dspaceItem DSpace Item
- *
+ *
* @return an object representing a feed entry
*/
private com.sun.syndication.feed.rss.Item itemFromDSpaceItem(Context context,
Item dspaceItem)
throws SQLException
{
- com.sun.syndication.feed.rss.Item rssItem =
+ com.sun.syndication.feed.rss.Item rssItem =
new com.sun.syndication.feed.rss.Item();
-
+
//get the title and date fields
String titleField = ConfigurationManager.getProperty("webui.feed.item.title");
if (titleField == null)
{
titleField = "dc.title";
}
-
+
String dateField = ConfigurationManager.getProperty("webui.feed.item.date");
if (dateField == null)
{
dateField = "dc.date.issued";
- }
-
+ }
+
//Set item URI
String link = ConfigurationManager.getBooleanProperty("webui.feed.localresolve")
? IdentifierService.getURL(dspaceItem).toString()
Modified: trunk/dspace-jspui/dspace-jspui-api/src/main/java/org/dspace/app/webui/servlet/StatisticsServlet.java
===================================================================
--- trunk/dspace-jspui/dspace-jspui-api/src/main/java/org/dspace/app/webui/servlet/StatisticsServlet.java 2008-09-11 01:18:03 UTC (rev 3126)
+++ trunk/dspace-jspui/dspace-jspui-api/src/main/java/org/dspace/app/webui/servlet/StatisticsServlet.java 2008-09-11 15:06:38 UTC (rev 3127)
@@ -122,6 +122,7 @@
HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException, SQLException, AuthorizeException
{
+ StringBuffer report = new StringBuffer();
String date = (String) request.getParameter("date");
request.setAttribute("date", date);
@@ -135,123 +136,135 @@
FileInputStream fir = null;
InputStreamReader ir = null;
BufferedReader br = null;
-
- List monthsList = new ArrayList();
-
- Pattern monthly = Pattern.compile("report-([0-9][0-9][0-9][0-9]-[0-9]+)\\.html");
- Pattern general = Pattern.compile("report-general-([0-9]+-[0-9]+-[0-9]+)\\.html");
-
- // FIXME: this whole thing is horribly inflexible and needs serious
- // work; but as a basic proof of concept will suffice
-
- // if no date is passed then we want to get the most recent general
- // report
- if (date == null)
+
+ try
{
- request.setAttribute("general", new Boolean(true));
-
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy'-'M'-'dd");
- Date mostRecentDate = null;
-
+ List monthsList = new ArrayList();
+
+ Pattern monthly = Pattern.compile("report-([0-9][0-9][0-9][0-9]-[0-9]+)\\.html");
+ Pattern general = Pattern.compile("report-general-([0-9]+-[0-9]+-[0-9]+)\\.html");
+
+ // FIXME: this whole thing is horribly inflexible and needs serious
+ // work; but as a basic proof of concept will suffice
+
+ // if no date is passed then we want to get the most recent general
+ // report
+ if (date == null)
+ {
+ request.setAttribute("general", new Boolean(true));
+
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy'-'M'-'dd");
+ Date mostRecentDate = null;
+
+ for (int i = 0; i < reports.length; i++)
+ {
+ Matcher matchGeneral = general.matcher(reports[i].getName());
+ if (matchGeneral.matches())
+ {
+ Date parsedDate = null;
+
+ try
+ {
+ parsedDate = sdf.parse(matchGeneral.group(1).trim());
+ }
+ catch (ParseException e)
+ {
+ // FIXME: currently no error handling
+ }
+
+ if (mostRecentDate == null)
+ {
+ mostRecentDate = parsedDate;
+ reportFile = reports[i];
+ }
+
+ if (parsedDate != null && parsedDate.compareTo(mostRecentDate) > 0)
+ {
+ mostRecentDate = parsedDate;
+ reportFile = reports[i];
+ }
+ }
+ }
+ }
+
+ // if a date is passed then we want to get the file for that month
+ if (date != null)
+ {
+ String desiredReport = "report-" + date + ".html";
+
+ for (int i = 0; i < reports.length; i++)
+ {
+ if (reports[i].getName().equals(desiredReport))
+ {
+ reportFile = reports[i];
+ }
+ }
+ }
+
+ if (reportFile == null)
+ {
+ JSPManager.showJSP(request, response, "statistics/no-report.jsp");
+ }
+
+ // finally, build the list of report dates
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy'-'M");
for (int i = 0; i < reports.length; i++)
{
- Matcher matchGeneral = general.matcher(reports[i].getName());
- if (matchGeneral.matches())
+ Matcher matchReport = monthly.matcher(reports[i].getName());
+ if (matchReport.matches())
{
Date parsedDate = null;
- try
+ try
{
- parsedDate = sdf.parse(matchGeneral.group(1).trim());
+ parsedDate = sdf.parse(matchReport.group(1).trim());
}
catch (ParseException e)
{
// FIXME: currently no error handling
}
-
- if (mostRecentDate == null)
- {
- mostRecentDate = parsedDate;
- reportFile = reports[i];
- }
-
- if (parsedDate.compareTo(mostRecentDate) > 0)
- {
- mostRecentDate = parsedDate;
- reportFile = reports[i];
- }
+
+ monthsList.add(parsedDate);
}
}
- }
-
- // if a date is passed then we want to get the file for that month
- if (date != null)
- {
- String desiredReport = "report-" + date + ".html";
-
- for (int i = 0; i < reports.length; i++)
+
+ Date[] months = new Date[monthsList.size()];
+ months = (Date[]) monthsList.toArray(months);
+
+ Arrays.sort(months);
+
+ request.setAttribute("months", months);
+
+ try
{
- if (reports[i].getName().equals(desiredReport))
- {
- reportFile = reports[i];
- }
+ fir = new FileInputStream(reportFile.getPath());
+ ir = new InputStreamReader(fir, "UTF-8");
+ br = new BufferedReader(ir);
}
- }
-
- if (reportFile == null)
- {
- JSPManager.showJSP(request, response, "statistics/no-report.jsp");
- }
-
- // finally, build the list of report dates
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy'-'M");
- for (int i = 0; i < reports.length; i++)
- {
- Matcher matchReport = monthly.matcher(reports[i].getName());
- if (matchReport.matches())
+ catch (IOException e)
{
- Date parsedDate = null;
-
- try
- {
- parsedDate = sdf.parse(matchReport.group(1).trim());
- }
- catch (ParseException e)
- {
- // FIXME: currently no error handling
- }
-
- monthsList.add(parsedDate);
+ // FIXME: no error handing yet
+ throw new RuntimeException(e.getMessage(),e);
}
+
+ // FIXME: there's got to be a better way of doing this
+ String line = null;
+ while ((line = br.readLine()) != null)
+ {
+ report.append(line);
+ }
}
-
- Date[] months = new Date[monthsList.size()];
- months = (Date[]) monthsList.toArray(months);
-
- Arrays.sort(months);
-
- request.setAttribute("months", months);
-
- try
- {
- fir = new FileInputStream(reportFile.getPath());
- ir = new InputStreamReader(fir, "UTF-8");
- br = new BufferedReader(ir);
- }
- catch (IOException e)
+ finally
{
- // FIXME: no error handing yet
- throw new RuntimeException(e.getMessage(),e);
- }
-
- // FIXME: there's got to be a better way of doing this
- StringBuffer report = new StringBuffer();
- String line = null;
- while ((line = br.readLine()) != null)
- {
- report.append(line);
+ 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
request.setAttribute("report", report.toString());
Modified: trunk/dspace-oai/dspace-oai-api/src/main/java/org/dspace/app/oai/DIDLCrosswalk.java
===================================================================
--- trunk/dspace-oai/dspace-oai-api/src/main/java/org/dspace/app/oai/DIDLCrosswalk.java 2008-09-11 01:18:03 UTC (rev 3126)
+++ trunk/dspace-oai/dspace-oai-api/src/main/java/org/dspace/app/oai/DIDLCrosswalk.java 2008-09-11 15:06:38 UTC (rev 3127)
@@ -56,10 +56,10 @@
/**
* DSpace Item DIDL crosswalk.
- *
- * Development of this code was part of the aDORe repository project
+ *
+ * Development of this code was part of the aDORe repository project
* by the Research Library of the Los Alamos National Laboratory.
- *
+ *
* @author Henry Jerez
* @author Los Alamos National Laboratory
*/
@@ -70,32 +70,32 @@
{
super("urn:mpeg:mpeg21:2002:02-DIDL-NS http://standards.iso.org/ittf/PubliclyAvailableStandards/MPEG-21_schema_files/did/didl.xsd ");
}
-
-
+
+
public boolean isAvailableFor(Object nativeItem)
{
// We have DC for everything
return true;
}
-
-
+
+
public String createMetadata(Object nativeItem)
throws CannotDisseminateFormatException
{
Item item = ((HarvestedItemInfo) nativeItem).item;
-
+
Date d = ((HarvestedItemInfo) nativeItem).datestamp;
String ITEMDATE = new DCDate(d).toString();
-
+
// Get all the DC
DCValue[] allDC = item.getDC(Item.ANY, Item.ANY, Item.ANY);
-
+
StringBuffer metadata = new StringBuffer();
StringBuffer metadata1 = new StringBuffer();
String itemURI=item.getIdentifier().getCanonicalForm();
- int maxsize= Integer.parseInt(ConfigurationManager.getProperty("oai.didl.maxresponse"));
+ int maxsize= Integer.parseInt(ConfigurationManager.getProperty("oai.didl.maxresponse"));
String currdate=ServerVerb.createResponseDate(new Date());
-
+
metadata.append("<didl:DIDL ")
.append(" xmlns:didl=\"urn:mpeg:mpeg21:2002:02-DIDL-NS\" ")
.append(" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" ")
@@ -115,7 +115,7 @@
.append("</didl:Descriptor>");
metadata.append("<didl:Descriptor>")
.append("<didl:Statement mimeType=\"application/xml; charset=utf-8\">");
-
+
for (int i = 0; i < allDC.length; i++)
{
// Do not include description.provenance
@@ -144,7 +144,7 @@
"<" +
value.substring(c + 1);
}
-
+
while ((c = value.indexOf(">")) > -1)
{
value = value.substring(0, c) +
@@ -161,48 +161,48 @@
.append(">");
}
}
-
+
metadata.append("<oai_dc:dc xmlns:oai_dc=\"http://www.openarchives.org/OAI/2.0/oai_dc/\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd\">");
-
+
metadata.append(metadata1);
-
+
metadata.append("</oai_dc:dc>")
.append("</didl:Statement>")
- .append("</didl:Descriptor>");
-
+ .append("</didl:Descriptor>");
+
/**putfirst item here**/
-
-
+
+
//**CYCLE HERE!!!!**//
-
- Bundle[] bundles= item.getBundles("ORIGINAL");
-
+
+ Bundle[] bundles= item.getBundles("ORIGINAL");
+
if (bundles.length == 0)
{
metadata.append("<P>There are no files associated with this item.</P>");
}
else
- {
+ {
/**cycle bundles**/
for (int i = 0; i < bundles.length; i++)
- {
- int flag=0;
+ {
+ int flag=0;
Bitstream[] bitstreams = bundles[i].getBitstreams();
-
+
/**cycle bitstreams**/
for (int k = 0; k < bitstreams.length ; k++)
{
// Skip internal types
if (!bitstreams[k].getFormat().isInternal())
{
- if (flag==0)
+ if (flag==0)
{
flag=1;
}
-
+
metadata.append("<didl:Component id=" + "\"uuid-"+ UUIDFactory.generateUUID().toString() + "\">");
-
- if (bitstreams[k].getSize()> maxsize)
+
+ if (bitstreams[k].getSize()> maxsize)
{
metadata.append("<didl:Resource ref=\""+ConfigurationManager.getProperty("dspace.url")+"/bitstream/"+itemURI+"/"+bitstreams[k].getSequenceID()+"/"+bitstreams[k].getName() );
metadata.append("\" mimeType=\"");
@@ -211,34 +211,47 @@
metadata.append("</didl:Resource>");
}
else
- {
-
+ {
+
try
{
metadata.append("<didl:Resource mimeType=\"");
metadata.append(bitstreams[k].getFormat().getMIMEType());
metadata.append("\" encoding=\"base64\">");
-
+
/*
@@ Diff output truncated at 100000 characters. @@
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|