You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@manifoldcf.apache.org by kw...@apache.org on 2010/08/23 14:18:14 UTC

svn commit: r988101 [2/2] - in /incubator/lcf/trunk/modules/framework: agents/org/apache/lcf/agents/ core/org/apache/lcf/core/ pull-agent/org/apache/lcf/authorities/ pull-agent/org/apache/lcf/crawler/

Modified: incubator/lcf/trunk/modules/framework/pull-agent/org/apache/lcf/crawler/UnRegister.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/modules/framework/pull-agent/org/apache/lcf/crawler/UnRegister.java?rev=988101&r1=988100&r2=988101&view=diff
==============================================================================
--- incubator/lcf/trunk/modules/framework/pull-agent/org/apache/lcf/crawler/UnRegister.java (original)
+++ incubator/lcf/trunk/modules/framework/pull-agent/org/apache/lcf/crawler/UnRegister.java Mon Aug 23 12:18:13 2010
@@ -18,19 +18,37 @@
 */
 package org.apache.lcf.crawler;
 
-import java.io.*;
 import org.apache.lcf.core.interfaces.*;
 import org.apache.lcf.crawler.interfaces.*;
 import org.apache.lcf.crawler.system.*;
 
-public class UnRegister
+/**
+ * Un-register a repository connector class
+ */
+public class UnRegister extends TransactionalCrawlerInitializationCommand
 {
   public static final String _rcsid = "@(#)$Id$";
 
-  private UnRegister()
+  private final String className;
+
+  public UnRegister(String className)
   {
+    this.className = className;
   }
 
+  protected void doExecute(IThreadContext tc) throws LCFException
+  {
+    IConnectorManager mgr = ConnectorManagerFactory.make(tc);
+    IJobManager jobManager = JobManagerFactory.make(tc);
+    IRepositoryConnectionManager connManager = RepositoryConnectionManagerFactory.make(tc);
+    // Find the connection names that come with this class
+    String[] connectionNames = connManager.findConnectionsForConnector(className);
+    // 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(className);
+    Logging.root.info("Successfully unregistered connector '"+className+"'");
+  }
 
   public static void main(String[] args)
   {
@@ -41,43 +59,10 @@ public class UnRegister
     }
 
     String className = args[0];
-
     try
     {
-      LCF.initializeEnvironment();
-      IThreadContext tc = ThreadContextFactory.make();
-      IDBInterface database = DBInterfaceFactory.make(tc,
-        LCF.getMasterDatabaseName(),
-        LCF.getMasterDatabaseUsername(),
-        LCF.getMasterDatabasePassword());
-      IConnectorManager mgr = ConnectorManagerFactory.make(tc);
-      IJobManager jobManager = JobManagerFactory.make(tc);
-      IRepositoryConnectionManager connManager = RepositoryConnectionManagerFactory.make(tc);
-      // Deregistration should be done in a transaction
-      database.beginTransaction();
-      try
-      {
-        // Find the connection names that come with this class
-        String[] connectionNames = connManager.findConnectionsForConnector(className);
-        // 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(className);
-      }
-      catch (LCFException e)
-      {
-        database.signalRollback();
-        throw e;
-      }
-      catch (Error e)
-      {
-        database.signalRollback();
-        throw e;
-      }
-      finally
-      {
-        database.endTransaction();
-      }
+      UnRegister unRegister = new UnRegister(className);
+      unRegister.execute();
       System.err.println("Successfully unregistered connector '"+className+"'");
     }
     catch (LCFException e)
@@ -86,8 +71,4 @@ public class UnRegister
       System.exit(1);
     }
   }
-
-
-
-
 }

Modified: incubator/lcf/trunk/modules/framework/pull-agent/org/apache/lcf/crawler/UnRegisterAll.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/modules/framework/pull-agent/org/apache/lcf/crawler/UnRegisterAll.java?rev=988101&r1=988100&r2=988101&view=diff
==============================================================================
--- incubator/lcf/trunk/modules/framework/pull-agent/org/apache/lcf/crawler/UnRegisterAll.java (original)
+++ incubator/lcf/trunk/modules/framework/pull-agent/org/apache/lcf/crawler/UnRegisterAll.java Mon Aug 23 12:18:13 2010
@@ -18,19 +18,65 @@
 */
 package org.apache.lcf.crawler;
 
-import java.io.*;
 import org.apache.lcf.core.interfaces.*;
 import org.apache.lcf.crawler.interfaces.*;
 import org.apache.lcf.crawler.system.*;
 
-public class UnRegisterAll
+/**
+ * Un-register all repository connector classes
+ */
+public class UnRegisterAll extends BaseCrawlerInitializationCommand
 {
   public static final String _rcsid = "@(#)$Id$";
 
-  private UnRegisterAll()
+  public UnRegisterAll()
   {
   }
 
+  protected void doExecute(IThreadContext tc) throws LCFException
+  {
+    IDBInterface database = DBInterfaceFactory.make(tc,
+      LCF.getMasterDatabaseName(),
+      LCF.getMasterDatabaseUsername(),
+      LCF.getMasterDatabasePassword());
+    IConnectorManager mgr = ConnectorManagerFactory.make(tc);
+    IJobManager jobManager = JobManagerFactory.make(tc);
+    IRepositoryConnectionManager connManager = RepositoryConnectionManagerFactory.make(tc);
+    IResultSet classNames = mgr.getConnectors();
+    int i = 0;
+    while (i < classNames.getRowCount())
+    {
+      IResultRow row = classNames.getRow(i++);
+      String className = (String)row.getValue("classname");
+      // Deregistration should be done in a transaction
+      database.beginTransaction();
+      try
+      {
+        // Find the connection names that come with this class
+        String[] connectionNames = connManager.findConnectionsForConnector(className);
+        // 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(className);
+      }
+      catch (LCFException e)
+      {
+        database.signalRollback();
+        throw e;
+      }
+      catch (Error e)
+      {
+        database.signalRollback();
+        throw e;
+      }
+      finally
+      {
+        database.endTransaction();
+      }
+    }
+    Logging.root.info("Successfully unregistered all connectors");
+  }
+
 
   public static void main(String[] args)
   {
@@ -42,47 +88,8 @@ public class UnRegisterAll
 
     try
     {
-      LCF.initializeEnvironment();
-      IThreadContext tc = ThreadContextFactory.make();
-      IDBInterface database = DBInterfaceFactory.make(tc,
-        LCF.getMasterDatabaseName(),
-        LCF.getMasterDatabaseUsername(),
-        LCF.getMasterDatabasePassword());
-      IConnectorManager mgr = ConnectorManagerFactory.make(tc);
-      IJobManager jobManager = JobManagerFactory.make(tc);
-      IRepositoryConnectionManager connManager = RepositoryConnectionManagerFactory.make(tc);
-      IResultSet classNames = mgr.getConnectors();
-      int i = 0;
-      while (i < classNames.getRowCount())
-      {
-        IResultRow row = classNames.getRow(i++);
-        String className = (String)row.getValue("classname");
-        // Deregistration should be done in a transaction
-        database.beginTransaction();
-        try
-        {
-          // Find the connection names that come with this class
-          String[] connectionNames = connManager.findConnectionsForConnector(className);
-          // 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(className);
-        }
-        catch (LCFException e)
-        {
-          database.signalRollback();
-          throw e;
-        }
-        catch (Error e)
-        {
-          database.signalRollback();
-          throw e;
-        }
-        finally
-        {
-          database.endTransaction();
-        }
-      }
+      UnRegisterAll unRegisterAll = new UnRegisterAll();
+      unRegisterAll.execute();
       System.err.println("Successfully unregistered all connectors");
     }
     catch (LCFException e)
@@ -91,8 +98,4 @@ public class UnRegisterAll
       System.exit(1);
     }
   }
-
-
-
-
 }