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/07/16 18:57:25 UTC

svn commit: r964859 - /incubator/lcf/trunk/modules/framework/pull-agent/org/apache/lcf/crawler/system/LCF.java

Author: kwright
Date: Fri Jul 16 16:57:25 2010
New Revision: 964859

URL: http://svn.apache.org/viewvc?rev=964859&view=rev
Log:
Add connector listing API methods, without which it will be hard to write any kind of basic external UI.

Modified:
    incubator/lcf/trunk/modules/framework/pull-agent/org/apache/lcf/crawler/system/LCF.java

Modified: incubator/lcf/trunk/modules/framework/pull-agent/org/apache/lcf/crawler/system/LCF.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/modules/framework/pull-agent/org/apache/lcf/crawler/system/LCF.java?rev=964859&r1=964858&r2=964859&view=diff
==============================================================================
--- incubator/lcf/trunk/modules/framework/pull-agent/org/apache/lcf/crawler/system/LCF.java (original)
+++ incubator/lcf/trunk/modules/framework/pull-agent/org/apache/lcf/crawler/system/LCF.java Fri Jul 16 16:57:25 2010
@@ -989,6 +989,9 @@ public class LCF extends org.apache.lcf.
   protected static final String API_ERRORNODE = "error";
   protected static final String API_JOBNODE = "job";
   protected static final String API_JOBSTATUSNODE = "jobstatus";
+  protected static final String API_REPOSITORYCONNECTORNODE = "repositoryconnector";
+  protected static final String API_OUTPUTCONNECTORNODE = "outputconnector";
+  protected static final String API_AUTHORITYCONNECTORNODE = "authorityconnector";
   protected static final String API_REPOSITORYCONNECTIONNODE = "repositoryconnection";
   protected static final String API_OUTPUTCONNECTIONNODE = "outputconnection";
   protected static final String API_AUTHORITYCONNECTIONNODE = "authorityconnection";
@@ -996,6 +999,10 @@ public class LCF extends org.apache.lcf.
   protected static final String API_JOBIDNODE = "job_id";
   protected static final String API_CONNECTIONNAMENODE = "connection_name";
   
+  // Connector nodes
+  protected static final String CONNECTORNODE_DESCRIPTION = "description";
+  protected static final String CONNECTORNODE_CLASSNAME = "class_name";
+  
   /** Execute specified command.  Note that the command is a string, and that it is permitted to accept at most one argument, which
   * will be a Configuration object, and return the same.
   *@param tc is the thread context.
@@ -1313,6 +1320,120 @@ public class LCF extends org.apache.lcf.
         rval.addChild(rval.getChildCount(),error);
       }
     }
+    else if (command.equals("outputconnector/list"))
+    {
+      // List registered output connectors
+      try
+      {
+        IOutputConnectorManager manager = OutputConnectorManagerFactory.make(tc);
+        IResultSet resultSet = manager.getConnectors();
+        int j = 0;
+        while (j < resultSet.getRowCount())
+        {
+          IResultRow row = resultSet.getRow(j++);
+          ConfigurationNode child = new ConfigurationNode(API_OUTPUTCONNECTORNODE);
+          String description = (String)row.getValue("description");
+          String className = (String)row.getValue("classname");
+          ConfigurationNode node;
+          if (description != null)
+          {
+            node = new ConfigurationNode(CONNECTORNODE_DESCRIPTION);
+            node.setValue(description);
+            child.addChild(child.getChildCount(),node);
+          }
+          node = new ConfigurationNode(CONNECTORNODE_CLASSNAME);
+          node.setValue(className);
+          child.addChild(child.getChildCount(),node);
+
+          rval.addChild(rval.getChildCount(),child);
+        }
+      }
+      catch (LCFException e)
+      {
+        if (e.getErrorCode() == LCFException.INTERRUPTED)
+          throw e;
+        Logging.api.error(e.getMessage(),e);
+        ConfigurationNode error = new ConfigurationNode(API_ERRORNODE);
+        error.setValue(e.getMessage());
+        rval.addChild(rval.getChildCount(),error);
+      }
+    }
+    else if (command.equals("authorityconnector/list"))
+    {
+      // List registered authority connectors
+      try
+      {
+        IAuthorityConnectorManager manager = AuthorityConnectorManagerFactory.make(tc);
+        IResultSet resultSet = manager.getConnectors();
+        int j = 0;
+        while (j < resultSet.getRowCount())
+        {
+          IResultRow row = resultSet.getRow(j++);
+          ConfigurationNode child = new ConfigurationNode(API_AUTHORITYCONNECTORNODE);
+          String description = (String)row.getValue("description");
+          String className = (String)row.getValue("classname");
+          ConfigurationNode node;
+          if (description != null)
+          {
+            node = new ConfigurationNode(CONNECTORNODE_DESCRIPTION);
+            node.setValue(description);
+            child.addChild(child.getChildCount(),node);
+          }
+          node = new ConfigurationNode(CONNECTORNODE_CLASSNAME);
+          node.setValue(className);
+          child.addChild(child.getChildCount(),node);
+
+          rval.addChild(rval.getChildCount(),child);
+        }
+      }
+      catch (LCFException e)
+      {
+        if (e.getErrorCode() == LCFException.INTERRUPTED)
+          throw e;
+        Logging.api.error(e.getMessage(),e);
+        ConfigurationNode error = new ConfigurationNode(API_ERRORNODE);
+        error.setValue(e.getMessage());
+        rval.addChild(rval.getChildCount(),error);
+      }
+    }
+    else if (command.equals("repositoryconnector/list"))
+    {
+      // List registered repository connectors
+      try
+      {
+        IConnectorManager manager = ConnectorManagerFactory.make(tc);
+        IResultSet resultSet = manager.getConnectors();
+        int j = 0;
+        while (j < resultSet.getRowCount())
+        {
+          IResultRow row = resultSet.getRow(j++);
+          ConfigurationNode child = new ConfigurationNode(API_REPOSITORYCONNECTORNODE);
+          String description = (String)row.getValue("description");
+          String className = (String)row.getValue("classname");
+          ConfigurationNode node;
+          if (description != null)
+          {
+            node = new ConfigurationNode(CONNECTORNODE_DESCRIPTION);
+            node.setValue(description);
+            child.addChild(child.getChildCount(),node);
+          }
+          node = new ConfigurationNode(CONNECTORNODE_CLASSNAME);
+          node.setValue(className);
+          child.addChild(child.getChildCount(),node);
+
+          rval.addChild(rval.getChildCount(),child);
+        }
+      }
+      catch (LCFException e)
+      {
+        if (e.getErrorCode() == LCFException.INTERRUPTED)
+          throw e;
+        Logging.api.error(e.getMessage(),e);
+        ConfigurationNode error = new ConfigurationNode(API_ERRORNODE);
+        error.setValue(e.getMessage());
+        rval.addChild(rval.getChildCount(),error);
+      }
+    }
     else if (command.equals("outputconnection/list"))
     {
       try