diff --git a/dspace-api/src/main/java/org/dspace/administer/CreateAdministrator.java b/dspace-api/src/main/java/org/dspace/administer/CreateAdministrator.java index 6a2a6de409..a1f6dc8de9 100644 --- a/dspace-api/src/main/java/org/dspace/administer/CreateAdministrator.java +++ b/dspace-api/src/main/java/org/dspace/administer/CreateAdministrator.java @@ -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 diff --git a/dspace-api/src/main/java/org/dspace/app/itemexport/ItemExport.java b/dspace-api/src/main/java/org/dspace/app/itemexport/ItemExport.java index 51c73a4813..e28c97f3e1 100644 --- a/dspace-api/src/main/java/org/dspace/app/itemexport/ItemExport.java +++ b/dspace-api/src/main/java/org/dspace/app/itemexport/ItemExport.java @@ -1033,7 +1033,7 @@ public class ItemExport { // wont throw here } - throw new RuntimeException(e1); + throw new IllegalStateException(e1); } finally { diff --git a/dspace-api/src/main/java/org/dspace/app/launcher/ScriptLauncher.java b/dspace-api/src/main/java/org/dspace/app/launcher/ScriptLauncher.java index 8a0984f6d1..bb160c2a14 100644 --- a/dspace-api/src/main/java/org/dspace/app/launcher/ScriptLauncher.java +++ b/dspace-api/src/main/java/org/dspace/app/launcher/ScriptLauncher.java @@ -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 diff --git a/dspace-api/src/main/java/org/dspace/app/util/DSpaceContextListener.java b/dspace-api/src/main/java/org/dspace/app/util/DSpaceContextListener.java index e2601ee8fc..a725823fd8 100644 --- a/dspace-api/src/main/java/org/dspace/app/util/DSpaceContextListener.java +++ b/dspace-api/src/main/java/org/dspace/app/util/DSpaceContextListener.java @@ -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" + diff --git a/dspace-api/src/main/java/org/dspace/checker/BitstreamInfoDAO.java b/dspace-api/src/main/java/org/dspace/checker/BitstreamInfoDAO.java index 05f434163c..055f606e8a 100644 --- a/dspace-api/src/main/java/org/dspace/checker/BitstreamInfoDAO.java +++ b/dspace-api/src/main/java/org/dspace/checker/BitstreamInfoDAO.java @@ -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 diff --git a/dspace-api/src/main/java/org/dspace/checker/ChecksumHistoryDAO.java b/dspace-api/src/main/java/org/dspace/checker/ChecksumHistoryDAO.java index 4609473c3d..480f91cc3d 100644 --- a/dspace-api/src/main/java/org/dspace/checker/ChecksumHistoryDAO.java +++ b/dspace-api/src/main/java/org/dspace/checker/ChecksumHistoryDAO.java @@ -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 { diff --git a/dspace-api/src/main/java/org/dspace/checker/ChecksumResultDAO.java b/dspace-api/src/main/java/org/dspace/checker/ChecksumResultDAO.java index e5ce914421..79e2553b58 100644 --- a/dspace-api/src/main/java/org/dspace/checker/ChecksumResultDAO.java +++ b/dspace-api/src/main/java/org/dspace/checker/ChecksumResultDAO.java @@ -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 { diff --git a/dspace-api/src/main/java/org/dspace/checker/HandleDispatcher.java b/dspace-api/src/main/java/org/dspace/checker/HandleDispatcher.java index ff505defb6..27ad006fbd 100644 --- a/dspace-api/src/main/java/org/dspace/checker/HandleDispatcher.java +++ b/dspace-api/src/main/java/org/dspace/checker/HandleDispatcher.java @@ -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 diff --git a/dspace-api/src/main/java/org/dspace/checker/ResultsPruner.java b/dspace-api/src/main/java/org/dspace/checker/ResultsPruner.java index aefcf77ab5..18e8b3d264 100644 --- a/dspace-api/src/main/java/org/dspace/checker/ResultsPruner.java +++ b/dspace-api/src/main/java/org/dspace/checker/ResultsPruner.java @@ -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)) diff --git a/dspace-api/src/main/java/org/dspace/content/Collection.java b/dspace-api/src/main/java/org/dspace/content/Collection.java index 29f07e99b8..98df95072e 100644 --- a/dspace-api/src/main/java/org/dspace/content/Collection.java +++ b/dspace-api/src/main/java/org/dspace/content/Collection.java @@ -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 diff --git a/dspace-api/src/main/java/org/dspace/content/Community.java b/dspace-api/src/main/java/org/dspace/content/Community.java index d7f30aabee..3a1b7db5e9 100644 --- a/dspace-api/src/main/java/org/dspace/content/Community.java +++ b/dspace-api/src/main/java/org/dspace/content/Community.java @@ -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 diff --git a/dspace-api/src/main/java/org/dspace/core/ConfigurationManager.java b/dspace-api/src/main/java/org/dspace/core/ConfigurationManager.java index dd20489e75..ae84167528 100644 --- a/dspace-api/src/main/java/org/dspace/core/ConfigurationManager.java +++ b/dspace-api/src/main/java/org/dspace/core/ConfigurationManager.java @@ -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); } } diff --git a/dspace-api/src/main/java/org/dspace/eperson/Group.java b/dspace-api/src/main/java/org/dspace/eperson/Group.java index 95a703a5e2..23eb4ebcd2 100644 --- a/dspace-api/src/main/java/org/dspace/eperson/Group.java +++ b/dspace-api/src/main/java/org/dspace/eperson/Group.java @@ -208,7 +208,7 @@ public class Group extends DSpaceObject } catch (Exception e) { - throw new RuntimeException(e); + throw new IllegalStateException(e); } isDataLoaded = true; } diff --git a/dspace-api/src/main/java/org/dspace/event/EventManager.java b/dspace-api/src/main/java/org/dspace/event/EventManager.java index 76f6064c08..611777e24d 100644 --- a/dspace-api/src/main/java/org/dspace/event/EventManager.java +++ b/dspace-api/src/main/java/org/dspace/event/EventManager.java @@ -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!"); } diff --git a/dspace-api/src/main/java/org/dspace/license/CreativeCommons.java b/dspace-api/src/main/java/org/dspace/license/CreativeCommons.java index af7b1adcd8..1b7ae09bfb 100644 --- a/dspace-api/src/main/java/org/dspace/license/CreativeCommons.java +++ b/dspace-api/src/main/java/org/dspace/license/CreativeCommons.java @@ -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(); diff --git a/dspace-api/src/main/java/org/dspace/license/LicenseCleanup.java b/dspace-api/src/main/java/org/dspace/license/LicenseCleanup.java index 1c9ea3ea40..e99c1aa03c 100644 --- a/dspace-api/src/main/java/org/dspace/license/LicenseCleanup.java +++ b/dspace-api/src/main/java/org/dspace/license/LicenseCleanup.java @@ -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(); diff --git a/dspace-api/src/main/java/org/dspace/search/DSIndexer.java b/dspace-api/src/main/java/org/dspace/search/DSIndexer.java index f88ddfd8fb..993c69eb7c 100644 --- a/dspace-api/src/main/java/org/dspace/search/DSIndexer.java +++ b/dspace-api/src/main/java/org/dspace/search/DSIndexer.java @@ -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); } } } diff --git a/dspace-api/src/main/java/org/dspace/storage/rdbms/InitializeDatabase.java b/dspace-api/src/main/java/org/dspace/storage/rdbms/InitializeDatabase.java index a6c0591b3a..a8e2ea8ad9 100644 --- a/dspace-api/src/main/java/org/dspace/storage/rdbms/InitializeDatabase.java +++ b/dspace-api/src/main/java/org/dspace/storage/rdbms/InitializeDatabase.java @@ -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); } } diff --git a/dspace-discovery/dspace-discovery-provider/src/main/java/org/dspace/discovery/SearchUtils.java b/dspace-discovery/dspace-discovery-provider/src/main/java/org/dspace/discovery/SearchUtils.java index dbf9191ada..37b15657de 100644 --- a/dspace-discovery/dspace-discovery-provider/src/main/java/org/dspace/discovery/SearchUtils.java +++ b/dspace-discovery/dspace-discovery-provider/src/main/java/org/dspace/discovery/SearchUtils.java @@ -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); } } diff --git a/dspace-jspui/dspace-jspui-api/src/main/java/org/dspace/app/webui/servlet/StatisticsServlet.java b/dspace-jspui/dspace-jspui-api/src/main/java/org/dspace/app/webui/servlet/StatisticsServlet.java index c9d6348557..8c14ad963d 100644 --- a/dspace-jspui/dspace-jspui-api/src/main/java/org/dspace/app/webui/servlet/StatisticsServlet.java +++ b/dspace-jspui/dspace-jspui-api/src/main/java/org/dspace/app/webui/servlet/StatisticsServlet.java @@ -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 diff --git a/dspace-sword/dspace-sword-api/src/main/java/org/purl/sword/client/GuiClient.java b/dspace-sword/dspace-sword-api/src/main/java/org/purl/sword/client/GuiClient.java index 6dd19e683d..31e00aad15 100644 --- a/dspace-sword/dspace-sword-api/src/main/java/org/purl/sword/client/GuiClient.java +++ b/dspace-sword/dspace-sword-api/src/main/java/org/purl/sword/client/GuiClient.java @@ -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); } } diff --git a/dspace-xmlui/dspace-xmlui-api/src/main/java/org/dspace/app/xmlui/aspect/eperson/AuthenticationCountSelector.java b/dspace-xmlui/dspace-xmlui-api/src/main/java/org/dspace/app/xmlui/aspect/eperson/AuthenticationCountSelector.java index 668e66b922..23281851ee 100644 --- a/dspace-xmlui/dspace-xmlui-api/src/main/java/org/dspace/app/xmlui/aspect/eperson/AuthenticationCountSelector.java +++ b/dspace-xmlui/dspace-xmlui-api/src/main/java/org/dspace/app/xmlui/aspect/eperson/AuthenticationCountSelector.java @@ -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); } }