mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-15 05:53:08 +00:00
[DS-707] Exception handling
git-svn-id: http://scm.dspace.org/svn/repo/dspace/trunk@5661 9c30dcfa-912a-0410-8fc2-9e0234be79fd
This commit is contained in:
@@ -265,7 +265,7 @@ public class CreateAdministrator
|
||||
|
||||
if (admins == null)
|
||||
{
|
||||
throw new Exception("Error, no admin group (group 1) found");
|
||||
throw new IllegalStateException("Error, no admin group (group 1) found");
|
||||
}
|
||||
|
||||
// Create the administrator e-person
|
||||
|
@@ -1033,7 +1033,7 @@ public class ItemExport
|
||||
{
|
||||
// wont throw here
|
||||
}
|
||||
throw new RuntimeException(e1);
|
||||
throw new IllegalStateException(e1);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
@@ -94,7 +94,7 @@ public class ScriptLauncher
|
||||
}
|
||||
String message = "Failure during filter init: " + e.getMessage();
|
||||
System.err.println(message + ":" + e);
|
||||
throw new RuntimeException(message, e);
|
||||
throw new IllegalStateException(message, e);
|
||||
}
|
||||
|
||||
// Parse the configuration file looking for the command entered
|
||||
|
@@ -112,7 +112,7 @@ public class DSpaceContextListener implements ServletContextListener
|
||||
// Finally, if no config parameter found throw an error
|
||||
if (dspaceConfig == null || "".equals(dspaceConfig))
|
||||
{
|
||||
throw new RuntimeException(
|
||||
throw new IllegalStateException(
|
||||
"\n\nDSpace has failed to initialize. This has occurred because it was unable to determine \n" +
|
||||
"where the dspace.cfg file is located. The path to the configuration file should be stored \n" +
|
||||
"in a context variable, '"+DSPACE_CONFIG_PARAMETER+"', in the global context. \n" +
|
||||
@@ -136,7 +136,7 @@ public class DSpaceContextListener implements ServletContextListener
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new RuntimeException(
|
||||
throw new IllegalStateException(
|
||||
"\n\nDSpace has failed to initialize, during stage 2. Error while attempting to read the \n" +
|
||||
"DSpace configuration file (Path: '"+dspaceConfig+"'). \n" +
|
||||
"This has likely occurred because either the file does not exist, or it's permissions \n" +
|
||||
|
@@ -233,8 +233,7 @@ public final class BitstreamInfoDAO extends DAOSupport
|
||||
catch (SQLException e)
|
||||
{
|
||||
LOG.error("Problem updating checksum row. " + e.getMessage(), e);
|
||||
throw new RuntimeException("Problem updating checksum row. "
|
||||
+ e.getMessage(), e);
|
||||
throw new IllegalStateException("Problem updating checksum row. " + e.getMessage(), e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -327,11 +326,8 @@ public final class BitstreamInfoDAO extends DAOSupport
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
LOG.error(
|
||||
"Problem inserting missing bitstreams. " + e.getMessage(),
|
||||
e);
|
||||
throw new RuntimeException("Problem inserting missing bitstreams. "
|
||||
+ e.getMessage(), e);
|
||||
LOG.error("Problem inserting missing bitstreams. " + e.getMessage(), e);
|
||||
throw new IllegalStateException("Problem inserting missing bitstreams. " + e.getMessage(), e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -373,8 +369,7 @@ public final class BitstreamInfoDAO extends DAOSupport
|
||||
catch (SQLException e)
|
||||
{
|
||||
LOG.error("Problem deleting bitstream. " + e.getMessage(), e);
|
||||
throw new RuntimeException("Problem deleting bitstream. "
|
||||
+ e.getMessage(), e);
|
||||
throw new IllegalStateException("Problem deleting bitstream. " + e.getMessage(), e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -399,8 +394,7 @@ public final class BitstreamInfoDAO extends DAOSupport
|
||||
catch (SQLException e)
|
||||
{
|
||||
LOG.error("Problem deleting bitstream. " + e.getMessage(), e);
|
||||
throw new RuntimeException("Problem deleting bitstream. "
|
||||
+ e.getMessage(), e);
|
||||
throw new IllegalStateException("Problem deleting bitstream. " + e.getMessage(), e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -449,8 +443,7 @@ public final class BitstreamInfoDAO extends DAOSupport
|
||||
catch (SQLException e)
|
||||
{
|
||||
LOG.error("Problem with get oldest bitstream " + e.getMessage(), e);
|
||||
throw new RuntimeException("Oldest bitstream error. "
|
||||
+ e.getMessage(), e);
|
||||
throw new IllegalStateException("Oldest bitstream error. " + e.getMessage(), e);
|
||||
|
||||
}
|
||||
finally
|
||||
@@ -499,8 +492,7 @@ public final class BitstreamInfoDAO extends DAOSupport
|
||||
{
|
||||
LOG.error("get oldest bitstream less than date " + e.getMessage(),
|
||||
e);
|
||||
throw new RuntimeException("get oldest bitstream less than date. "
|
||||
+ e.getMessage(), e);
|
||||
throw new IllegalStateException("get oldest bitstream less than date. " + e.getMessage(), e);
|
||||
|
||||
}
|
||||
finally
|
||||
@@ -541,8 +533,7 @@ public final class BitstreamInfoDAO extends DAOSupport
|
||||
catch (SQLException e)
|
||||
{
|
||||
LOG.error("get item bitstreams " + e.getMessage(), e);
|
||||
throw new RuntimeException(
|
||||
"get item bitstreams. " + e.getMessage(), e);
|
||||
throw new IllegalStateException("get item bitstreams. " + e.getMessage(), e);
|
||||
|
||||
}
|
||||
finally
|
||||
@@ -583,7 +574,7 @@ public final class BitstreamInfoDAO extends DAOSupport
|
||||
catch (SQLException e)
|
||||
{
|
||||
LOG.error("get item bitstreams " + e.getMessage(), e);
|
||||
throw new RuntimeException("get item bitstreams. " + e.getMessage(), e);
|
||||
throw new IllegalStateException("get item bitstreams. " + e.getMessage(), e);
|
||||
|
||||
}
|
||||
finally
|
||||
@@ -625,8 +616,7 @@ public final class BitstreamInfoDAO extends DAOSupport
|
||||
catch (SQLException e)
|
||||
{
|
||||
LOG.error("get item bitstreams " + e.getMessage(), e);
|
||||
throw new RuntimeException(
|
||||
"get item bitstreams. " + e.getMessage(), e);
|
||||
throw new IllegalStateException("get item bitstreams. " + e.getMessage(), e);
|
||||
|
||||
}
|
||||
finally
|
||||
|
@@ -156,8 +156,7 @@ public class ChecksumHistoryDAO extends DAOSupport
|
||||
catch (SQLException e)
|
||||
{
|
||||
LOG.error("Problem updating checksum row. " + e.getMessage(), e);
|
||||
throw new RuntimeException("Problem updating checksum row. "
|
||||
+ e.getMessage(), e);
|
||||
throw new IllegalStateException("Problem updating checksum row. " + e.getMessage(), e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -190,10 +189,8 @@ public class ChecksumHistoryDAO extends DAOSupport
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
LOG.error("Problem with inserting missing bitstream. "
|
||||
+ e.getMessage(), e);
|
||||
throw new RuntimeException("Problem inserting missing bitstream. "
|
||||
+ e.getMessage(), e);
|
||||
LOG.error("Problem with inserting missing bitstream. " + e.getMessage(), e);
|
||||
throw new IllegalStateException("Problem inserting missing bitstream. " + e.getMessage(), e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -224,8 +221,7 @@ public class ChecksumHistoryDAO extends DAOSupport
|
||||
catch (SQLException e)
|
||||
{
|
||||
LOG.error("Problem updating missing history. " + e.getMessage(), e);
|
||||
throw new RuntimeException("Problem updating missing history. "
|
||||
+ e.getMessage(), e);
|
||||
throw new IllegalStateException("Problem updating missing history. " + e.getMessage(), e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -293,8 +289,7 @@ public class ChecksumHistoryDAO extends DAOSupport
|
||||
catch (SQLException e)
|
||||
{
|
||||
LOG.error("Problem pruning results: " + e.getMessage(), e);
|
||||
throw new RuntimeException("Problem pruning results: "
|
||||
+ e.getMessage(), e);
|
||||
throw new IllegalStateException("Problem pruning results: " + e.getMessage(), e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
@@ -101,10 +101,8 @@ public final class ChecksumResultDAO extends DAOSupport
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
LOG.error("Problem selecting checker result description. "
|
||||
+ e.getMessage(), e);
|
||||
throw new RuntimeException("selecting checker result description. "
|
||||
+ e.getMessage(), e);
|
||||
LOG.error("Problem selecting checker result description. " + e.getMessage(), e);
|
||||
throw new IllegalStateException("selecting checker result description. " + e.getMessage(), e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -140,11 +138,8 @@ public final class ChecksumResultDAO extends DAOSupport
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
LOG.error("Problem listing checksum results codes: "
|
||||
+ e.getMessage(), e);
|
||||
throw new RuntimeException(
|
||||
"Problem listing checksum results codes: " + e.getMessage(),
|
||||
e);
|
||||
LOG.error("Problem listing checksum results codes: " + e.getMessage(), e);
|
||||
throw new IllegalStateException("Problem listing checksum results codes: " + e.getMessage(), e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
@@ -115,7 +115,7 @@ public class HandleDispatcher implements BitstreamDispatcher
|
||||
catch (SQLException e)
|
||||
{
|
||||
LOG.error("init error " + e.getMessage(), e);
|
||||
throw new RuntimeException("init error" + e.getMessage(), e);
|
||||
throw new IllegalStateException("init error" + e.getMessage(), e);
|
||||
|
||||
}
|
||||
finally
|
||||
|
@@ -81,7 +81,7 @@ public final class ResultsPruner
|
||||
}
|
||||
catch (FileNotFoundException e)
|
||||
{
|
||||
throw new RuntimeException(
|
||||
throw new IllegalStateException(
|
||||
"VeryExceptionalException - config file not there! ", e);
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ public final class ResultsPruner
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
throw new RuntimeException("Problem loading properties file: "
|
||||
throw new IllegalStateException("Problem loading properties file: "
|
||||
+ e.getMessage(), e);
|
||||
}
|
||||
finally
|
||||
@@ -161,7 +161,7 @@ public final class ResultsPruner
|
||||
}
|
||||
catch (ParseException e)
|
||||
{
|
||||
throw new RuntimeException("Problem parsing duration: "
|
||||
throw new IllegalStateException("Problem parsing duration: "
|
||||
+ e.getMessage(), e);
|
||||
}
|
||||
if ("default".equals(resultCode))
|
||||
|
@@ -1177,7 +1177,7 @@ public class Collection extends DSpaceObject
|
||||
{
|
||||
// FIXME: upside down exception handling due to lack of good
|
||||
// exception framework
|
||||
throw new RuntimeException(e.getMessage(), e);
|
||||
throw new IllegalStateException(e.getMessage(), e);
|
||||
}
|
||||
|
||||
// Remove any Handle
|
||||
|
@@ -1136,7 +1136,7 @@ public class Community extends DSpaceObject
|
||||
{
|
||||
// FIXME: upside down exception handling due to lack of good
|
||||
// exception framework
|
||||
throw new RuntimeException(e.getMessage(),e);
|
||||
throw new IllegalStateException(e.getMessage(),e);
|
||||
}
|
||||
|
||||
// Remove any Handle
|
||||
|
@@ -306,7 +306,7 @@ public class ConfigurationManager
|
||||
|
||||
// FIXME: Maybe something more graceful here, but with the
|
||||
// configuration we can't do anything
|
||||
throw new RuntimeException("Failed to read default license.", e);
|
||||
throw new IllegalStateException("Failed to read default license.", e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -695,7 +695,7 @@ public class ConfigurationManager
|
||||
if (url == null)
|
||||
{
|
||||
fatal("Cannot find dspace.cfg");
|
||||
throw new RuntimeException("Cannot find dspace.cfg");
|
||||
throw new IllegalStateException("Cannot find dspace.cfg");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -722,7 +722,7 @@ public class ConfigurationManager
|
||||
|
||||
// FIXME: Maybe something more graceful here, but with the
|
||||
// configuration we can't do anything
|
||||
throw new RuntimeException("Cannot load configuration: " + url, e);
|
||||
throw new IllegalStateException("Cannot load configuration: " + url, e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -768,7 +768,7 @@ public class ConfigurationManager
|
||||
|
||||
// FIXME: Maybe something more graceful here, but with the
|
||||
// configuration we can't do anything
|
||||
throw new RuntimeException("Cannot load license: " + licenseFile.toString(),e);
|
||||
throw new IllegalStateException("Cannot load license: " + licenseFile.toString(),e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -866,7 +866,7 @@ public class ConfigurationManager
|
||||
catch (MalformedURLException e)
|
||||
{
|
||||
fatal("Can't load dspace provided log4j configuration", e);
|
||||
throw new RuntimeException("Cannot load dspace provided log4j configuration",e);
|
||||
throw new IllegalStateException("Cannot load dspace provided log4j configuration",e);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -208,7 +208,7 @@ public class Group extends DSpaceObject
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
isDataLoaded = true;
|
||||
}
|
||||
|
@@ -142,8 +142,7 @@ public class EventManager
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new RuntimeException("Unable to aquire dispatcher named "
|
||||
+ name, e);
|
||||
throw new IllegalStateException("Unable to aquire dispatcher named " + name, e);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -232,7 +231,7 @@ public class EventManager
|
||||
.getProperty(consumerKey);
|
||||
if (consumerList == null)
|
||||
{
|
||||
throw new RuntimeException(
|
||||
throw new IllegalStateException(
|
||||
"No Configuration entry found for consumer list of event Dispatcher: \""
|
||||
+ consumerKey + "\"");
|
||||
}
|
||||
@@ -245,7 +244,7 @@ public class EventManager
|
||||
// I think this should be a fatal error.. --lcs
|
||||
if (consumerStanza.length < 1)
|
||||
{
|
||||
throw new RuntimeException(
|
||||
throw new IllegalStateException(
|
||||
"Cannot initialize Dispatcher, malformed Configuration value for "
|
||||
+ consumerKey);
|
||||
}
|
||||
@@ -264,38 +263,38 @@ public class EventManager
|
||||
}
|
||||
catch (NoSuchMethodException e)
|
||||
{
|
||||
throw new RuntimeException(
|
||||
throw new IllegalStateException(
|
||||
"Constructor not found for event dispatcher="
|
||||
+ dispatcherName, e);
|
||||
}
|
||||
catch (InvocationTargetException e)
|
||||
{
|
||||
throw new RuntimeException(
|
||||
throw new IllegalStateException(
|
||||
"Error creating event dispatcher=" + dispatcherName,
|
||||
e);
|
||||
}
|
||||
catch (ClassNotFoundException e)
|
||||
{
|
||||
throw new RuntimeException(
|
||||
throw new IllegalStateException(
|
||||
"Dispatcher/Consumer class not found for event dispatcher="
|
||||
+ dispatcherName, e);
|
||||
}
|
||||
catch (InstantiationException e)
|
||||
{
|
||||
throw new RuntimeException(
|
||||
throw new IllegalStateException(
|
||||
"Dispatcher/Consumer instantiation failure for event dispatcher="
|
||||
+ dispatcherName, e);
|
||||
}
|
||||
catch (IllegalAccessException e)
|
||||
{
|
||||
throw new RuntimeException(
|
||||
throw new IllegalStateException(
|
||||
"Dispatcher/Consumer access failure for event dispatcher="
|
||||
+ dispatcherName, e);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new RuntimeException(
|
||||
throw new IllegalStateException(
|
||||
"Requested Dispatcher Does Not Exist In DSpace Configuration!");
|
||||
}
|
||||
|
||||
|
@@ -115,7 +115,7 @@ public class CreativeCommons
|
||||
}
|
||||
catch (TransformerConfigurationException e)
|
||||
{
|
||||
throw new RuntimeException(e.getMessage(),e);
|
||||
throw new IllegalStateException(e.getMessage(),e);
|
||||
}
|
||||
|
||||
|
||||
@@ -311,7 +311,7 @@ public class CreativeCommons
|
||||
}
|
||||
catch (TransformerException e)
|
||||
{
|
||||
throw new RuntimeException(e.getMessage(),e);
|
||||
throw new IllegalStateException(e.getMessage(),e);
|
||||
}
|
||||
|
||||
return result.getBuffer().toString();
|
||||
|
@@ -87,7 +87,7 @@ public class LicenseCleanup
|
||||
catch (TransformerConfigurationException e)
|
||||
{
|
||||
log.error(e.getMessage(), e);
|
||||
throw new RuntimeException(e.getMessage(), e);
|
||||
throw new IllegalStateException(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -188,7 +188,7 @@ public class LicenseCleanup
|
||||
}
|
||||
catch (TransformerException e)
|
||||
{
|
||||
throw new RuntimeException(e.getMessage(), e);
|
||||
throw new IllegalStateException(e.getMessage(), e);
|
||||
}
|
||||
|
||||
StringBuffer buffer = result.getBuffer();
|
||||
|
@@ -212,8 +212,7 @@ public class DSIndexer
|
||||
default:
|
||||
log.warn("Malformed configuration line: search.index." + i);
|
||||
// FIXME: Can't proceed here, no suitable exception to throw
|
||||
throw new RuntimeException(
|
||||
"Malformed configuration line: search.index." + i);
|
||||
throw new IllegalStateException("Malformed configuration line: search.index." + i);
|
||||
}
|
||||
|
||||
if (configLine.length > 2)
|
||||
@@ -240,8 +239,7 @@ public class DSIndexer
|
||||
}
|
||||
openIndex(true).close();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(
|
||||
"Could not create search index: " + e.getMessage(),e);
|
||||
throw new IllegalStateException("Could not create search index: " + e.getMessage(),e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -88,7 +88,7 @@ public class InitializeDatabase
|
||||
catch (BrowseException e)
|
||||
{
|
||||
log.error(e.getMessage(),e);
|
||||
throw new RuntimeException(e.getMessage(),e);
|
||||
throw new IllegalStateException(e.getMessage(),e);
|
||||
}
|
||||
|
||||
DatabaseManager.loadSql(getScript(argv[0]));
|
||||
@@ -109,7 +109,7 @@ public class InitializeDatabase
|
||||
catch (BrowseException e)
|
||||
{
|
||||
log.error(e.getMessage(),e);
|
||||
throw new RuntimeException(e.getMessage(),e);
|
||||
throw new IllegalStateException(e.getMessage(),e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -151,7 +151,7 @@ public class SearchUtils {
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw new RuntimeException(e.getMessage(), e);
|
||||
throw new IllegalStateException(e.getMessage(), e);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -241,7 +241,7 @@ public class StatisticsServlet extends org.dspace.app.webui.servlet.DSpaceServle
|
||||
catch (IOException e)
|
||||
{
|
||||
// FIXME: no error handing yet
|
||||
throw new RuntimeException(e.getMessage(),e);
|
||||
throw new IllegalStateException(e.getMessage(),e);
|
||||
}
|
||||
|
||||
// FIXME: there's got to be a better way of doing this
|
||||
|
@@ -194,7 +194,7 @@ public class GuiClient extends JFrame implements ClientType,
|
||||
"Unable to load properties file " + ioe.getMessage(),
|
||||
"Properties", JOptionPane.ERROR_MESSAGE);
|
||||
} catch (URISyntaxException e) {
|
||||
throw new RuntimeException(
|
||||
throw new IllegalStateException(
|
||||
"Most unexpectedly, a file URL is not a URI.", e);
|
||||
} finally {
|
||||
IOUtils.closeQuietly(stream);
|
||||
@@ -1102,7 +1102,7 @@ public class GuiClient extends JFrame implements ClientType,
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new RuntimeException(
|
||||
throw new IllegalStateException(
|
||||
"Don't know how to unpack help files from " + help);
|
||||
}
|
||||
}
|
||||
|
@@ -92,7 +92,7 @@ public class AuthenticationCountSelector implements Selector{
|
||||
catch (SQLException e)
|
||||
{
|
||||
// mmm... we should not never go here, anyway we convert it in an unchecked exception
|
||||
throw new RuntimeException(e);
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user