manifoldcf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwri...@apache.org
Subject svn commit: r1535429 - in /manifoldcf/branches/CONNECTORS-792/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities: authority/AuthorityConnection.java authority/AuthorityConnectionManager.java interfaces/IAuthorityConnection.java
Date Thu, 24 Oct 2013 16:26:19 GMT
Author: kwright
Date: Thu Oct 24 16:26:19 2013
New Revision: 1535429

URL: http://svn.apache.org/r1535429
Log:
Schema changes for authority connections.

Modified:
    manifoldcf/branches/CONNECTORS-792/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/authority/AuthorityConnection.java
    manifoldcf/branches/CONNECTORS-792/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/authority/AuthorityConnectionManager.java
    manifoldcf/branches/CONNECTORS-792/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/interfaces/IAuthorityConnection.java

Modified: manifoldcf/branches/CONNECTORS-792/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/authority/AuthorityConnection.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-792/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/authority/AuthorityConnection.java?rev=1535429&r1=1535428&r2=1535429&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-792/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/authority/AuthorityConnection.java
(original)
+++ manifoldcf/branches/CONNECTORS-792/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/authority/AuthorityConnection.java
Thu Oct 24 16:26:19 2013
@@ -38,6 +38,7 @@ public class AuthorityConnection impleme
   protected int maxCount = 100;
   protected String prerequisiteMapping = null;
   protected String authDomain = null;
+  protected String authGroup = null;
 
   /** Constructor.
   */
@@ -59,6 +60,7 @@ public class AuthorityConnection impleme
     rval.configParams = configParams.duplicate();
     rval.prerequisiteMapping = prerequisiteMapping;
     rval.authDomain = authDomain;
+    rval.authGroup = authGroup;
     return rval;
   }
 
@@ -183,4 +185,20 @@ public class AuthorityConnection impleme
     return authDomain;
   }
 
+  /** Set authorization group.
+  *@param groupName is the name of the group.
+  */
+  public void setAuthGroup(String groupName)
+  {
+    authGroup = groupName;
+  }
+  
+  /** Get the authorization group.
+  *@return the group.
+  */
+  public String getAuthGroup()
+  {
+    return authGroup;
+  }
+
 }

Modified: manifoldcf/branches/CONNECTORS-792/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/authority/AuthorityConnectionManager.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-792/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/authority/AuthorityConnectionManager.java?rev=1535429&r1=1535428&r2=1535429&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-792/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/authority/AuthorityConnectionManager.java
(original)
+++ manifoldcf/branches/CONNECTORS-792/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/authority/AuthorityConnectionManager.java
Thu Oct 24 16:26:19 2013
@@ -59,7 +59,8 @@ public class AuthorityConnectionManager 
   protected final static String configField = "configxml";
   protected final static String mappingField = "mappingname";
   protected final static String authDomainField = "authdomainname";
-
+  protected final static String groupNameField = "groupname";
+  
   // Cache manager
   ICacheManager cacheManager;
   // Thread context
@@ -83,6 +84,9 @@ public class AuthorityConnectionManager 
   public void install()
     throws ManifoldCFException
   {
+    // First, get the authority manager table name and name column
+    IAuthorityGroupManager authMgr = AuthorityGroupManagerFactory.make(threadContext);
+
     // Always do a loop, in case upgrade needs it.
     while (true)
     {
@@ -98,6 +102,8 @@ public class AuthorityConnectionManager 
         map.put(configField,new ColumnDescription("LONGTEXT",false,true,null,null,false));
         map.put(mappingField,new ColumnDescription("VARCHAR(32)",false,true,null,null,false));
         map.put(authDomainField,new ColumnDescription("VARCHAR(255)",false,true,null,null,false));
+        map.put(groupNameField,new ColumnDescription("VARCHAR(32)",false,false,
+          authMgr.getTableName(),authMgr.getGroupNameColumn(),false));
         performCreate(map,null);
       }
       else
@@ -118,10 +124,57 @@ public class AuthorityConnectionManager 
           addMap.put(authDomainField,new ColumnDescription("VARCHAR(255)",false,true,null,null,false));
           performAlter(addMap,null,null,null);
         }
+        cd = (ColumnDescription)existing.get(groupNameField);
+        if (cd == null)
+        {
+          Map addMap = new HashMap();
+          addMap.put(groupNameField,new ColumnDescription("VARCHAR(32)",false,true,
+            authMgr.getTableName(),authMgr.getGroupNameColumn(),false));
+          performAlter(addMap,null,null,null);
+          try
+          {
+            ArrayList params = new ArrayList();
+            IResultSet set = performQuery("SELECT "+nameField+","+descriptionField+" FROM
"+getTableName(),null,null,null);
+            for (int i = 0 ; i < set.getRowCount() ; i++)
+            {
+              IResultRow row = set.getRow(i);
+              String authName = (String)row.getValue(nameField);
+              String authDescription = (String)row.getValue(descriptionField);
+              IAuthorityGroup gp = authMgr.load(authName);
+              if (gp == null)
+              {
+                // Create an authority group with this name
+                gp = authMgr.create();
+                gp.setName(authName);
+                if (authDescription != null)
+                  gp.setDescription(authDescription);
+                authMgr.save(gp);
+              }
+              Map<String,String> map = new HashMap<String,String>();
+              map.put(groupNameField,authName);
+              params.clear();
+              String query = buildConjunctionClause(params,new ClauseDescription[]{
+                new UnitaryClause(nameField,authName)});
+              performUpdate(map," WHERE "+query,params,null);
+            }
+            Map modifyMap = new HashMap();
+            modifyMap.put(groupNameField,new ColumnDescription("VARCHAR(32)",false,false,
+              authMgr.getTableName(),authMgr.getGroupNameColumn(),false));
+            performAlter(null,modifyMap,null,null);
+          }
+          finally
+          {
+            // Upgrade failed; back out our changes
+            List<String> deleteList = new ArrayList<String>();
+            deleteList.add(groupNameField);
+            performAlter(null,null,deleteList,null);
+          }
+        }
       }
 
       // Index management goes here
       IndexDescription authDomainIndex = new IndexDescription(false,new String[]{authDomainField});
+      IndexDescription authorityIndex = new IndexDescription(false,new String[]{groupNameField});
 
       // Get rid of indexes that shouldn't be there
       Map indexes = getTableIndexes(null,null);
@@ -133,6 +186,8 @@ public class AuthorityConnectionManager 
 
         if (authDomainIndex != null && id.equals(authDomainIndex))
           authDomainIndex = null;
+        if (authorityIndex != null && id.equals(authorityIndex))
+          authorityIndex = null;
         else if (indexName.indexOf("_pkey") == -1)
           // This index shouldn't be here; drop it
           performRemoveIndex(indexName);
@@ -141,7 +196,8 @@ public class AuthorityConnectionManager 
       // Add the ones we didn't find
       if (authDomainIndex != null)
         performAddIndex(null,authDomainIndex);
-
+      if (authorityIndex != null)
+        performAddIndex(null,authorityIndex);
       break;
     }
   }
@@ -178,6 +234,7 @@ public class AuthorityConnectionManager 
       ManifoldCF.writeDword(os,conn.getMaxConnections());
       ManifoldCF.writeString(os,conn.getPrerequisiteMapping());
       ManifoldCF.writeString(os,conn.getAuthDomain());
+      ManifoldCF.writeString(os,conn.getAuthGroup());
     }
   }
 
@@ -205,6 +262,7 @@ public class AuthorityConnectionManager 
         if (version >= 3)
         {
           conn.setAuthDomain(ManifoldCF.readString(is));
+          conn.setAuthGroup(ManifoldCF.readString(is));
         }
       }
       // Attempt to save this connection
@@ -214,14 +272,21 @@ public class AuthorityConnectionManager 
   }
 
   /** Return true if the specified authority group name is referenced.
-  *@param authorityGroup is the authority group name.
+  *@param groupName is the authority group name.
   *@return true if referenced, false otherwise.
   */
-  public boolean isReferenced(String authorityGroup)
+  public boolean isReferenced(String groupName)
     throws ManifoldCFException
   {
-    // MHL
-    return false;
+    StringSetBuffer ssb = new StringSetBuffer();
+    ssb.add(getAuthorityConnectionsKey());
+    StringSet localCacheKeys = new StringSet(ssb);
+    ArrayList params = new ArrayList();
+    String query = buildConjunctionClause(params,new ClauseDescription[]{
+      new UnitaryClause(groupNameField,groupName)});
+    IResultSet set = performQuery("SELECT "+nameField+" FROM "+getTableName()+" WHERE "+query,params,
+      localCacheKeys,null);
+    return set.getRowCount() > 0;
   }
 
   /** Obtain a list of the authority connections which correspond to an auth domain.
@@ -398,6 +463,7 @@ public class AuthorityConnectionManager 
             values.put(configField,object.getConfigParams().toXML());
             values.put(mappingField,object.getPrerequisiteMapping());
             values.put(authDomainField,object.getAuthDomain());
+            values.put(groupNameField,object.getAuthGroup());
 
             boolean isCreated;
             
@@ -654,6 +720,7 @@ public class AuthorityConnectionManager 
       rc.setMaxConnections((int)((Long)row.getValue(maxCountField)).longValue());
       rc.setPrerequisiteMapping((String)row.getValue(mappingField));
       rc.setAuthDomain((String)row.getValue(authDomainField));
+      rc.setAuthGroup((String)row.getValue(groupNameField));
       String xml = (String)row.getValue(configField);
       if (xml != null && xml.length() > 0)
         rc.getConfigParams().fromXML(xml);

Modified: manifoldcf/branches/CONNECTORS-792/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/interfaces/IAuthorityConnection.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-792/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/interfaces/IAuthorityConnection.java?rev=1535429&r1=1535428&r2=1535429&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-792/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/interfaces/IAuthorityConnection.java
(original)
+++ manifoldcf/branches/CONNECTORS-792/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/interfaces/IAuthorityConnection.java
Thu Oct 24 16:26:19 2013
@@ -101,4 +101,14 @@ public interface IAuthorityConnection
   */
   public String getAuthDomain();
   
+  /** Set authorization group.
+  *@param groupName is the name of the group.
+  */
+  public void setAuthGroup(String groupName);
+  
+  /** Get the authorization group.
+  *@return the group.
+  */
+  public String getAuthGroup();
+  
 }



Mime
View raw message