manifoldcf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwri...@apache.org
Subject svn commit: r1535754 - /manifoldcf/branches/CONNECTORS-792/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/ManifoldCF.java
Date Fri, 25 Oct 2013 14:53:26 GMT
Author: kwright
Date: Fri Oct 25 14:53:26 2013
New Revision: 1535754

URL: http://svn.apache.org/r1535754
Log:
Add ability to register domains via connectors.xml

Modified:
    manifoldcf/branches/CONNECTORS-792/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/ManifoldCF.java

Modified: manifoldcf/branches/CONNECTORS-792/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/ManifoldCF.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-792/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/ManifoldCF.java?rev=1535754&r1=1535753&r2=1535754&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-792/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/ManifoldCF.java
(original)
+++ manifoldcf/branches/CONNECTORS-792/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/ManifoldCF.java
Fri Oct 25 14:53:26 2013
@@ -230,12 +230,14 @@ public class ManifoldCF extends org.apac
   }
 
   // Connectors configuration file
+  protected static final String NODE_AUTHORIZATIONDOMAIN = "authorizationdomain";
   protected static final String NODE_OUTPUTCONNECTOR = "outputconnector";
   protected static final String NODE_MAPPINGCONNECTOR = "mappingconnector";
   protected static final String NODE_AUTHORITYCONNECTOR = "authorityconnector";
   protected static final String NODE_REPOSITORYCONNECTOR = "repositoryconnector";
   protected static final String ATTRIBUTE_NAME = "name";
   protected static final String ATTRIBUTE_CLASS = "class";
+  protected static final String ATTRIBUTE_DOMAIN = "domain";
   
   /** Unregister all connectors which don't match a specified connector list.
   */
@@ -249,12 +251,20 @@ public class ManifoldCF extends org.apac
     Map<String,String> desiredAuthorityConnectors = new HashMap<String,String>();
     Map<String,String> desiredRepositoryConnectors = new HashMap<String,String>();
 
+    Map<String,String> desiredDomains = new HashMap<String,String>();
+
     if (c != null)
     {
       for (int i = 0; i < c.getChildCount(); i++)
       {
         ConfigurationNode cn = c.findChild(i);
-        if (cn.getType().equals(NODE_OUTPUTCONNECTOR))
+        if (cn.getType().equals(NODE_AUTHORIZATIONDOMAIN))
+        {
+          String domainName = cn.getAttributeValue(ATTRIBUTE_DOMAIN);
+          String name = cn.getAttributeValue(ATTRIBUTE_NAME);
+          desiredDomains.put(domainName,name);
+        }
+        else if (cn.getType().equals(NODE_OUTPUTCONNECTOR))
         {
           String name = cn.getAttributeValue(ATTRIBUTE_NAME);
           String className = cn.getAttributeValue(ATTRIBUTE_CLASS);
@@ -287,6 +297,23 @@ public class ManifoldCF extends org.apac
       ManifoldCF.getMasterDatabaseUsername(),
       ManifoldCF.getMasterDatabasePassword());
 
+    // Domains...
+    {
+      IAuthorizationDomainManager mgr = AuthorizationDomainManagerFactory.make(tc);
+      IResultSet domains = mgr.getDomains();
+      for (int i = 0; i < domains.getRowCount(); i++)
+      {
+        IResultRow row = domains.getRow(i);
+        String domainName = (String)row.getValue("domainname");
+        String description = (String)row.getValue("description");
+        if (desiredDomains.get(domainName) == null || !desiredDomains.get(domainName).equals(description))
+        {
+          mgr.unregisterDomain(domainName);
+        }
+      }
+      System.err.println("Successfully unregistered all domains");
+    }
+    
     // Output connectors...
     {
       IOutputConnectorManager mgr = OutputConnectorManagerFactory.make(tc);
@@ -430,7 +457,14 @@ public class ManifoldCF extends org.apac
       while (i < c.getChildCount())
       {
         ConfigurationNode cn = c.findChild(i++);
-        if (cn.getType().equals(NODE_OUTPUTCONNECTOR))
+        if (cn.getType().equals(NODE_AUTHORIZATIONDOMAIN))
+        {
+          String domainName = cn.getAttributeValue(ATTRIBUTE_DOMAIN);
+          String name = cn.getAttributeValue(ATTRIBUTE_NAME);
+          IAuthorizationDomainManager mgr = AuthorizationDomainManagerFactory.make(tc);
+          mgr.registerDomain(name,domainName);
+        }
+        else if (cn.getType().equals(NODE_OUTPUTCONNECTOR))
         {
           String name = cn.getAttributeValue(ATTRIBUTE_NAME);
           String className = cn.getAttributeValue(ATTRIBUTE_CLASS);



Mime
View raw message