http://git-wip-us.apache.org/repos/asf/atlas/blob/f57fd7f0/omrs/src/main/java/org/apache/atlas/omrs/enterprise/repositoryconnector/EnterpriseOMRSMetadataCollection.java
----------------------------------------------------------------------
diff --git 
a/omrs/src/main/java/org/apache/atlas/omrs/enterprise/repositoryconnector/EnterpriseOMRSMetadataCollection.java
 
b/omrs/src/main/java/org/apache/atlas/omrs/enterprise/repositoryconnector/EnterpriseOMRSMetadataCollection.java
index b5798c6..e930361 100644
--- 
a/omrs/src/main/java/org/apache/atlas/omrs/enterprise/repositoryconnector/EnterpriseOMRSMetadataCollection.java
+++ 
b/omrs/src/main/java/org/apache/atlas/omrs/enterprise/repositoryconnector/EnterpriseOMRSMetadataCollection.java
@@ -26,7 +26,9 @@ import 
org.apache.atlas.omrs.metadatacollection.properties.MatchCriteria;
 import org.apache.atlas.omrs.metadatacollection.properties.SequencingOrder;
 import org.apache.atlas.omrs.metadatacollection.properties.instances.*;
 import org.apache.atlas.omrs.metadatacollection.properties.typedefs.*;
+import 
org.apache.atlas.omrs.metadatacollection.repositoryconnector.OMRSRepositoryConnector;
 
+import java.util.HashMap;
 import java.util.List;
 import java.util.ArrayList;
 import java.util.Date;
@@ -66,41 +68,65 @@ public class EnterpriseOMRSMetadataCollection extends 
OMRSMetadataCollection
     /*
      * Private variables for a metadata collection instance
      */
-    private EnterpriseOMRSRepositoryConnector parentConnector;
-    private String                            enterpriseMetadataCollectionId;
-    private String                            enterpriseMetadataCollectionName;
-    private OMRSRepositoryValidator           repositoryValidator;
-    private OMRSRepositoryHelper              repositoryHelper;
+    private EnterpriseOMRSRepositoryConnector enterpriseParentConnector;
 
 
     /**
-     * Default constructor.
+     * Constructor ensures the metadata collection is linked to its connector 
and knows its metadata collection Id.
      *
-     * @param parentConnector - connector that this metadata collection 
supports.  The connector has the information
+     * @param enterpriseParentConnector - connector that this metadata 
collection supports.  The connector has the information
      *                        to call the metadata repository.
-     * @param enterpriseMetadataCollectionId - unique identifier for the 
metadata collection.
-     * @param enterpriseMetadataCollectionName - name of the metadata 
collection - used for messages.
+     * @param repositoryName - name of the repository - used for logging.
+     * @param repositoryHelper - class used to build type definitions and 
instances.
+     * @param repositoryValidator - class used to validate type definitions 
and instances.
+     * @param metadataCollectionId - unique Identifier of the metadata 
collection Id.
      */
-    public EnterpriseOMRSMetadataCollection(EnterpriseOMRSRepositoryConnector 
parentConnector,
+    public EnterpriseOMRSMetadataCollection(EnterpriseOMRSRepositoryConnector 
enterpriseParentConnector,
+                                            String                            
repositoryName,
                                             OMRSRepositoryHelper              
repositoryHelper,
                                             OMRSRepositoryValidator           
repositoryValidator,
-                                            String                            
enterpriseMetadataCollectionId,
-                                            String                            
enterpriseMetadataCollectionName)
+                                            String                            
metadataCollectionId)
     {
         /*
-         * The metadata collection Id is the unique Id for the metadata 
collection.  It is managed by the super class.
+         * The metadata collection Id is the unique identifier for the 
metadata collection.  It is managed by the super class.
          */
-        super(enterpriseMetadataCollectionId);
-        this.enterpriseMetadataCollectionId = enterpriseMetadataCollectionId;
-        this.enterpriseMetadataCollectionName = 
enterpriseMetadataCollectionName;
+        super(enterpriseParentConnector, repositoryName, metadataCollectionId, 
repositoryHelper, repositoryValidator);
 
         /*
-         * Save parentConnector and associated helper and validator since this 
has the connection information and
+         * Save enterpriseParentConnector since this has the connection 
information and
          * access to the metadata about the open metadata repository cohort.
          */
-        this.parentConnector = parentConnector;
-        this.repositoryHelper = repositoryHelper;
-        this.repositoryValidator = repositoryValidator;
+        this.enterpriseParentConnector = enterpriseParentConnector;
+
+    }
+
+
+    /* ======================================================================
+     * Group 1: Confirm the identity of the metadata repository being called.
+     */
+
+    /**
+     * Returns the identifier of the metadata repository.  This is the 
identifier used to register the
+     * metadata repository with the metadata repository cohort.  It is also 
the identifier used to
+     * identify the home repository of a metadata instance.
+     *
+     * @return String - metadata collection id.
+     * @throws RepositoryErrorException - there is a problem communicating 
with the metadata repository.
+     */
+    public String      getMetadataCollectionId() throws 
RepositoryErrorException
+    {
+        final String methodName = "getMetadataCollectionId";
+
+        /*
+         * Validate parameters
+         */
+        this.validateRepositoryConnector(methodName);
+        parentConnector.validateRepositoryIsActive(methodName);
+
+        /*
+         * Perform operation
+         */
+        return super.metadataCollectionId;
     }
 
 
@@ -122,167 +148,93 @@ public class EnterpriseOMRSMetadataCollection extends 
OMRSMetadataCollection
     public TypeDefGallery getAllTypes(String userId) throws 
RepositoryErrorException,
                                                             
UserNotAuthorizedException
     {
-        final String                       methodName = "getTypeDefs()";
+        final String                       methodName = "getAllTypes";
 
         /*
-         * The list of metadata collections are retrieved for each request to 
ensure that any changes in
-         * the shape of the cohort are reflected immediately.
+         * Validate parameters
          */
-        ArrayList<OMRSMetadataCollection>  metadataCollections = 
parentConnector.getMetadataCollections();
+        this.validateRepositoryConnector(methodName);
+        parentConnector.validateRepositoryIsActive(methodName);
 
-        if (metadataCollections == null)
-        {
-            /*
-             * No repositories available
-             */
-            OMRSErrorCode errorCode = OMRSErrorCode.NO_REPOSITORIES;
-            String errorMessage = errorCode.getErrorMessageId() + 
errorCode.getFormattedErrorMessage();
+        repositoryValidator.validateUserId(repositoryName, userId, methodName);
+
+        /*
+         * The list of cohort connectors are retrieved for each request to 
ensure that any changes in
+         * the shape of the cohort are reflected immediately.
+         */
+        List<OMRSRepositoryConnector> cohortConnectors = 
enterpriseParentConnector.getCohortConnectors(methodName);
 
-            throw new RepositoryErrorException(errorCode.getHTTPErrorCode(),
-                                               this.getClass().getName(),
-                                               methodName,
-                                               errorMessage,
-                                               errorCode.getSystemAction(),
-                                               errorCode.getUserAction());
-        }
 
         /*
          * Ready to process the request.  Search results need to come from all 
members of the cohort.
          * They need to be combined and then duplicates removed to create the 
final list of results.
-         * Some repositories may produce exceptions.  These exceptions are 
saved and may be returned if
+         * Some repositories may produce exceptions.  These exceptions are 
saved and will be returned if
          * there are no results from any repository.
          */
-        List<TypeDef>               combinedTypeDefResults          = new 
ArrayList<>();
-        List<AttributeTypeDef>      combinedAttributeTypeDefResults = new 
ArrayList<>();
+        HashMap<String, TypeDef>               combinedTypeDefResults          
= new HashMap<>();
+        HashMap<String, AttributeTypeDef>      combinedAttributeTypeDefResults 
= new HashMap<>();
+
         UserNotAuthorizedException  userNotAuthorizedException      = null;
         RepositoryErrorException    repositoryErrorException        = null;
-        RuntimeException            anotherException                = null;
+        Throwable                   anotherException                = null;
 
         /*
          * Loop through the metadata collections extracting the typedefs from 
each repository.
          */
-        for (OMRSMetadataCollection metadataCollection : metadataCollections)
+        for (OMRSRepositoryConnector cohortConnector : cohortConnectors)
         {
-            if (metadataCollection == null)
+            if (cohortConnector != null)
             {
-                /*
-                 * A problem in the set up of the metadata collection list.  
Repository connectors implemented
-                 * with no metadata collection are tested for in the 
OMRSEnterpriseConnectorManager so something
-                 * else has gone wrong.
-                 */
-                OMRSErrorCode errorCode = 
OMRSErrorCode.NULL_ENTERPRISE_METADATA_COLLECTION;
-                String errorMessage = errorCode.getErrorMessageId() + 
errorCode.getFormattedErrorMessage();
-
-                throw new 
RepositoryErrorException(errorCode.getHTTPErrorCode(),
-                                                   this.getClass().getName(),
-                                                   methodName,
-                                                   errorMessage,
-                                                   errorCode.getSystemAction(),
-                                                   errorCode.getUserAction());
-            }
+                OMRSMetadataCollection   metadataCollection = 
cohortConnector.getMetadataCollection();
 
-            /*
-             * Process the retrieved metadata collection
-             */
-            try
-            {
-                TypeDefGallery     results = 
metadataCollection.getAllTypes(userId);
+                validateMetadataCollection(metadataCollection, methodName);
 
-                /*
-                 * Step through the list of returned TypeDefs and consolidate.
-                 */
-                if (results != null)
+                try
                 {
-                    List<TypeDef>           typeDefResults     = 
results.getTypeDefs();
-                    List<AttributeTypeDef>  attributeResults   = 
results.getAttributeTypeDefs();
-
-                    if (typeDefResults != null)
+                    /*
+                     * Issue the request
+                     */
+                    TypeDefGallery     results = 
metadataCollection.getAllTypes(userId);
+
+                    /*
+                     * Step through the list of returned TypeDefs and 
consolidate.
+                     */
+                    if (results != null)
                     {
-                        combinedTypeDefResults.addAll(typeDefResults);
-                    }
-
-                    if (attributeResults != null)
-                    {
-                        
combinedAttributeTypeDefResults.addAll(attributeResults);
+                        combinedAttributeTypeDefResults = 
this.addUniqueAttributeTypeDefs(combinedAttributeTypeDefResults,
+                                                                               
           results.getAttributeTypeDefs(),
+                                                                               
           cohortConnector.getServerName(),
+                                                                               
           cohortConnector.getMetadataCollectionId(),
+                                                                               
           methodName);
+                        combinedTypeDefResults = 
this.addUniqueTypeDefs(combinedTypeDefResults,
+                                                                        
results.getTypeDefs(),
+                                                                        
cohortConnector.getServerName(),
+                                                                        
cohortConnector.getMetadataCollectionId(),
+                                                                        
methodName);
                     }
                 }
-            }
-            catch (RepositoryErrorException  error)
-            {
-                repositoryErrorException = error;
-            }
-            catch (UserNotAuthorizedException  error)
-            {
-                userNotAuthorizedException = error;
-            }
-            catch (RuntimeException   error)
-            {
-                anotherException = error;
+                catch (RepositoryErrorException error)
+                {
+                    repositoryErrorException = error;
+                }
+                catch (UserNotAuthorizedException error)
+                {
+                    userNotAuthorizedException = error;
+                }
+                catch (Throwable error)
+                {
+                    anotherException = error;
+                }
             }
         }
 
-        int  resultCount = (combinedTypeDefResults.size() + 
combinedAttributeTypeDefResults.size());
-
-        /*
-         * Return any results, or exception if nothing is found.
-         */
-        if (resultCount > 0)
-        {
-            TypeDefGallery combinedResults = new TypeDefGallery();
-
-            
combinedResults.setAttributeTypeDefs(combinedAttributeTypeDefResults);
-            combinedResults.setTypeDefs(combinedTypeDefResults);
-
-            if 
(repositoryValidator.validateEnterpriseTypeDefs(enterpriseMetadataCollectionName,
-                                                               
combinedTypeDefResults))
-            {
-                return combinedResults;
-            }
-            else
-            {
-                OMRSErrorCode errorCode = 
OMRSErrorCode.CONFLICTING_ENTERPRISE_TYPEDEFS;
-                String errorMessage = errorCode.getErrorMessageId() + 
errorCode.getFormattedErrorMessage();
-
-                throw new 
RepositoryErrorException(errorCode.getHTTPErrorCode(),
-                                                   this.getClass().getName(),
-                                                   methodName,
-                                                   errorMessage,
-                                                   errorCode.getSystemAction(),
-                                                   errorCode.getUserAction());
-            }
-        }
-        else
-        {
-            /*
-             * A system with no defined TypeDefs is unbelievable.  Certainly 
not very useful :)
-             * This probably means that exceptions were thrown.  Re-throw any 
cached exceptions
-             * or, if no exceptions occurred then throw repository error 
because something is wrong.
-             */
-            if (userNotAuthorizedException != null)
-            {
-                throw userNotAuthorizedException;
-            }
-            else if (repositoryErrorException != null)
-            {
-                throw repositoryErrorException;
-            }
-            else if (anotherException != null)
-            {
-                throw anotherException;
-            }
-            else
-            {
-                OMRSErrorCode errorCode = OMRSErrorCode.NO_TYPEDEFS_DEFINED;
-                String errorMessage = errorCode.getErrorMessageId() + 
errorCode.getFormattedErrorMessage();
-
-                throw new 
RepositoryErrorException(errorCode.getHTTPErrorCode(),
-                                                   this.getClass().getName(),
-                                                   methodName,
-                                                   errorMessage,
-                                                   errorCode.getSystemAction(),
-                                                   errorCode.getUserAction());
-            }
-        }
+        return validatedTypeDefGalleryResults(repositoryName,
+                                              combinedTypeDefResults,
+                                              combinedAttributeTypeDefResults,
+                                              userNotAuthorizedException,
+                                              repositoryErrorException,
+                                              anotherException,
+                                              methodName);
     }
 
 
@@ -303,183 +255,95 @@ public class EnterpriseOMRSMetadataCollection extends 
OMRSMetadataCollection
                                                                 
RepositoryErrorException,
                                                                 
UserNotAuthorizedException
     {
-        final String                       methodName = "findTypeDefsByName()";
+        final String   methodName        = "findTypesByName";
+        final String   nameParameterName = "name";
 
         /*
-         * Validate that there is a name supplied.
+         * Validate parameters
          */
-        if (name == null)
-        {
-            /*
-             * No Name supplied so can not perform the search
-             */
-            OMRSErrorCode errorCode = OMRSErrorCode.NO_TYPEDEF_NAME;
-            String errorMessage = errorCode.getErrorMessageId() + 
errorCode.getFormattedErrorMessage();
+        this.validateRepositoryConnector(methodName);
+        parentConnector.validateRepositoryIsActive(methodName);
 
-            throw new InvalidParameterException(errorCode.getHTTPErrorCode(),
-                                                this.getClass().getName(),
-                                                methodName,
-                                                errorMessage,
-                                                errorCode.getSystemAction(),
-                                                errorCode.getUserAction());
-        }
+        repositoryValidator.validateUserId(repositoryName, userId, methodName);
+        repositoryValidator.validateTypeName(repositoryName, 
nameParameterName, name, methodName);
 
         /*
-         * The list of metadata collections are retrieved for each request to 
ensure that any changes in
+         * The list of cohort connectors are retrieved for each request to 
ensure that any changes in
          * the shape of the cohort are reflected immediately.
          */
-        List<OMRSMetadataCollection>  metadataCollections = 
parentConnector.getMetadataCollections();
+        List<OMRSRepositoryConnector> cohortConnectors = 
enterpriseParentConnector.getCohortConnectors(methodName);
 
-        if (metadataCollections == null)
-        {
-            /*
-             * No repositories available
-             */
-            OMRSErrorCode errorCode = OMRSErrorCode.NO_REPOSITORIES;
-            String errorMessage = errorCode.getErrorMessageId() + 
errorCode.getFormattedErrorMessage();
-
-            throw new RepositoryErrorException(errorCode.getHTTPErrorCode(),
-                                               this.getClass().getName(),
-                                               methodName,
-                                               errorMessage,
-                                               errorCode.getSystemAction(),
-                                               errorCode.getUserAction());
-        }
 
         /*
          * Ready to process the request.  Search results need to come from all 
members of the cohort.
          * They need to be combined and then duplicates removed to create the 
final list of results.
-         * Some repositories may produce exceptions.  These exceptions are 
saved and may be returned if
+         * Some repositories may produce exceptions.  These exceptions are 
saved and will be returned if
          * there are no results from any repository.
          */
-        List<TypeDef>               combinedTypeDefResults          = new 
ArrayList<>();
-        List<AttributeTypeDef>      combinedAttributeTypeDefResults = new 
ArrayList<>();
-        InvalidParameterException   invalidParameterException       = null;
+        HashMap<String, TypeDef>               combinedTypeDefResults          
= new HashMap<>();
+        HashMap<String, AttributeTypeDef>      combinedAttributeTypeDefResults 
= new HashMap<>();
+
         UserNotAuthorizedException  userNotAuthorizedException      = null;
         RepositoryErrorException    repositoryErrorException        = null;
-        RuntimeException            anotherException                = null;
+        Throwable                   anotherException                = null;
 
         /*
          * Loop through the metadata collections extracting the typedefs from 
each repository.
          */
-        for (OMRSMetadataCollection metadataCollection : metadataCollections)
+        for (OMRSRepositoryConnector cohortConnector : cohortConnectors)
         {
-            if (metadataCollection == null)
+            if (cohortConnector != null)
             {
-                /*
-                 * A problem in the set up of the metadata collection list.  
Repository connectors implemented
-                 * with no metadata collection are tested for in the 
OMRSEnterpriseConnectorManager so something
-                 * else has gone wrong.
-                 */
-                OMRSErrorCode errorCode = 
OMRSErrorCode.NULL_ENTERPRISE_METADATA_COLLECTION;
-                String errorMessage = errorCode.getErrorMessageId() + 
errorCode.getFormattedErrorMessage();
-
-                throw new 
RepositoryErrorException(errorCode.getHTTPErrorCode(),
-                                                   this.getClass().getName(),
-                                                   methodName,
-                                                   errorMessage,
-                                                   errorCode.getSystemAction(),
-                                                   errorCode.getUserAction());
-            }
+                OMRSMetadataCollection   metadataCollection = 
cohortConnector.getMetadataCollection();
 
-            /*
-             * Process the retrieved metadata collection
-             */
-            try
-            {
-                TypeDefGallery     results              = 
metadataCollection.findTypesByName(userId, name);
-                String             metadataCollectionId = 
metadataCollection.getMetadataCollectionId();
+                validateMetadataCollection(metadataCollection, methodName);
 
-                /*
-                 * Combine the results from the metadata collection with those 
elements previously retrieved.
-                 */
-                if (results != null)
+                try
                 {
-                    List<TypeDef>           typeDefResults     = 
results.getTypeDefs();
-                    List<AttributeTypeDef>  attributeResults   = 
results.getAttributeTypeDefs();
-
-                    if (typeDefResults != null)
-                    {
-                        combinedTypeDefResults.addAll(typeDefResults);
-                    }
-
-                    if (attributeResults != null)
+                    /*
+                     * Issue the request
+                     */
+                    TypeDefGallery     results = 
metadataCollection.findTypesByName(userId, name);
+
+                    /*
+                     * Step through the list of returned TypeDefs and 
consolidate.
+                     */
+                    if (results != null)
                     {
-                        
combinedAttributeTypeDefResults.addAll(attributeResults);
+                        combinedAttributeTypeDefResults = 
this.addUniqueAttributeTypeDefs(combinedAttributeTypeDefResults,
+                                                                               
           results.getAttributeTypeDefs(),
+                                                                               
           cohortConnector.getServerName(),
+                                                                               
           cohortConnector.getMetadataCollectionId(),
+                                                                               
           methodName);
+                        combinedTypeDefResults = 
this.addUniqueTypeDefs(combinedTypeDefResults,
+                                                                        
results.getTypeDefs(),
+                                                                        
cohortConnector.getServerName(),
+                                                                        
cohortConnector.getMetadataCollectionId(),
+                                                                        
methodName);
                     }
                 }
-            }
-            catch (InvalidParameterException  error)
-            {
-                invalidParameterException = error;
-            }
-            catch (RepositoryErrorException  error)
-            {
-                repositoryErrorException = error;
-            }
-            catch (UserNotAuthorizedException  error)
-            {
-                userNotAuthorizedException = error;
-            }
-            catch (RuntimeException   error)
-            {
-                anotherException = error;
+                catch (RepositoryErrorException error)
+                {
+                    repositoryErrorException = error;
+                }
+                catch (UserNotAuthorizedException error)
+                {
+                    userNotAuthorizedException = error;
+                }
+                catch (Throwable error)
+                {
+                    anotherException = error;
+                }
             }
         }
 
-        int  resultCount = (combinedTypeDefResults.size() + 
combinedAttributeTypeDefResults.size());
-
-        /*
-         * Return any results, or exception if nothing is found.
-         */
-        if (resultCount > 0)
-        {
-            TypeDefGallery combinedResults = new TypeDefGallery();
-
-            
combinedResults.setAttributeTypeDefs(combinedAttributeTypeDefResults);
-            combinedResults.setTypeDefs(combinedTypeDefResults);
-
-            if 
(repositoryValidator.validateEnterpriseTypeDefs(enterpriseMetadataCollectionName,
-                                                               
combinedTypeDefResults))
-            {
-                return combinedResults;
-            }
-            else
-            {
-                OMRSErrorCode errorCode = 
OMRSErrorCode.CONFLICTING_ENTERPRISE_TYPEDEFS;
-                String errorMessage = errorCode.getErrorMessageId() + 
errorCode.getFormattedErrorMessage();
-
-                throw new 
RepositoryErrorException(errorCode.getHTTPErrorCode(),
-                                                   this.getClass().getName(),
-                                                   methodName,
-                                                   errorMessage,
-                                                   errorCode.getSystemAction(),
-                                                   errorCode.getUserAction());
-            }
-        }
-        else
-        {
-            if (userNotAuthorizedException != null)
-            {
-                throw userNotAuthorizedException;
-            }
-            else if (repositoryErrorException != null)
-            {
-                throw repositoryErrorException;
-            }
-            else if (invalidParameterException != null)
-            {
-                throw invalidParameterException;
-            }
-            else if (anotherException != null)
-            {
-                throw anotherException;
-            }
-            else
-            {
-                return null;
-            }
-        }
+        return validatedTypeDefGalleryResults(repositoryName,
+                                              combinedTypeDefResults,
+                                              combinedAttributeTypeDefResults,
+                                              userNotAuthorizedException,
+                                              repositoryErrorException,
+                                              anotherException,
+                                              methodName);
     }
 
 
@@ -487,176 +351,94 @@ public class EnterpriseOMRSMetadataCollection extends 
OMRSMetadataCollection
      * Returns all of the TypeDefs for a specific category.
      *
      * @param userId - unique identifier for requesting user.
-     * @param typeDefCategory - enum value for the category of TypeDef to 
return.
+     * @param category - enum value for the category of TypeDef to return.
      * @return TypeDefs list.
      * @throws InvalidParameterException - the TypeDefCategory is null.
      * @throws RepositoryErrorException - there is a problem communicating 
with the metadata repository.
      * @throws UserNotAuthorizedException - the userId is not permitted to 
perform this operation.
      */
     public List<TypeDef> findTypeDefsByCategory(String          userId,
-                                                TypeDefCategory 
typeDefCategory) throws InvalidParameterException,
-                                                                               
         RepositoryErrorException,
-                                                                               
         UserNotAuthorizedException
+                                                TypeDefCategory category) 
throws InvalidParameterException,
+                                                                               
  RepositoryErrorException,
+                                                                               
  UserNotAuthorizedException
     {
-        final String                       methodName = 
"findTypeDefsByCategory()";
+        final String methodName            = "findTypeDefsByCategory";
+        final String categoryParameterName = "category";
 
-        if (typeDefCategory == null)
-        {
-            /*
-             * No category supplied so can not perform the search
-             */
-            OMRSErrorCode errorCode = OMRSErrorCode.NO_TYPEDEF_CATEGORY;
-            String errorMessage = errorCode.getErrorMessageId() + 
errorCode.getFormattedErrorMessage();
+        /*
+         * Validate parameters
+         */
+        this.validateRepositoryConnector(methodName);
+        parentConnector.validateRepositoryIsActive(methodName);
 
-            throw new InvalidParameterException(errorCode.getHTTPErrorCode(),
-                                                this.getClass().getName(),
-                                                methodName,
-                                                errorMessage,
-                                                errorCode.getSystemAction(),
-                                                errorCode.getUserAction());
-        }
+        repositoryValidator.validateUserId(repositoryName, userId, methodName);
+        repositoryValidator.validateTypeDefCategory(repositoryName, 
categoryParameterName, category, methodName);
 
         /*
-         * The list of metadata collections are retrieved for each request to 
ensure that any changes in
+         * The list of cohort connectors are retrieved for each request to 
ensure that any changes in
          * the shape of the cohort are reflected immediately.
          */
-        List<OMRSMetadataCollection>  metadataCollections = 
parentConnector.getMetadataCollections();
-
-        if (metadataCollections == null)
-        {
-            /*
-             * No repositories available
-             */
-            OMRSErrorCode errorCode = OMRSErrorCode.NO_REPOSITORIES;
-            String errorMessage = errorCode.getErrorMessageId() + 
errorCode.getFormattedErrorMessage();
-
-            throw new RepositoryErrorException(errorCode.getHTTPErrorCode(),
-                                               this.getClass().getName(),
-                                               methodName,
-                                               errorMessage,
-                                               errorCode.getSystemAction(),
-                                               errorCode.getUserAction());
-        }
+        List<OMRSRepositoryConnector> cohortConnectors = 
enterpriseParentConnector.getCohortConnectors(methodName);
 
         /*
          * Ready to process the request.  Search results need to come from all 
members of the cohort.
          * They need to be combined and then duplicates removed to create the 
final list of results.
-         * Some repositories may produce exceptions.  These exceptions are 
saved and may be returned if
+         * Some repositories may produce exceptions.  These exceptions are 
saved and will be returned if
          * there are no results from any repository.
          */
-        List<TypeDef>              combinedResults            = new 
ArrayList<>();
-        InvalidParameterException  invalidParameterException  = null;
+        HashMap<String, TypeDef>   combinedResults            = new 
HashMap<>();
         UserNotAuthorizedException userNotAuthorizedException = null;
         RepositoryErrorException   repositoryErrorException   = null;
-        RuntimeException           anotherException           = null;
+        Throwable                  anotherException           = null;
 
         /*
          * Loop through the metadata collections extracting the typedefs from 
each repository.
          */
-        for (OMRSMetadataCollection metadataCollection : metadataCollections)
+        for (OMRSRepositoryConnector cohortConnector : cohortConnectors)
         {
-            if (metadataCollection == null)
+            if (cohortConnector != null)
             {
-                /*
-                 * A problem in the set up of the metadata collection list.  
Repository connectors implemented
-                 * with no metadata collection are tested for in the 
OMRSEnterpriseConnectorManager so something
-                 * else has gone wrong.
-                 */
-                OMRSErrorCode errorCode = 
OMRSErrorCode.NULL_ENTERPRISE_METADATA_COLLECTION;
-                String errorMessage = errorCode.getErrorMessageId() + 
errorCode.getFormattedErrorMessage();
-
-                throw new 
RepositoryErrorException(errorCode.getHTTPErrorCode(),
-                                                   this.getClass().getName(),
-                                                   methodName,
-                                                   errorMessage,
-                                                   errorCode.getSystemAction(),
-                                                   errorCode.getUserAction());
-            }
+                OMRSMetadataCollection   metadataCollection = 
cohortConnector.getMetadataCollection();
 
-            /*
-             * Process the retrieved metadata collection
-             */
-            try
-            {
-                List<TypeDef>    results              = 
metadataCollection.findTypeDefsByCategory(userId, typeDefCategory);
-                String           metadataCollectionId = 
metadataCollection.getMetadataCollectionId();
+                validateMetadataCollection(metadataCollection, methodName);
 
-                /*
-                 * Step through the list of returned TypeDefs and remove 
duplicates.
-                 */
-                if (results != null)
+                try
                 {
-                    for (TypeDef returnedTypeDef : results)
-                    {
-                        combinedResults = 
this.addUniqueTypeDef(combinedResults,
-                                                                
returnedTypeDef,
-                                                                
metadataCollectionId);
-                    }
+                    /*
+                     * Issue the request
+                     */
+                    List<TypeDef> results  = 
metadataCollection.findTypeDefsByCategory(userId, category);
+
+                    /*
+                     * Step through the list of returned TypeDefs and remove 
duplicates.
+                     */
+                    combinedResults = this.addUniqueTypeDefs(combinedResults,
+                                                             results,
+                                                             
cohortConnector.getServerName(),
+                                                             
cohortConnector.getMetadataCollectionId(),
+                                                             methodName);
+                }
+                catch (RepositoryErrorException error)
+                {
+                    repositoryErrorException = error;
+                }
+                catch (UserNotAuthorizedException error)
+                {
+                    userNotAuthorizedException = error;
+                }
+                catch (Throwable error)
+                {
+                    anotherException = error;
                 }
-            }
-            catch (InvalidParameterException  error)
-            {
-                invalidParameterException = error;
-            }
-            catch (RepositoryErrorException  error)
-            {
-                repositoryErrorException = error;
-            }
-            catch (UserNotAuthorizedException  error)
-            {
-                userNotAuthorizedException = error;
-            }
-            catch (RuntimeException   error)
-            {
-                anotherException = error;
             }
         }
 
-        /*
-         * Return any results, or null if nothing is found.
-         */
-        if (combinedResults.size() > 0)
-        {
-            if 
(repositoryValidator.validateEnterpriseTypeDefs(enterpriseMetadataCollectionName,
 combinedResults))
-            {
-                return combinedResults;
-            }
-            else
-            {
-                OMRSErrorCode errorCode = 
OMRSErrorCode.CONFLICTING_ENTERPRISE_TYPEDEFS;
-                String errorMessage = errorCode.getErrorMessageId() + 
errorCode.getFormattedErrorMessage();
-
-                throw new 
RepositoryErrorException(errorCode.getHTTPErrorCode(),
-                                                   this.getClass().getName(),
-                                                   methodName,
-                                                   errorMessage,
-                                                   errorCode.getSystemAction(),
-                                                   errorCode.getUserAction());
-            }
-        }
-        else
-        {
-            if (userNotAuthorizedException != null)
-            {
-                throw userNotAuthorizedException;
-            }
-            else if (repositoryErrorException != null)
-            {
-                throw repositoryErrorException;
-            }
-            else if (invalidParameterException != null)
-            {
-                throw invalidParameterException;
-            }
-            else if (anotherException != null)
-            {
-                throw anotherException;
-            }
-            else
-            {
-                return null;
-            }
-        }
+        return validatedTypeDefListResults(repositoryName,
+                                           combinedResults,
+                                           userNotAuthorizedException,
+                                           repositoryErrorException,
+                                           anotherException,
+                                           methodName);
     }
 
 
@@ -675,184 +457,179 @@ public class EnterpriseOMRSMetadataCollection extends 
OMRSMetadataCollection
                                                                                
                             RepositoryErrorException,
                                                                                
                             UserNotAuthorizedException
     {
-        return null;
-    }
+        final String methodName            = "findAttributeTypeDefsByCategory";
+        final String categoryParameterName = "category";
 
+        /*
+         * Validate parameters
+         */
+        this.validateRepositoryConnector(methodName);
+        parentConnector.validateRepositoryIsActive(methodName);
 
-    /**
-     * Return the TypeDefs that have the properties matching the supplied 
match criteria.
-     *
-     * @param userId - unique identifier for requesting user.
-     * @param matchCriteria - TypeDefProperties - a list of property names and 
values.
-     * @return TypeDefs list.
-     * @throws InvalidParameterException - the matchCriteria is null.
-     * @throws RepositoryErrorException - there is a problem communicating 
with the metadata repository.
-     * @throws UserNotAuthorizedException - the userId is not permitted to 
perform this operation.
-     */
-    public List<TypeDef> findTypeDefsByProperty(String            userId,
-                                                TypeDefProperties 
matchCriteria) throws InvalidParameterException,
-                                                                               
         RepositoryErrorException,
-                                                                               
         UserNotAuthorizedException
-    {
-        final String                       methodName = 
"findTypeDefsByProperty()";
-
-        if (matchCriteria == null)
-        {
-            /*
-             * No match criteria supplied so can not perform the search
-             */
-            OMRSErrorCode errorCode = OMRSErrorCode.NO_MATCH_CRITERIA;
-            String errorMessage = errorCode.getErrorMessageId() + 
errorCode.getFormattedErrorMessage();
-
-            throw new InvalidParameterException(errorCode.getHTTPErrorCode(),
-                                                this.getClass().getName(),
-                                                methodName,
-                                                errorMessage,
-                                                errorCode.getSystemAction(),
-                                                errorCode.getUserAction());
-        }
+        repositoryValidator.validateUserId(repositoryName, userId, methodName);
+        repositoryValidator.validateAttributeTypeDefCategory(repositoryName, 
categoryParameterName, category, methodName);
 
         /*
-         * The list of metadata collections are retrieved for each request to 
ensure that any changes in
+         * The list of cohort connectors are retrieved for each request to 
ensure that any changes in
          * the shape of the cohort are reflected immediately.
          */
-        List<OMRSMetadataCollection>  metadataCollections = 
parentConnector.getMetadataCollections();
-
-        if (metadataCollections == null)
-        {
-            /*
-             * No repositories available
-             */
-            OMRSErrorCode errorCode = OMRSErrorCode.NO_REPOSITORIES;
-            String errorMessage = errorCode.getErrorMessageId() + 
errorCode.getFormattedErrorMessage();
-
-            throw new RepositoryErrorException(errorCode.getHTTPErrorCode(),
-                                               this.getClass().getName(),
-                                               methodName,
-                                               errorMessage,
-                                               errorCode.getSystemAction(),
-                                               errorCode.getUserAction());
-        }
+        List<OMRSRepositoryConnector> cohortConnectors = 
enterpriseParentConnector.getCohortConnectors(methodName);
 
         /*
          * Ready to process the request.  Search results need to come from all 
members of the cohort.
          * They need to be combined and then duplicates removed to create the 
final list of results.
-         * Some repositories may produce exceptions.  These exceptions are 
saved and may be returned if
+         * Some repositories may produce exceptions.  These exceptions are 
saved and will be returned if
          * there are no results from any repository.
          */
-        List<TypeDef>              combinedResults            = new 
ArrayList<>();
-        InvalidParameterException  invalidParameterException  = null;
+        HashMap<String, AttributeTypeDef>   combinedResults   = new 
HashMap<>();
+
         UserNotAuthorizedException userNotAuthorizedException = null;
         RepositoryErrorException   repositoryErrorException   = null;
-        RuntimeException           anotherException           = null;
+        Throwable                  anotherException           = null;
 
         /*
          * Loop through the metadata collections extracting the typedefs from 
each repository.
          */
-        for (OMRSMetadataCollection metadataCollection : metadataCollections)
+        for (OMRSRepositoryConnector cohortConnector : cohortConnectors)
         {
-            if (metadataCollection == null)
+            if (cohortConnector != null)
             {
-                /*
-                 * A problem in the set up of the metadata collection list.  
Repository connectors implemented
-                 * with no metadata collection are tested for in the 
OMRSEnterpriseConnectorManager so something
-                 * else has gone wrong.
-                 */
-                OMRSErrorCode errorCode = 
OMRSErrorCode.NULL_ENTERPRISE_METADATA_COLLECTION;
-                String errorMessage = errorCode.getErrorMessageId() + 
errorCode.getFormattedErrorMessage();
-
-                throw new 
RepositoryErrorException(errorCode.getHTTPErrorCode(),
-                                                   this.getClass().getName(),
-                                                   methodName,
-                                                   errorMessage,
-                                                   errorCode.getSystemAction(),
-                                                   errorCode.getUserAction());
-            }
+                OMRSMetadataCollection   metadataCollection = 
cohortConnector.getMetadataCollection();
 
-            /*
-             * Process the retrieved metadata collection
-             */
-            try
-            {
-                List<TypeDef>      results              = 
metadataCollection.findTypeDefsByProperty(userId, matchCriteria);
-                String             metadataCollectionId = 
metadataCollection.getMetadataCollectionId();
+                validateMetadataCollection(metadataCollection, methodName);
 
-                /*
-                 * Step through the list of returned TypeDefs and remove 
duplicates.
-                 */
-                if (results != null)
+                try
                 {
-                    for (TypeDef returnedTypeDef : results)
-                    {
-                        combinedResults = 
this.addUniqueTypeDef(combinedResults,
-                                                                
returnedTypeDef,
-                                                                
metadataCollectionId);
-                    }
+                    /*
+                     * Issue the request
+                     */
+                    List<AttributeTypeDef> results  = 
metadataCollection.findAttributeTypeDefsByCategory(userId, category);
+
+                    /*
+                     * Step through the list of returned TypeDefs and remove 
duplicates.
+                     */
+                    combinedResults = 
this.addUniqueAttributeTypeDefs(combinedResults,
+                                                                      results,
+                                                                      
cohortConnector.getServerName(),
+                                                                      
cohortConnector.getMetadataCollectionId(),
+                                                                      
methodName);
+                }
+                catch (RepositoryErrorException error)
+                {
+                    repositoryErrorException = error;
+                }
+                catch (UserNotAuthorizedException error)
+                {
+                    userNotAuthorizedException = error;
+                }
+                catch (Throwable error)
+                {
+                    anotherException = error;
                 }
-            }
-            catch (InvalidParameterException  error)
-            {
-                invalidParameterException = error;
-            }
-            catch (RepositoryErrorException  error)
-            {
-                repositoryErrorException = error;
-            }
-            catch (UserNotAuthorizedException  error)
-            {
-                userNotAuthorizedException = error;
-            }
-            catch (RuntimeException   error)
-            {
-                anotherException = error;
             }
         }
 
+        return validatedAttributeTypeDefListResults(repositoryName,
+                                                    combinedResults,
+                                                    userNotAuthorizedException,
+                                                    repositoryErrorException,
+                                                    anotherException,
+                                                    methodName);
+    }
+
+
+    /**
+     * Return the TypeDefs that have the properties matching the supplied 
match criteria.
+     *
+     * @param userId - unique identifier for requesting user.
+     * @param matchCriteria - TypeDefProperties - a list of property names and 
values.
+     * @return TypeDefs list.
+     * @throws InvalidParameterException - the matchCriteria is null.
+     * @throws RepositoryErrorException - there is a problem communicating 
with the metadata repository.
+     * @throws UserNotAuthorizedException - the userId is not permitted to 
perform this operation.
+     */
+    public List<TypeDef> findTypeDefsByProperty(String            userId,
+                                                TypeDefProperties 
matchCriteria) throws InvalidParameterException,
+                                                                               
         RepositoryErrorException,
+                                                                               
         UserNotAuthorizedException
+    {
+        final String  methodName                 = "findTypeDefsByProperty";
+        final String  matchCriteriaParameterName = "matchCriteria";
+
         /*
-         * Return any results, or null if nothing is found.
+         * Validate parameters
          */
-        if (combinedResults.size() > 0)
-        {
-            if 
(repositoryValidator.validateEnterpriseTypeDefs(enterpriseMetadataCollectionName,
 combinedResults))
-            {
-                return combinedResults;
-            }
-            else
-            {
-                OMRSErrorCode errorCode = 
OMRSErrorCode.CONFLICTING_ENTERPRISE_TYPEDEFS;
-                String errorMessage = errorCode.getErrorMessageId() + 
errorCode.getFormattedErrorMessage();
-
-                throw new 
RepositoryErrorException(errorCode.getHTTPErrorCode(),
-                                                   this.getClass().getName(),
-                                                   methodName,
-                                                   errorMessage,
-                                                   errorCode.getSystemAction(),
-                                                   errorCode.getUserAction());
-            }
-        }
-        else
+        this.validateRepositoryConnector(methodName);
+        parentConnector.validateRepositoryIsActive(methodName);
+
+        repositoryValidator.validateUserId(repositoryName, userId, methodName);
+        repositoryValidator.validateMatchCriteria(repositoryName, 
matchCriteriaParameterName, matchCriteria, methodName);
+
+        /*
+         * The list of cohort connectors are retrieved for each request to 
ensure that any changes in
+         * the shape of the cohort are reflected immediately.
+         */
+        List<OMRSRepositoryConnector> cohortConnectors = 
enterpriseParentConnector.getCohortConnectors(methodName);
+
+        /*
+         * Ready to process the request.  Search results need to come from all 
members of the cohort.
+         * They need to be combined and then duplicates removed to create the 
final list of results.
+         * Some repositories may produce exceptions.  These exceptions are 
saved and will be returned if
+         * there are no results from any repository.
+         */
+        HashMap<String, TypeDef>   combinedResults            = new 
HashMap<>();
+        UserNotAuthorizedException userNotAuthorizedException = null;
+        RepositoryErrorException   repositoryErrorException   = null;
+        Throwable                  anotherException           = null;
+
+        /*
+         * Loop through the metadata collections extracting the typedefs from 
each repository.
+         */
+        for (OMRSRepositoryConnector cohortConnector : cohortConnectors)
         {
-            if (userNotAuthorizedException != null)
-            {
-                throw userNotAuthorizedException;
-            }
-            else if (repositoryErrorException != null)
-            {
-                throw repositoryErrorException;
-            }
-            else if (invalidParameterException != null)
-            {
-                throw invalidParameterException;
-            }
-            else if (anotherException != null)
-            {
-                throw anotherException;
-            }
-            else
+            if (cohortConnector != null)
             {
-                return null;
+                OMRSMetadataCollection   metadataCollection = 
cohortConnector.getMetadataCollection();
+
+                validateMetadataCollection(metadataCollection, methodName);
+
+                try
+                {
+                    /*
+                     * Issue the request
+                     */
+                    List<TypeDef> results  = 
metadataCollection.findTypeDefsByProperty(userId, matchCriteria);
+
+                    /*
+                     * Step through the list of returned TypeDefs and remove 
duplicates.
+                     */
+                    combinedResults = this.addUniqueTypeDefs(combinedResults,
+                                                             results,
+                                                             
cohortConnector.getServerName(),
+                                                             
cohortConnector.getMetadataCollectionId(),
+                                                             methodName);
+                }
+                catch (RepositoryErrorException error)
+                {
+                    repositoryErrorException = error;
+                }
+                catch (UserNotAuthorizedException error)
+                {
+                    userNotAuthorizedException = error;
+                }
+                catch (Throwable error)
+                {
+                    anotherException = error;
+                }
             }
         }
+
+        return validatedTypeDefListResults(repositoryName,
+                                           combinedResults,
+                                           userNotAuthorizedException,
+                                           repositoryErrorException,
+                                           anotherException,
+                                           methodName);
     }
 
 
@@ -869,34 +646,89 @@ public class EnterpriseOMRSMetadataCollection extends 
OMRSMetadataCollection
      * @throws RepositoryErrorException - there is a problem communicating 
with the metadata repository.
      * @throws UserNotAuthorizedException - the userId is not permitted to 
perform this operation.
      */
-    public List<TypeDef> findTypesByExternalID(String    userId,
+    public  List<TypeDef> findTypesByExternalID(String    userId,
                                                 String    standard,
                                                 String    organization,
                                                 String    identifier) throws 
InvalidParameterException,
                                                                              
RepositoryErrorException,
                                                                              
UserNotAuthorizedException
     {
-        final String                       methodName = 
"findTypeDefsByExternalID()";
+        final String                       methodName = 
"findTypesByExternalID";
+
+        /*
+         * Validate parameters
+         */
+        this.validateRepositoryConnector(methodName);
+        parentConnector.validateRepositoryIsActive(methodName);
+
+        repositoryValidator.validateUserId(repositoryName, userId, methodName);
+        repositoryValidator.validateExternalId(repositoryName, standard, 
organization, identifier, methodName);
+
+        /*
+         * The list of cohort connectors are retrieved for each request to 
ensure that any changes in
+         * the shape of the cohort are reflected immediately.
+         */
+        List<OMRSRepositoryConnector> cohortConnectors = 
enterpriseParentConnector.getCohortConnectors(methodName);
 
-        if ((standard == null) && (organization == null) && (identifier == 
null))
+        /*
+         * Ready to process the request.  Search results need to come from all 
members of the cohort.
+         * They need to be combined and then duplicates removed to create the 
final list of results.
+         * Some repositories may produce exceptions.  These exceptions are 
saved and one selected to
+         * be returned if there are no results from any repository.
+         */
+        HashMap<String, TypeDef>   combinedResults            = new 
HashMap<>();
+        UserNotAuthorizedException userNotAuthorizedException = null;
+        RepositoryErrorException   repositoryErrorException   = null;
+        Throwable                  anotherException           = null;
+
+        /*
+         * Loop through the metadata collections extracting the typedefs from 
each repository.
+         */
+        for (OMRSRepositoryConnector cohortConnector : cohortConnectors)
         {
-            /*
-             * No external Id properties supplied so can not perform the search
-             */
-            OMRSErrorCode errorCode = OMRSErrorCode.NO_EXTERNAL_ID;
-            String errorMessage = errorCode.getErrorMessageId() + 
errorCode.getFormattedErrorMessage();
+            if (cohortConnector != null)
+            {
+                OMRSMetadataCollection   metadataCollection = 
cohortConnector.getMetadataCollection();
 
-            throw new InvalidParameterException(errorCode.getHTTPErrorCode(),
-                                                this.getClass().getName(),
-                                                methodName,
-                                                errorMessage,
-                                                errorCode.getSystemAction(),
-                                                errorCode.getUserAction());
-        }
+                validateMetadataCollection(metadataCollection, methodName);
 
-        // todo
+                try
+                {
+                    /*
+                     * Issue the request
+                     */
+                    List<TypeDef> results  = 
metadataCollection.findTypesByExternalID(userId, standard, organization, 
identifier);
+
+                    /*
+                     * Step through the list of returned TypeDefs and remove 
duplicates.
+                     */
+                    combinedResults = this.addUniqueTypeDefs(combinedResults,
+                                                             results,
+                                                             
cohortConnector.getServerName(),
+                                                             
cohortConnector.getMetadataCollectionId(),
+                                                             methodName);
+                }
+                catch (RepositoryErrorException error)
+                {
+                    repositoryErrorException = error;
+                }
+                catch (UserNotAuthorizedException error)
+                {
+                    userNotAuthorizedException = error;
+                }
+                catch (Throwable error)
+                {
+                    anotherException = error;
+                }
+            }
+        }
 
-        return null;
+        return validatedTypeDefListResults(repositoryName,
+                                           combinedResults,
+                                           userNotAuthorizedException,
+                                           repositoryErrorException,
+                                           anotherException,
+                                           methodName);
     }
 
 
@@ -916,165 +748,83 @@ public class EnterpriseOMRSMetadataCollection extends 
OMRSMetadataCollection
                                                                          
RepositoryErrorException,
                                                                          
UserNotAuthorizedException
     {
-        final String                       methodName = "searchForTypeDefs()";
+        final String methodName                  = "searchForTypeDefs";
+        final String searchCriteriaParameterName = "searchCriteria";
 
-        if (searchCriteria == null)
-        {
-            /*
-             * No search criteria supplied so can not perform the search
-             */
-            OMRSErrorCode errorCode = OMRSErrorCode.NO_SEARCH_CRITERIA;
-            String errorMessage = errorCode.getErrorMessageId() + 
errorCode.getFormattedErrorMessage();
+        /*
+         * Validate parameters
+         */
+        this.validateRepositoryConnector(methodName);
+        parentConnector.validateRepositoryIsActive(methodName);
 
-            throw new InvalidParameterException(errorCode.getHTTPErrorCode(),
-                                                this.getClass().getName(),
-                                                methodName,
-                                                errorMessage,
-                                                errorCode.getSystemAction(),
-                                                errorCode.getUserAction());
-        }
+        repositoryValidator.validateUserId(repositoryName, userId, methodName);
+        repositoryValidator.validateSearchCriteria(repositoryName, 
searchCriteriaParameterName, searchCriteria, methodName);
 
         /*
-         * The list of metadata collections are retrieved for each request to 
ensure that any changes in
+         * The list of cohort connectors are retrieved for each request to 
ensure that any changes in
          * the shape of the cohort are reflected immediately.
          */
-        List<OMRSMetadataCollection>  metadataCollections = 
parentConnector.getMetadataCollections();
-
-        if (metadataCollections == null)
-        {
-            /*
-             * No repositories available
-             */
-            OMRSErrorCode errorCode = OMRSErrorCode.NO_REPOSITORIES;
-            String errorMessage = errorCode.getErrorMessageId() + 
errorCode.getFormattedErrorMessage();
-
-            throw new RepositoryErrorException(errorCode.getHTTPErrorCode(),
-                                               this.getClass().getName(),
-                                               methodName,
-                                               errorMessage,
-                                               errorCode.getSystemAction(),
-                                               errorCode.getUserAction());
-        }
+        List<OMRSRepositoryConnector> cohortConnectors = 
enterpriseParentConnector.getCohortConnectors(methodName);
 
         /*
          * Ready to process the request.  Search results need to come from all 
members of the cohort.
          * They need to be combined and then duplicates removed to create the 
final list of results.
-         * Some repositories may produce exceptions.  These exceptions are 
saved and may be returned if
+         * Some repositories may produce exceptions.  These exceptions are 
saved and will be returned if
          * there are no results from any repository.
          */
-        List<TypeDef>              combinedResults            = new 
ArrayList<>();
-        InvalidParameterException  invalidParameterException  = null;
+        HashMap<String, TypeDef>   combinedResults            = new 
HashMap<>();
         UserNotAuthorizedException userNotAuthorizedException = null;
         RepositoryErrorException   repositoryErrorException   = null;
-        RuntimeException           anotherException           = null;
+        Throwable                  anotherException           = null;
 
         /*
          * Loop through the metadata collections extracting the typedefs from 
each repository.
          */
-        for (OMRSMetadataCollection metadataCollection : metadataCollections)
+        for (OMRSRepositoryConnector cohortConnector : cohortConnectors)
         {
-            if (metadataCollection == null)
+            if (cohortConnector != null)
             {
-                /*
-                 * A problem in the set up of the metadata collection list.  
Repository connectors implemented
-                 * with no metadata collection are tested for in the 
OMRSEnterpriseConnectorManager so something
-                 * else has gone wrong.
-                 */
-                OMRSErrorCode errorCode = 
OMRSErrorCode.NULL_ENTERPRISE_METADATA_COLLECTION;
-                String errorMessage = errorCode.getErrorMessageId() + 
errorCode.getFormattedErrorMessage();
-
-                throw new 
RepositoryErrorException(errorCode.getHTTPErrorCode(),
-                                                   this.getClass().getName(),
-                                                   methodName,
-                                                   errorMessage,
-                                                   errorCode.getSystemAction(),
-                                                   errorCode.getUserAction());
-            }
+                OMRSMetadataCollection   metadataCollection = 
cohortConnector.getMetadataCollection();
 
-            /*
-             * Process the retrieved metadata collection
-             */
-            try
-            {
-                List<TypeDef> results              = 
metadataCollection.searchForTypeDefs(userId, searchCriteria);
-                String        metadataCollectionId = 
metadataCollection.getMetadataCollectionId();
+                validateMetadataCollection(metadataCollection, methodName);
 
-                /*
-                 * Step through the list of returned TypeDefs and remove 
duplicates.
-                 */
-                if (results != null)
+                try
                 {
-                    for (TypeDef returnedTypeDef : results)
-                    {
-                        combinedResults = 
this.addUniqueTypeDef(combinedResults,
-                                                                
returnedTypeDef,
-                                                                
metadataCollectionId);
-                    }
+                    /*
+                     * Issue the request
+                     */
+                    List<TypeDef> results  = 
metadataCollection.searchForTypeDefs(userId, searchCriteria);
+
+                    /*
+                     * Step through the list of returned TypeDefs and remove 
duplicates.
+                     */
+                    combinedResults = this.addUniqueTypeDefs(combinedResults,
+                                                             results,
+                                                             
cohortConnector.getServerName(),
+                                                             
cohortConnector.getMetadataCollectionId(),
+                                                             methodName);
+                }
+                catch (RepositoryErrorException error)
+                {
+                    repositoryErrorException = error;
+                }
+                catch (UserNotAuthorizedException error)
+                {
+                    userNotAuthorizedException = error;
+                }
+                catch (Throwable error)
+                {
+                    anotherException = error;
                 }
-            }
-            catch (InvalidParameterException  error)
-            {
-                invalidParameterException = error;
-            }
-            catch (RepositoryErrorException  error)
-            {
-                repositoryErrorException = error;
-            }
-            catch (UserNotAuthorizedException  error)
-            {
-                userNotAuthorizedException = error;
-            }
-            catch (RuntimeException   error)
-            {
-                anotherException = error;
             }
         }
 
-        /*
-         * Return any results, or null if nothing is found.
-         */
-        if (combinedResults.size() > 0)
-        {
-            if 
(repositoryValidator.validateEnterpriseTypeDefs(enterpriseMetadataCollectionName,
 combinedResults))
-            {
-                return combinedResults;
-            }
-            else
-            {
-                OMRSErrorCode errorCode = 
OMRSErrorCode.CONFLICTING_ENTERPRISE_TYPEDEFS;
-                String errorMessage = errorCode.getErrorMessageId() + 
errorCode.getFormattedErrorMessage();
-
-                throw new 
RepositoryErrorException(errorCode.getHTTPErrorCode(),
-                                                   this.getClass().getName(),
-                                                   methodName,
-                                                   errorMessage,
-                                                   errorCode.getSystemAction(),
-                                                   errorCode.getUserAction());
-            }
-        }
-        else
-        {
-            if (userNotAuthorizedException != null)
-            {
-                throw userNotAuthorizedException;
-            }
-            else if (repositoryErrorException != null)
-            {
-                throw repositoryErrorException;
-            }
-            else if (invalidParameterException != null)
-            {
-                throw invalidParameterException;
-            }
-            else if (anotherException != null)
-            {
-                throw anotherException;
-            }
-            else
-            {
-                return null;
-            }
-        }
+        return validatedTypeDefListResults(repositoryName,
+                                           combinedResults,
+                                           userNotAuthorizedException,
+                                           repositoryErrorException,
+                                           anotherException,
+                                           methodName);
     }
 
 
@@ -1096,119 +846,78 @@ public class EnterpriseOMRSMetadataCollection extends 
OMRSMetadataCollection
                                                            
TypeDefNotKnownException,
                                                            
UserNotAuthorizedException
     {
-        final String    methodName = "getTypeDefByGUID()";
-
-        if (guid == null)
-        {
-            /*
-             * No guid supplied so can not perform the search
-             */
-            OMRSErrorCode errorCode = OMRSErrorCode.NO_GUID;
-            String errorMessage = errorCode.getErrorMessageId() + 
errorCode.getFormattedErrorMessage();
+        final String methodName        = "getTypeDefByGUID";
+        final String guidParameterName = "guid";
 
-            throw new InvalidParameterException(errorCode.getHTTPErrorCode(),
-                                                this.getClass().getName(),
-                                                methodName,
-                                                errorMessage,
-                                                errorCode.getSystemAction(),
-                                                errorCode.getUserAction());
-        }
+        /*
+         * Validate parameters
+         */
+        this.validateRepositoryConnector(methodName);
+        parentConnector.validateRepositoryIsActive(methodName);
 
-        List<OMRSMetadataCollection>  metadataCollections = 
parentConnector.getMetadataCollections();
+        repositoryValidator.validateUserId(repositoryName, userId, methodName);
+        repositoryValidator.validateTypeGUID(repositoryName, 
guidParameterName, guid, methodName);
 
-        if (metadataCollections == null)
-        {
-            /*
-             * No repositories available
-             */
-            OMRSErrorCode errorCode = OMRSErrorCode.NO_REPOSITORIES;
-            String errorMessage = errorCode.getErrorMessageId() + 
errorCode.getFormattedErrorMessage();
+        /*
+         * The list of cohort connectors are retrieved for each request to 
ensure that any changes in
+         * the shape of the cohort are reflected immediately.
+         */
+        List<OMRSRepositoryConnector> cohortConnectors = 
enterpriseParentConnector.getCohortConnectors(methodName);
 
-            throw new RepositoryErrorException(errorCode.getHTTPErrorCode(),
-                                               this.getClass().getName(),
-                                               methodName,
-                                               errorMessage,
-                                               errorCode.getSystemAction(),
-                                               errorCode.getUserAction());
-        }
-
-        TypeDefNotKnownException   typeDefNotKnownException = null;
+        /*
+         * Ready to process the request.  Search results need to come from all 
members of the cohort.
+         * They need to be combined and then duplicates removed to create the 
final list of results.
+         * Some repositories may produce exceptions.  These exceptions are 
saved and one selected to
+         * be returned if there are no results from any repository.
+         */
+        TypeDefNotKnownException   typeDefNotKnownException   = null;
         UserNotAuthorizedException userNotAuthorizedException = null;
-        RepositoryErrorException   repositoryErrorException = null;
-        RuntimeException           anotherException = null;
+        RepositoryErrorException   repositoryErrorException   = null;
+        Throwable                  anotherException           = null;
 
         /*
-         * Loop through the metadata collections requesting the typedef from 
each repository.
-         * The first TypeDef retrieved is returned to the caller.
+         * Loop through the metadata collections extracting the typedefs from 
each repository.
          */
-        for (OMRSMetadataCollection metadataCollection : metadataCollections)
+        for (OMRSRepositoryConnector cohortConnector : cohortConnectors)
         {
-            if (metadataCollection != null)
+            if (cohortConnector != null)
             {
+                OMRSMetadataCollection   metadataCollection = 
cohortConnector.getMetadataCollection();
+
+                validateMetadataCollection(metadataCollection, methodName);
+
                 try
                 {
-                    TypeDef retrievedTypeDef = getTypeDefByGUID(userId, guid);
-
-                    if (retrievedTypeDef != null)
-                    {
-                        return retrievedTypeDef;
-                    }
+                    /*
+                     * Issue the request and return if it succeeds
+                     */
+                    return metadataCollection.getTypeDefByGUID(userId, guid);
                 }
-                catch (TypeDefNotKnownException  error)
+                catch (TypeDefNotKnownException error)
                 {
                     typeDefNotKnownException = error;
                 }
-                catch (UserNotAuthorizedException error)
-                {
-                    userNotAuthorizedException = error;
-                }
                 catch (RepositoryErrorException error)
                 {
                     repositoryErrorException = error;
                 }
-                catch (RuntimeException error)
+                catch (UserNotAuthorizedException error)
+                {
+                    userNotAuthorizedException = error;
+                }
+                catch (Throwable error)
                 {
                     anotherException = error;
                 }
             }
         }
 
-        /*
-         * The TypeDef has not been found. Process the exceptions.
-         */
-        if (typeDefNotKnownException != null)
-        {
-            throw typeDefNotKnownException;
-        }
-        else if (userNotAuthorizedException != null)
-        {
-            throw userNotAuthorizedException;
-        }
-        else if (repositoryErrorException != null)
-        {
-            throw repositoryErrorException;
-        }
-        else if (anotherException != null)
-        {
-            throw anotherException;
-        }
-        else
-        {
-            /*
-             * All of the repositories have returned a null TypeDef so default 
to TypeDefNotKnownException.
-             */
-            // todo - bad parms for message
-            OMRSErrorCode errorCode = OMRSErrorCode.TYPEDEF_NOT_KNOWN;
-            String errorMessage = errorCode.getErrorMessageId() + 
errorCode.getFormattedErrorMessage(guid);
-
-            throw new TypeDefNotKnownException(errorCode.getHTTPErrorCode(),
-                                               this.getClass().getName(),
-                                               methodName,
-                                               errorMessage,
-                                               errorCode.getSystemAction(),
-                                               errorCode.getUserAction());
-        }
+        throwCapturedRepositoryErrorException(repositoryErrorException);
+        throwCapturedUserNotAuthorizedException(userNotAuthorizedException);
+        throwCapturedThrowableException(anotherException, methodName);
+        throwCapturedTypeDefNotKnownException(typeDefNotKnownException);
 
+        return null;
     }
 
 
@@ -1230,6 +939,81 @@ public class EnterpriseOMRSMetadataCollection extends 
OMRSMetadataCollection
                                                                               
TypeDefNotKnownException,
                                                                               
UserNotAuthorizedException
     {
+        final String methodName        = "getAttributeTypeDefByGUID";
+        final String guidParameterName = "guid";
+
+        /*
+         * Validate parameters
+         */
+        this.validateRepositoryConnector(methodName);
+        parentConnector.validateRepositoryIsActive(methodName);
+
+        repositoryValidator.validateUserId(repositoryName, userId, methodName);
+        repositoryValidator.validateTypeGUID(repositoryName, 
guidParameterName, guid, methodName);
+
+        /*
+         * The list of cohort connectors are retrieved for each request to 
ensure that any changes in
+         * the shape of the cohort are reflected immediately.
+         */
+        List<OMRSRepositoryConnector> cohortConnectors = 
enterpriseParentConnector.getCohortConnectors(methodName);
+
+        /*
+         * Ready to process the request.  Search results need to come from all 
members of the cohort.
+         * They need to be combined and then duplicates removed to create the 
final list of results.
+         * Some repositories may produce exceptions.  These exceptions are 
saved and one selected to
+         * be returned if there are no results from any repository.
+         */
+        TypeDefNotKnownException   typeDefNotKnownException   = null;
+        UserNotAuthorizedException userNotAuthorizedException = null;
+        RepositoryErrorException   repositoryErrorException   = null;
+        Throwable                  anotherException           = null;
+
+        /*
+         * Loop through the metadata collections extracting the typedefs from 
each repository.
+         */
+        for (OMRSRepositoryConnector cohortConnector : cohortConnectors)
+        {
+            if (cohortConnector != null)
+            {
+                OMRSMetadataCollection   metadataCollection = 
cohortConnector.getMetadataCollection();
+
+                validateMetadataCollection(metadataCollection, methodName);
+
+                try
+                {
+                    /*
+                     * Issue the request and return if it succeeds
+                     */
+                    return 
metadataCollection.getAttributeTypeDefByGUID(userId, guid);
+                }
+                catch (TypeDefNotKnownException error)
+                {
+                    typeDefNotKnownException = error;
+                }
+                catch (RepositoryErrorException error)
+                {
+                    repositoryErrorException = error;
+                }
+                catch (UserNotAuthorizedException error)
+                {
+                    userNotAuthorizedException = error;
+                }
+                catch (Throwable error)
+                {
+                    anotherException = error;
+                }
+            }
+        }
+
+        throwCapturedRepositoryErrorException(repositoryErrorException);
+        throwCapturedUserNotAuthorizedException(userNotAuthorizedException);
+        throwCapturedThrowableException(anotherException, methodName);
+
+        if (typeDefNotKnownException != null)
+        {
+            throw typeDefNotKnownException;
+        }
+
         return null;
     }
 
@@ -1251,118 +1035,78 @@ public class EnterpriseOMRSMetadataCollection extends 
OMRSMetadataCollection
                                                            
TypeDefNotKnownException,
                                                            
UserNotAuthorizedException
     {
-        final String    methodName = "getTypeDefByName()";
-
-        if (name == null)
-        {
-            /*
-             * No name supplied so can not perform the search
-             */
-            OMRSErrorCode errorCode = OMRSErrorCode.NO_TYPEDEF_NAME;
-            String errorMessage = errorCode.getErrorMessageId() + 
errorCode.getFormattedErrorMessage();
-
-            throw new InvalidParameterException(errorCode.getHTTPErrorCode(),
-                                                this.getClass().getName(),
-                                                methodName,
-                                                errorMessage,
-                                                errorCode.getSystemAction(),
-                                                errorCode.getUserAction());
-        }
+        final String  methodName = "getTypeDefByName";
+        final String  nameParameterName = "name";
 
-        List<OMRSMetadataCollection>  metadataCollections = 
parentConnector.getMetadataCollections();
+        /*
+         * Validate parameters
+         */
+        this.validateRepositoryConnector(methodName);
+        parentConnector.validateRepositoryIsActive(methodName);
 
-        if (metadataCollections == null)
-        {
-            /*
-             * No repositories available
-             */
-            OMRSErrorCode errorCode = OMRSErrorCode.NO_REPOSITORIES;
-            String errorMessage = errorCode.getErrorMessageId() + 
errorCode.getFormattedErrorMessage();
+        repositoryValidator.validateUserId(repositoryName, userId, methodName);
+        repositoryValidator.validateTypeName(repositoryName, 
nameParameterName, name, methodName);
 
-            throw new RepositoryErrorException(errorCode.getHTTPErrorCode(),
-                                               this.getClass().getName(),
-                                               methodName,
-                                               errorMessage,
-                                               errorCode.getSystemAction(),
-                                               errorCode.getUserAction());
-        }
+        /*
+         * The list of cohort connectors are retrieved for each request to 
ensure that any changes in
+         * the shape of the cohort are reflected immediately.
+         */
+        List<OMRSRepositoryConnector> cohortConnectors = 
enterpriseParentConnector.getCohortConnectors(methodName);
 
-        TypeDefNotKnownException   typeDefNotKnownException = null;
+        /*
+         * Ready to process the request.  Search results need to come from all 
members of the cohort.
+         * They need to be combined and then duplicates removed to create the 
final list of results.
+         * Some repositories may produce exceptions.  These exceptions are 
saved and one selected to
+         * be returned if there are no results from any repository.
+         */
+        TypeDefNotKnownException   typeDefNotKnownException   = null;
         UserNotAuthorizedException userNotAuthorizedException = null;
-        RepositoryErrorException   repositoryErrorException = null;
-        RuntimeException           anotherException = null;
+        RepositoryErrorException   repositoryErrorException   = null;
+        Throwable                  anotherException           = null;
 
         /*
-         * Loop through the metadata collections requesting the typedef from 
each repository.
-         * The first TypeDef retrieved is returned to the caller.
+         * Loop through the metadata collections extracting the typedefs from 
each repository.
          */
-        for (OMRSMetadataCollection metadataCollection : metadataCollections)
+        for (OMRSRepositoryConnector cohortConnector : cohortConnectors)
         {
-            if (metadataCollection != null)
+            if (cohortConnector != null)
             {
+                OMRSMetadataCollection   metadataCollection = 
cohortConnector.getMetadataCollection();
+
+                validateMetadataCollection(metadataCollection, methodName);
+
                 try
                 {
-                    TypeDef retrievedTypeDef = getTypeDefByName(userId, name);
-
-                    if (retrievedTypeDef != null)
-                    {
-                        return retrievedTypeDef;
-                    }
+                    /*
+                     * Issue the request and return if it succeeds
+                     */
+                    return metadataCollection.getTypeDefByName(userId, name);
                 }
-                catch (TypeDefNotKnownException  error)
+                catch (TypeDefNotKnownException error)
                 {
                     typeDefNotKnownException = error;
                 }
-                catch (UserNotAuthorizedException error)
-                {
-                    userNotAuthorizedException = error;
-                }
                 catch (RepositoryErrorException error)
                 {
                     repositoryErrorException = error;
                 }
-                catch (RuntimeException error)
+                catch (UserNotAuthorizedException error)
+                {
+                    userNotAuthorizedException = error;
+                }
+                catch (Throwable error)
                 {
                     anotherException = error;
                 }
             }
         }
 
-        /*
-         * The TypeDef has not been found. Process the exceptions.
-         */
-        if (typeDefNotKnownException != null)
-        {
-            throw typeDefNotKnownException;
-        }
-        else if (userNotAuthorizedException != null)
-        {
-            throw userNotAuthorizedException;
-        }
-        else if (repositoryErrorException != null)
-        {
-            throw repositoryErrorException;
-     

<TRUNCATED>

Reply via email to