protected void localCleanUp() throws Exception {
    IThreadContext tc = ThreadContextFactory.make();

    Exception currentException = null;
    // First, tear down all jobs, connections, authority connections, and output connections.
    try {
      IRepositoryConnectionManager connMgr = RepositoryConnectionManagerFactory.make(tc);
      IAuthorityConnectionManager authConnMgr = AuthorityConnectionManagerFactory.make(tc);
      IOutputConnectionManager outputMgr = OutputConnectionManagerFactory.make(tc);

      // Now, get a list of the repository connections
      IRepositoryConnection[] connections = connMgr.getAllConnections();
      int i = 0;
      while (i < connections.length) {
        connMgr.delete(connections[i++].getName());
      }

      // Get a list of authority connections
      IAuthorityConnection[] authorities = authConnMgr.getAllConnections();
      i = 0;
      while (i < authorities.length) {
        authConnMgr.delete(authorities[i++].getName());
      }

      // Finally, get rid of output connections
      IOutputConnection[] outputs = outputMgr.getAllConnections();
      i = 0;
      while (i < outputs.length) {
        outputMgr.delete(outputs[i++].getName());
      }

    } catch (Exception e) {
      currentException = e;
    }
    try {
      IDBInterface database =
          DBInterfaceFactory.make(
              tc,
              ManifoldCF.getMasterDatabaseName(),
              ManifoldCF.getMasterDatabaseUsername(),
              ManifoldCF.getMasterDatabasePassword());

      IConnectorManager mgr = ConnectorManagerFactory.make(tc);
      IAuthorityConnectorManager authMgr = AuthorityConnectorManagerFactory.make(tc);
      IOutputConnectorManager outputMgr = OutputConnectorManagerFactory.make(tc);
      IOutputConnectionManager outputConnManager = OutputConnectionManagerFactory.make(tc);
      IJobManager jobManager = JobManagerFactory.make(tc);
      IRepositoryConnectionManager connManager = RepositoryConnectionManagerFactory.make(tc);

      // Deregistration should be done in a transaction
      database.beginTransaction();
      try {
        int i;

        String[] connectorClasses = getConnectorClasses();

        i = 0;
        while (i < connectorClasses.length) {
          // Find the connection names that come with this class
          String[] connectionNames = connManager.findConnectionsForConnector(connectorClasses[i]);
          // For each connection name, modify the jobs to note that the connector is no longer
          // installed
          jobManager.noteConnectorDeregistration(connectionNames);
          // Now that all jobs have been placed into an appropriate state, actually do the
          // deregistration itself.
          mgr.unregisterConnector(connectorClasses[i]);
          i++;
        }

        String[] authorityClasses = getAuthorityClasses();

        i = 0;
        while (i < authorityClasses.length) {
          authMgr.unregisterConnector(authorityClasses[i]);
          i++;
        }

        String[] outputClasses = getOutputClasses();

        i = 0;
        while (i < outputClasses.length) {
          // Find the connection names that come with this class
          String[] connectionNames =
              outputConnManager.findConnectionsForConnector(outputClasses[i]);
          // For all connection names, notify all agents of the deregistration
          AgentManagerFactory.noteOutputConnectorDeregistration(tc, connectionNames);
          // Now that all jobs have been placed into an appropriate state, actually do the
          // deregistration itself.
          outputMgr.unregisterConnector(outputClasses[i]);
          i++;
        }

      } catch (ManifoldCFException e) {
        database.signalRollback();
        throw e;
      } catch (Error e) {
        database.signalRollback();
        throw e;
      } finally {
        database.endTransaction();
      }
    } catch (Exception e) {
      if (currentException != null) currentException = e;
    }
    try {
      super.localCleanUp();
    } catch (Exception e) {
      if (currentException != null) currentException = e;
    }
    if (currentException != null) throw currentException;
  }