Author: kwright
Date: Wed Oct 23 22:23:21 2013
New Revision: 1535200

URL: http://svn.apache.org/r1535200
Log:
Add authority group and manager.

Added:
    
manifoldcf/branches/CONNECTORS-792/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/authgroups/
    
manifoldcf/branches/CONNECTORS-792/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/authgroups/AuthorityGroup.java
   (with props)
    
manifoldcf/branches/CONNECTORS-792/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/authgroups/AuthorityGroupManager.java
   (with props)
    
manifoldcf/branches/CONNECTORS-792/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/interfaces/IAuthorityGroup.java
   (with props)
    
manifoldcf/branches/CONNECTORS-792/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/interfaces/IAuthorityGroupManager.java
   (with props)
Modified:
    
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/CacheKeyFactory.java
    
manifoldcf/branches/CONNECTORS-792/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/interfaces/IAuthorityConnectionManager.java
    
manifoldcf/branches/CONNECTORS-792/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/interfaces/IRepositoryConnectionManager.java

Added: 
manifoldcf/branches/CONNECTORS-792/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/authgroups/AuthorityGroup.java
URL: 
http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-792/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/authgroups/AuthorityGroup.java?rev=1535200&view=auto
==============================================================================
--- 
manifoldcf/branches/CONNECTORS-792/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/authgroups/AuthorityGroup.java
 (added)
+++ 
manifoldcf/branches/CONNECTORS-792/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/authgroups/AuthorityGroup.java
 Wed Oct 23 22:23:21 2013
@@ -0,0 +1,103 @@
+/* $Id$ */
+
+/**
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.manifoldcf.authorities.authgroups;
+
+import org.apache.manifoldcf.core.interfaces.*;
+import org.apache.manifoldcf.authorities.interfaces.*;
+import java.util.*;
+
+/** This is the implementation of the authority group interface, which 
describes a paper object
+* to be manipulated in order to create, edit, or save an authority group 
definition.
+*/
+public class AuthorityGroup implements IAuthorityGroup
+{
+  public static final String _rcsid = "@(#)$Id$";
+
+  // data
+  protected boolean isNew = true;
+  protected String name = null;
+  protected String description = null;
+
+  /** Constructor.
+  */
+  public AuthorityGroup()
+  {
+  }
+
+  /** Clone this object.
+  *@return the cloned object.
+  */
+  public AuthorityGroup duplicate()
+  {
+    AuthorityGroup rval = new AuthorityGroup();
+    rval.isNew = isNew;
+    rval.name = name;
+    rval.description = description;
+    return rval;
+  }
+
+  /** Set 'isnew' condition.
+  *@param isnew true if this is a new instance.
+  */
+  public void setIsNew(boolean isnew)
+  {
+    this.isNew = isnew;
+  }
+  
+  /** Get 'isnew' condition.
+  *@return true if this is a new connection, false otherwise.
+  */
+  public boolean getIsNew()
+  {
+    return isNew;
+  }
+
+  /** Set name.
+  *@param name is the name.
+  */
+  public void setName(String name)
+  {
+    this.name = name;
+  }
+
+  /** Get name.
+  *@return the name
+  */
+  public String getName()
+  {
+    return name;
+  }
+
+  /** Set description.
+  *@param description is the description.
+  */
+  public void setDescription(String description)
+  {
+    this.description = description;
+  }
+
+  /** Get description.
+  *@return the description
+  */
+  public String getDescription()
+  {
+    return description;
+  }
+
+}

Propchange: 
manifoldcf/branches/CONNECTORS-792/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/authgroups/AuthorityGroup.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
manifoldcf/branches/CONNECTORS-792/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/authgroups/AuthorityGroup.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: 
manifoldcf/branches/CONNECTORS-792/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/authgroups/AuthorityGroupManager.java
URL: 
http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-792/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/authgroups/AuthorityGroupManager.java?rev=1535200&view=auto
==============================================================================
--- 
manifoldcf/branches/CONNECTORS-792/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/authgroups/AuthorityGroupManager.java
 (added)
+++ 
manifoldcf/branches/CONNECTORS-792/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/authgroups/AuthorityGroupManager.java
 Wed Oct 23 22:23:21 2013
@@ -0,0 +1,657 @@
+/* $Id$ */
+
+/**
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.manifoldcf.authorities.authgroups;
+
+import org.apache.manifoldcf.core.interfaces.*;
+import org.apache.manifoldcf.authorities.interfaces.*;
+import java.util.*;
+import org.apache.manifoldcf.authorities.interfaces.CacheKeyFactory;
+import org.apache.manifoldcf.authorities.system.ManifoldCF;
+
+import org.apache.manifoldcf.crawler.interfaces.IRepositoryConnectionManager;
+import 
org.apache.manifoldcf.crawler.interfaces.RepositoryConnectionManagerFactory;
+
+/** Implementation of the authority group manager functionality.
+ * 
+ * <br><br>
+ * <b>authgroups</b>
+ * <table border="1" cellpadding="3" cellspacing="0">
+ * <tr class="TableHeadingColor">
+ * 
<th>Field</th><th>Type</th><th>Description&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th>
+ * <tr><td>groupname</td><td>VARCHAR(32)</td><td>Primary Key</td></tr>
+ * <tr><td>description</td><td>VARCHAR(255)</td><td></td></tr>
+ * </table>
+ * <br><br>
+ * 
+ */
+public class AuthorityGroupManager extends 
org.apache.manifoldcf.core.database.BaseTable implements IAuthorityGroupManager
+{
+  public static final String _rcsid = "@(#)$Id$";
+
+  protected final static String nameField = "groupname";
+  protected final static String descriptionField = "description";
+
+  // Cache manager
+  ICacheManager cacheManager;
+  // Thread context
+  IThreadContext threadContext;
+
+  /** Constructor.
+  *@param threadContext is the thread context.
+  */
+  public AuthorityGroupManager(IThreadContext threadContext, IDBInterface 
database)
+    throws ManifoldCFException
+  {
+    super(database,"authgroups");
+
+    cacheManager = CacheManagerFactory.make(threadContext);
+    this.threadContext = threadContext;
+  }
+
+  /** Install the manager.
+  */
+  @Override
+  public void install()
+    throws ManifoldCFException
+  {
+    // Always do a loop, in case upgrade needs it.
+    while (true)
+    {
+      Map existing = getTableSchema(null,null);
+      if (existing == null)
+      {
+        // Install the "objects" table.
+        HashMap map = new HashMap();
+        map.put(nameField,new 
ColumnDescription("VARCHAR(32)",true,false,null,null,false));
+        map.put(descriptionField,new 
ColumnDescription("VARCHAR(255)",false,true,null,null,false));
+        performCreate(map,null);
+      }
+      else
+      {
+        // Upgrade, when needed
+      }
+
+      // Index management goes here
+
+      break;
+    }
+  }
+
+  /** Uninstall the manager.
+  */
+  @Override
+  public void deinstall()
+    throws ManifoldCFException
+  {
+    performDrop(null);
+  }
+
+  /** Export configuration */
+  @Override
+  public void exportConfiguration(java.io.OutputStream os)
+    throws java.io.IOException, ManifoldCFException
+  {
+    // Write a version indicator
+    ManifoldCF.writeDword(os,1);
+    // Get the authority list
+    IAuthorityGroup[] list = getAllGroups();
+    // Write the number of groups
+    ManifoldCF.writeDword(os,list.length);
+    // Loop through the list and write the individual group info
+    int i = 0;
+    while (i < list.length)
+    {
+      IAuthorityGroup conn = list[i++];
+      ManifoldCF.writeString(os,conn.getName());
+      ManifoldCF.writeString(os,conn.getDescription());
+    }
+  }
+
+  /** Import configuration */
+  @Override
+  public void importConfiguration(java.io.InputStream is)
+    throws java.io.IOException, ManifoldCFException
+  {
+    int version = ManifoldCF.readDword(is);
+    if (version < 1 || version > 1)
+      throw new java.io.IOException("Unknown authority group configuration 
version: "+Integer.toString(version));
+    int count = ManifoldCF.readDword(is);
+    int i = 0;
+    while (i < count)
+    {
+      IAuthorityGroup conn = create();
+      conn.setName(ManifoldCF.readString(is));
+      conn.setDescription(ManifoldCF.readString(is));
+      // Attempt to save this connection
+      save(conn);
+      i++;
+    }
+  }
+
+  /** Obtain a list of the authority grouops, ordered by name.
+  *@return an array of connection objects.
+  */
+  @Override
+  public IAuthorityGroup[] getAllGroups()
+    throws ManifoldCFException
+  {
+    beginTransaction();
+    try
+    {
+      // Read all the tools
+      StringSetBuffer ssb = new StringSetBuffer();
+      ssb.add(getAuthorityGroupsKey());
+      StringSet localCacheKeys = new StringSet(ssb);
+      IResultSet set = performQuery("SELECT "+nameField+",lower("+nameField+") 
AS sortfield FROM "+getTableName()+" ORDER BY sortfield ASC",null,
+        localCacheKeys,null);
+      String[] names = new String[set.getRowCount()];
+      int i = 0;
+      while (i < names.length)
+      {
+        IResultRow row = set.getRow(i);
+        names[i] = row.getValue(nameField).toString();
+        i++;
+      }
+      return loadMultiple(names);
+    }
+    catch (ManifoldCFException e)
+    {
+      signalRollback();
+      throw e;
+    }
+    catch (Error e)
+    {
+      signalRollback();
+      throw e;
+    }
+    finally
+    {
+      endTransaction();
+    }
+  }
+
+  /** Load an authority group by name.
+  *@param name is the name of the authority group.
+  *@return the loaded group object, or null if not found.
+  */
+  @Override
+  public IAuthorityGroup load(String name)
+    throws ManifoldCFException
+  {
+    return loadMultiple(new String[]{name})[0];
+  }
+
+  /** Load multiple authority groups by name.
+  *@param names are the names to load.
+  *@return the loaded group objects.
+  */
+  @Override
+  public IAuthorityGroup[] loadMultiple(String[] names)
+    throws ManifoldCFException
+  {
+    // Build description objects
+    AuthorityGroupDescription[] objectDescriptions = new 
AuthorityGroupDescription[names.length];
+    int i = 0;
+    StringSetBuffer ssb = new StringSetBuffer();
+    while (i < names.length)
+    {
+      ssb.clear();
+      ssb.add(getAuthorityGroupKey(names[i]));
+      objectDescriptions[i] = new AuthorityGroupDescription(names[i],new 
StringSet(ssb));
+      i++;
+    }
+
+    AuthorityGroupExecutor exec = new 
AuthorityGroupExecutor(this,objectDescriptions);
+    
cacheManager.findObjectsAndExecute(objectDescriptions,null,exec,getTransactionID());
+    return exec.getResults();
+  }
+
+  /** Create a new authority group object.
+  *@return the new object.
+  */
+  @Override
+  public IAuthorityGroup create()
+    throws ManifoldCFException
+  {
+    AuthorityGroup rval = new AuthorityGroup();
+    return rval;
+  }
+
+  /** Save an authority group object.
+  *@param object is the object to save.
+  *@return true if the object is created, false otherwise.
+  */
+  @Override
+  public boolean save(IAuthorityGroup object)
+    throws ManifoldCFException
+  {
+    StringSetBuffer ssb = new StringSetBuffer();
+    ssb.add(getAuthorityGroupsKey());
+    ssb.add(getAuthorityGroupKey(object.getName()));
+    StringSet cacheKeys = new StringSet(ssb);
+    while (true)
+    {
+      long sleepAmt = 0L;
+      try
+      {
+        ICacheHandle ch = 
cacheManager.enterCache(null,cacheKeys,getTransactionID());
+        try
+        {
+          beginTransaction();
+          try
+          {
+            //performLock();
+            ManifoldCF.noteConfigurationChange();
+            boolean isNew = object.getIsNew();
+            // See whether the instance exists
+            ArrayList params = new ArrayList();
+            String query = buildConjunctionClause(params,new 
ClauseDescription[]{
+              new UnitaryClause(nameField,object.getName())});
+            IResultSet set = performQuery("SELECT * FROM "+getTableName()+" 
WHERE "+
+              query+" FOR UPDATE",params,null,null);
+            HashMap values = new HashMap();
+            values.put(descriptionField,object.getDescription());
+
+            boolean isCreated;
+            
+            if (set.getRowCount() > 0)
+            {
+              // If the object is supposedly new, it is bad that we found one 
that already exists.
+              if (isNew)
+                throw new ManifoldCFException("Authority group 
'"+object.getName()+"' already exists");
+              isCreated = false;
+              // Update
+              params.clear();
+              query = buildConjunctionClause(params,new ClauseDescription[]{
+                new UnitaryClause(nameField,object.getName())});
+              performUpdate(values," WHERE "+query,params,null);
+            }
+            else
+            {
+              // If the object is not supposed to be new, it is bad that we 
did not find one.
+              if (!isNew)
+                throw new ManifoldCFException("Authority group 
'"+object.getName()+"' no longer exists");
+              isCreated = true;
+              // Insert
+              values.put(nameField,object.getName());
+              // We only need the general key because this is new.
+              performInsert(values,null);
+            }
+
+            cacheManager.invalidateKeys(ch);
+            return isCreated;
+          }
+          catch (ManifoldCFException e)
+          {
+            signalRollback();
+            throw e;
+          }
+          catch (Error e)
+          {
+            signalRollback();
+            throw e;
+          }
+          finally
+          {
+            endTransaction();
+          }
+        }
+        finally
+        {
+          cacheManager.leaveCache(ch);
+        }
+      }
+      catch (ManifoldCFException e)
+      {
+        // Is this a deadlock exception?  If so, we want to try again.
+        if (e.getErrorCode() != ManifoldCFException.DATABASE_TRANSACTION_ABORT)
+          throw e;
+        sleepAmt = getSleepAmt();
+      }
+      finally
+      {
+        sleepFor(sleepAmt);
+      }
+    }
+  }
+
+  /** Delete an authority group.
+  *@param name is the name of the group to delete.  If the
+  * name does not exist, no error is returned.
+  */
+  @Override
+  public void delete(String name)
+    throws ManifoldCFException
+  {
+    // Grab repository connection manager handle, to check on legality of 
deletion.
+    IRepositoryConnectionManager repoManager = 
RepositoryConnectionManagerFactory.make(threadContext);
+    IAuthorityConnectionManager authManager = 
AuthorityConnectionManagerFactory.make(threadContext);
+    
+    StringSetBuffer ssb = new StringSetBuffer();
+    ssb.add(getAuthorityGroupsKey());
+    ssb.add(getAuthorityGroupKey(name));
+    StringSet cacheKeys = new StringSet(ssb);
+    ICacheHandle ch = 
cacheManager.enterCache(null,cacheKeys,getTransactionID());
+    try
+    {
+      beginTransaction();
+      try
+      {
+        // Check if anything refers to this group name
+        if (repoManager.isReferenced(name))
+          throw new ManifoldCFException("Can't delete authority group 
'"+name+"': existing repository connections refer to it");
+        if (authManager.isReferenced(name))
+          throw new ManifoldCFException("Can't delete authority group 
'"+name+"': existing authority connections refer to it");
+        ManifoldCF.noteConfigurationChange();
+        ArrayList params = new ArrayList();
+        String query = buildConjunctionClause(params,new ClauseDescription[]{
+          new UnitaryClause(nameField,name)});
+        performDelete("WHERE "+query,params,null);
+        cacheManager.invalidateKeys(ch);
+      }
+      catch (ManifoldCFException e)
+      {
+        signalRollback();
+        throw e;
+      }
+      catch (Error e)
+      {
+        signalRollback();
+        throw e;
+      }
+      finally
+      {
+        endTransaction();
+      }
+    }
+    finally
+    {
+      cacheManager.leaveCache(ch);
+    }
+
+  }
+
+  /** Get the authority group name column.
+  *@return the name column.
+  */
+  @Override
+  public String getGroupNameColumn()
+  {
+    return nameField;
+  }
+
+  // Caching strategy: Individual connection descriptions are cached, and 
there is a global cache key for the list of
+  // repository connections.
+
+  /** Construct a key which represents the general list of repository 
connectors.
+  *@return the cache key.
+  */
+  protected static String getAuthorityGroupsKey()
+  {
+    return CacheKeyFactory.makeAuthorityGroupsKey();
+  }
+
+  /** Construct a key which represents an individual authority group.
+  *@param groupName is the name of the group.
+  *@return the cache key.
+  */
+  protected static String getAuthorityGroupKey(String groupName)
+  {
+    return CacheKeyFactory.makeAuthorityGroupKey(groupName);
+  }
+
+  // Other utility methods.
+
+  /** Fetch multiple authority groups at a single time.
+  *@param groupNames are a list of group names.
+  *@return the corresponding authority group objects.
+  */
+  protected AuthorityGroup[] getAuthorityGroupsMultiple(String[] groupNames)
+    throws ManifoldCFException
+  {
+    AuthorityGroup[] rval = new AuthorityGroup[groupNames.length];
+    HashMap returnIndex = new HashMap();
+    int i = 0;
+    while (i < groupNames.length)
+    {
+      rval[i] = null;
+      returnIndex.put(groupNames[i],new Integer(i));
+      i++;
+    }
+    beginTransaction();
+    try
+    {
+      i = 0;
+      ArrayList params = new ArrayList();
+      int j = 0;
+      int maxIn = maxClauseGetAuthorityGroupsChunk();
+      while (i < groupNames.length)
+      {
+        if (j == maxIn)
+        {
+          getAuthorityGroupsChunk(rval,returnIndex,params);
+          params.clear();
+          j = 0;
+        }
+        params.add(groupNames[i]);
+        i++;
+        j++;
+      }
+      if (j > 0)
+        getAuthorityGroupsChunk(rval,returnIndex,params);
+      return rval;
+    }
+    catch (Error e)
+    {
+      signalRollback();
+      throw e;
+    }
+    catch (ManifoldCFException e)
+    {
+      signalRollback();
+      throw e;
+    }
+    finally
+    {
+      endTransaction();
+    }
+  }
+
+  /** Find the maximum number of clauses for getAuthorityConnectionsChunk.
+  */
+  protected int maxClauseGetAuthorityGroupsChunk()
+  {
+    return findConjunctionClauseMax(new ClauseDescription[]{});
+  }
+    
+  /** Read a chunk of authority groups.
+  *@param rval is the place to put the read policies.
+  *@param returnIndex is a map from the object id (resource id) and the rval 
index.
+  *@param params is the set of parameters.
+  */
+  protected void getAuthorityGroupsChunk(AuthorityGroup[] rval, Map 
returnIndex, ArrayList params)
+    throws ManifoldCFException
+  {
+    ArrayList list = new ArrayList();
+    String query = buildConjunctionClause(list,new ClauseDescription[]{
+      new MultiClause(nameField,params)});
+    IResultSet set = performQuery("SELECT * FROM "+getTableName()+" WHERE "+
+      query,list,null,null);
+    int i = 0;
+    while (i < set.getRowCount())
+    {
+      IResultRow row = set.getRow(i++);
+      String name = row.getValue(nameField).toString();
+      int index = ((Integer)returnIndex.get(name)).intValue();
+      AuthorityGroup rc = new AuthorityGroup();
+      rc.setIsNew(false);
+      rc.setName(name);
+      rc.setDescription((String)row.getValue(descriptionField));
+      rval[index] = rc;
+    }
+  }
+
+  // The cached instance will be a AuthorityGroup.  The cached version will be 
duplicated when it is returned
+  // from the cache.
+  //
+  // The description object is based completely on the name.
+
+  /** This is the object description for an authority group object.
+  */
+  protected static class AuthorityGroupDescription extends 
org.apache.manifoldcf.core.cachemanager.BaseDescription
+  {
+    protected String groupName;
+    protected String criticalSectionName;
+    protected StringSet cacheKeys;
+
+    public AuthorityGroupDescription(String groupName, StringSet invKeys)
+    {
+      super("authoritygroupcache");
+      this.groupName = groupName;
+      criticalSectionName = getClass().getName()+"-"+groupName;
+      cacheKeys = invKeys;
+    }
+
+    public String getGroupName()
+    {
+      return groupName;
+    }
+
+    public int hashCode()
+    {
+      return groupName.hashCode();
+    }
+
+    public boolean equals(Object o)
+    {
+      if (!(o instanceof AuthorityGroupDescription))
+        return false;
+      AuthorityGroupDescription d = (AuthorityGroupDescription)o;
+      return d.groupName.equals(groupName);
+    }
+
+    public String getCriticalSectionName()
+    {
+      return criticalSectionName;
+    }
+
+    /** Get the cache keys for an object (which may or may not exist yet in
+    * the cache).  This method is called in order for cache manager to throw 
the correct locks.
+    * @return the object's cache keys, or null if the object should not
+    * be cached.
+    */
+    public StringSet getObjectKeys()
+    {
+      return cacheKeys;
+    }
+
+  }
+
+  /** This is the executor object for locating authority group objects.
+  */
+  protected static class AuthorityGroupExecutor extends 
org.apache.manifoldcf.core.cachemanager.ExecutorBase
+  {
+    // Member variables
+    protected AuthorityGroupManager thisManager;
+    protected AuthorityGroup[] returnValues;
+    protected HashMap returnMap = new HashMap();
+
+    /** Constructor.
+    *@param manager is the AuthorityGroupManager.
+    *@param objectDescriptions are the object descriptions.
+    */
+    public AuthorityGroupExecutor(AuthorityGroupManager manager, 
AuthorityGroupDescription[] objectDescriptions)
+    {
+      super();
+      thisManager = manager;
+      returnValues = new AuthorityGroup[objectDescriptions.length];
+      int i = 0;
+      while (i < objectDescriptions.length)
+      {
+        returnMap.put(objectDescriptions[i].getGroupName(),new Integer(i));
+        i++;
+      }
+    }
+
+    /** Get the result.
+    *@return the looked-up or read cached instances.
+    */
+    public AuthorityGroup[] getResults()
+    {
+      return returnValues;
+    }
+
+    /** Create a set of new objects to operate on and cache.  This method is 
called only
+    * if the specified object(s) are NOT available in the cache.  The 
specified objects
+    * should be created and returned; if they are not created, it means that 
the
+    * execution cannot proceed, and the execute() method will not be called.
+    * @param objectDescriptions is the set of unique identifier of the object.
+    * @return the newly created objects to cache, or null, if any object 
cannot be created.
+    *  The order of the returned objects must correspond to the order of the 
object descriptinos.
+    */
+    public Object[] create(ICacheDescription[] objectDescriptions) throws 
ManifoldCFException
+    {
+      // Turn the object descriptions into the parameters for the 
AuthorityGroup requests
+      String[] groupNames = new String[objectDescriptions.length];
+      int i = 0;
+      while (i < groupNames.length)
+      {
+        AuthorityGroupDescription desc = 
(AuthorityGroupDescription)objectDescriptions[i];
+        groupNames[i] = desc.getGroupName();
+        i++;
+      }
+
+      return thisManager.getAuthorityGroupsMultiple(groupNames);
+    }
+
+
+    /** Notify the implementing class of the existence of a cached version of 
the
+    * object.  The object is passed to this method so that the execute() 
method below
+    * will have it available to operate on.  This method is also called for 
all objects
+    * that are freshly created as well.
+    * @param objectDescription is the unique identifier of the object.
+    * @param cachedObject is the cached object.
+    */
+    public void exists(ICacheDescription objectDescription, Object 
cachedObject) throws ManifoldCFException
+    {
+      // Cast what came in as what it really is
+      AuthorityGroupDescription objectDesc = 
(AuthorityGroupDescription)objectDescription;
+      AuthorityGroup ci = (AuthorityGroup)cachedObject;
+
+      // Duplicate it!
+      if (ci != null)
+        ci = ci.duplicate();
+
+      // In order to make the indexes line up, we need to use the hashtable 
built by
+      // the constructor.
+      
returnValues[((Integer)returnMap.get(objectDesc.getGroupName())).intValue()] = 
ci;
+    }
+
+    /** Perform the desired operation.  This method is called after either 
createGetObject()
+    * or exists() is called for every requested object.
+    */
+    public void execute() throws ManifoldCFException
+    {
+      // Does nothing; we only want to fetch objects in this cacher.
+    }
+
+
+  }
+
+}

Propchange: 
manifoldcf/branches/CONNECTORS-792/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/authgroups/AuthorityGroupManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
manifoldcf/branches/CONNECTORS-792/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/authgroups/AuthorityGroupManager.java
------------------------------------------------------------------------------
    svn:keywords = Id

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=1535200&r1=1535199&r2=1535200&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
 Wed Oct 23 22:23:21 2013
@@ -213,6 +213,17 @@ public class AuthorityConnectionManager 
     }
   }
 
+  /** Return true if the specified authority group name is referenced.
+  *@param authorityGroup is the authority group name.
+  *@return true if referenced, false otherwise.
+  */
+  public boolean isReferenced(String authorityGroup)
+    throws ManifoldCFException
+  {
+    // MHL
+    return false;
+  }
+
   /** Obtain a list of the authority connections which correspond to an auth 
domain.
   *@param authDomain is the domain to get connections for.
   *@return an array of connection objects.

Modified: 
manifoldcf/branches/CONNECTORS-792/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/interfaces/CacheKeyFactory.java
URL: 
http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-792/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/interfaces/CacheKeyFactory.java?rev=1535200&r1=1535199&r2=1535200&view=diff
==============================================================================
--- 
manifoldcf/branches/CONNECTORS-792/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/interfaces/CacheKeyFactory.java
 (original)
+++ 
manifoldcf/branches/CONNECTORS-792/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/interfaces/CacheKeyFactory.java
 Wed Oct 23 22:23:21 2013
@@ -28,6 +28,23 @@ public class CacheKeyFactory extends org
   {
   }
 
+  /** Construct a key which represents the general list of authority groups.
+  *@return the cache key.
+  */
+  public static String makeAuthorityGroupsKey()
+  {
+    return "AUTHORITYGROUPS";
+  }
+
+  /** Construct a key which represents an individual authority group.
+  *@param groupName is the name of the group.
+  *@return the cache key.
+  */
+  public static String makeAuthorityGroupKey(String groupName)
+  {
+    return "AUTHORITYGROUP_"+groupName;
+  }
+
   /** Construct a key which represents the general list of authority 
connectors.
   *@return the cache key.
   */

Modified: 
manifoldcf/branches/CONNECTORS-792/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/interfaces/IAuthorityConnectionManager.java
URL: 
http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-792/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/interfaces/IAuthorityConnectionManager.java?rev=1535200&r1=1535199&r2=1535200&view=diff
==============================================================================
--- 
manifoldcf/branches/CONNECTORS-792/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/interfaces/IAuthorityConnectionManager.java
 (original)
+++ 
manifoldcf/branches/CONNECTORS-792/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/interfaces/IAuthorityConnectionManager.java
 Wed Oct 23 22:23:21 2013
@@ -45,6 +45,13 @@ public interface IAuthorityConnectionMan
   public void importConfiguration(java.io.InputStream is)
     throws java.io.IOException, ManifoldCFException;
 
+  /** Return true if the specified authority group name is referenced.
+  *@param authorityGroup is the authority group name.
+  *@return true if referenced, false otherwise.
+  */
+  public boolean isReferenced(String authorityGroup)
+    throws ManifoldCFException;
+
   /** Obtain a list of the authority connections, ordered by name.
   *@return an array of connection objects.
   */

Added: 
manifoldcf/branches/CONNECTORS-792/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/interfaces/IAuthorityGroup.java
URL: 
http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-792/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/interfaces/IAuthorityGroup.java?rev=1535200&view=auto
==============================================================================
--- 
manifoldcf/branches/CONNECTORS-792/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/interfaces/IAuthorityGroup.java
 (added)
+++ 
manifoldcf/branches/CONNECTORS-792/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/interfaces/IAuthorityGroup.java
 Wed Oct 23 22:23:21 2013
@@ -0,0 +1,58 @@
+/* $Id$ */
+
+/**
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.manifoldcf.authorities.interfaces;
+
+import org.apache.manifoldcf.core.interfaces.*;
+import java.util.*;
+
+/** This interface describes a paper object which is an authority group.
+*/
+public interface IAuthorityGroup
+{
+  /** Set 'isnew' condition.
+  *@param isnew true if this is a new instance.
+  */
+  public void setIsNew(boolean isnew);
+  
+  /** Get 'isnew' condition.
+  *@return true if this is a new connection, false otherwise.
+  */
+  public boolean getIsNew();
+
+  /** Set name.
+  *@param name is the name.
+  */
+  public void setName(String name);
+
+  /** Get name.
+  *@return the name
+  */
+  public String getName();
+
+  /** Set description.
+  *@param description is the description.
+  */
+  public void setDescription(String description);
+
+  /** Get description.
+  *@return the description
+  */
+  public String getDescription();
+
+}

Propchange: 
manifoldcf/branches/CONNECTORS-792/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/interfaces/IAuthorityGroup.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
manifoldcf/branches/CONNECTORS-792/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/interfaces/IAuthorityGroup.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: 
manifoldcf/branches/CONNECTORS-792/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/interfaces/IAuthorityGroupManager.java
URL: 
http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-792/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/interfaces/IAuthorityGroupManager.java?rev=1535200&view=auto
==============================================================================
--- 
manifoldcf/branches/CONNECTORS-792/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/interfaces/IAuthorityGroupManager.java
 (added)
+++ 
manifoldcf/branches/CONNECTORS-792/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/interfaces/IAuthorityGroupManager.java
 Wed Oct 23 22:23:21 2013
@@ -0,0 +1,100 @@
+/* $Id$ */
+
+/**
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.manifoldcf.authorities.interfaces;
+
+import org.apache.manifoldcf.core.interfaces.*;
+import java.util.*;
+
+/** This interface describes the functionality in the authority group manager.
+* The authority group manager manages the definitions of individual groups,
+* and allows them to be defined, edited, and removed.
+*/
+public interface IAuthorityGroupManager
+{
+  /** Install the manager.
+  */
+  public void install()
+    throws ManifoldCFException;
+
+  /** Uninstall the manager.
+  */
+  public void deinstall()
+    throws ManifoldCFException;
+
+  /** Export configuration */
+  public void exportConfiguration(java.io.OutputStream os)
+    throws java.io.IOException, ManifoldCFException;
+
+  /** Import configuration */
+  public void importConfiguration(java.io.InputStream is)
+    throws java.io.IOException, ManifoldCFException;
+
+  /** Obtain a list of the authority groups, ordered by name.
+  *@return an array of group objects.
+  */
+  public IAuthorityGroup[] getAllGroups()
+    throws ManifoldCFException;
+
+  /** Load a authority group by name.
+  *@param name is the name of the authority group.
+  *@return the loaded group object, or null if not found.
+  */
+  public IAuthorityGroup load(String name)
+    throws ManifoldCFException;
+
+  /** Load multiple authority groups by name.
+  *@param names are the names to load.
+  *@return the loaded group objects.
+  */
+  public IAuthorityGroup[] loadMultiple(String[] names)
+    throws ManifoldCFException;
+
+  /** Create a new authority group object.
+  *@return the new object.
+  */
+  public IAuthorityGroup create()
+    throws ManifoldCFException;
+
+  /** Save an authority group object.
+  *@param object is the object to save.
+  *@return true if the object was created, false otherwise.
+  */
+  public boolean save(IAuthorityGroup object)
+    throws ManifoldCFException;
+
+  /** Delete an authority group.
+  *@param name is the name of the group to delete.  If the
+  * name does not exist, no error is returned.
+  */
+  public void delete(String name)
+    throws ManifoldCFException;
+
+  // Schema related
+
+  /** Get the authority connection table name.
+  *@return the table name.
+  */
+  public String getTableName();
+
+  /** Get the authority connection name column.
+  *@return the name column.
+  */
+  public String getGroupNameColumn();
+
+}

Propchange: 
manifoldcf/branches/CONNECTORS-792/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/interfaces/IAuthorityGroupManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
manifoldcf/branches/CONNECTORS-792/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/interfaces/IAuthorityGroupManager.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: 
manifoldcf/branches/CONNECTORS-792/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/interfaces/IRepositoryConnectionManager.java
URL: 
http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-792/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/interfaces/IRepositoryConnectionManager.java?rev=1535200&r1=1535199&r2=1535200&view=diff
==============================================================================
--- 
manifoldcf/branches/CONNECTORS-792/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/interfaces/IRepositoryConnectionManager.java
 (original)
+++ 
manifoldcf/branches/CONNECTORS-792/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/interfaces/IRepositoryConnectionManager.java
 Wed Oct 23 22:23:21 2013
@@ -85,11 +85,11 @@ public interface IRepositoryConnectionMa
   public void delete(String name)
     throws ManifoldCFException;
 
-  /** Return true if the specified authority name is referenced.
-  *@param authorityName is the authority name.
+  /** Return true if the specified authority group name is referenced.
+  *@param authorityGroup is the authority group name.
   *@return true if referenced, false otherwise.
   */
-  public boolean isReferenced(String authorityName)
+  public boolean isReferenced(String authorityGroup)
     throws ManifoldCFException;
 
   /** Get a list of repository connections that share the same connector.


Reply via email to