http://git-wip-us.apache.org/repos/asf/atlas/blob/68b47923/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 deleted file mode 100644 index 5b0165f..0000000 --- a/omrs/src/main/java/org/apache/atlas/omrs/enterprise/repositoryconnector/EnterpriseOMRSMetadataCollection.java +++ /dev/null @@ -1,6737 +0,0 @@ -/* - * 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 - * <p/> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p/> - * 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.atlas.omrs.enterprise.repositoryconnector; - -import org.apache.atlas.omrs.ffdc.OMRSErrorCode; -import org.apache.atlas.omrs.ffdc.exception.*; -import org.apache.atlas.omrs.localrepository.repositorycontentmanager.OMRSRepositoryHelper; -import org.apache.atlas.omrs.localrepository.repositorycontentmanager.OMRSRepositoryValidator; -import org.apache.atlas.omrs.metadatacollection.OMRSMetadataCollection; -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; - - -/** - * EnterpriseOMRSMetadataCollection executes the calls to the open metadata repositories registered - * with the OMRSEnterpriseConnectorManager. The effect is a federated view over these open metadata - * repositories. - * <p> - * EnterpriseOMRSMetadataCollection is part of an EnterpriseOMRSRepositoryConnector. The EnterpriseOMRSRepositoryConnector - * holds the list of OMRS Connectors, one for each of the metadata repositories. This list may change - * over time as metadata repositories register and deregister with the connected cohorts. - * The EnterpriseOMRSRepositoryConnector is responsible for keeping the list of connectors up-to-date through - * contact with the OMRSEnterpriseConnectorManager. - * </p> - * <p> - * When a request is made to the EnterpriseOMRSMetadataCollection, it calls the EnterpriseOMRSRepositoryConnector - * to request the appropriate list of metadata collection for the request. Then the EnterpriseOMRSConnector - * calls the appropriate remote connectors. - * </p> - * <p> - * The first OMRS Connector in the list is the OMRS Repository Connector for the "local" repository. - * The local repository is favoured when new metadata is to be created, unless the type of metadata - * is not supported by the local repository. In which case, the EnterpriseOMRSMetadataCollection searches its - * list looking for the first metadata repository that supports the metadata type and stores it there. - * </p> - * <p> - * Updates and deletes are routed to the owning (home) repository. Searches are made to each repository in turn - * and the duplicates are removed. Queries are directed to the local repository and then the remote repositories - * until all of the requested metadata is assembled. - * </p> - */ -public class EnterpriseOMRSMetadataCollection extends OMRSMetadataCollection -{ - - /* - * Private variables for a metadata collection instance - */ - private EnterpriseOMRSRepositoryConnector enterpriseParentConnector; - - - /** - * Constructor ensures the metadata collection is linked to its connector and knows its metadata collection Id. - * - * @param enterpriseParentConnector - connector that this metadata collection supports. The connector has the information - * to call the metadata repository. - * @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 enterpriseParentConnector, - String repositoryName, - OMRSRepositoryHelper repositoryHelper, - OMRSRepositoryValidator repositoryValidator, - String metadataCollectionId) - { - /* - * The metadata collection Id is the unique identifier for the metadata collection. It is managed by the super class. - */ - super(enterpriseParentConnector, repositoryName, metadataCollectionId, repositoryHelper, repositoryValidator); - - /* - * Save enterpriseParentConnector since this has the connection information and - * access to the metadata about the open metadata repository cohort. - */ - 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; - } - - - /* ============================== - * Group 2: Working with typedefs - */ - - /** - * Returns the list of different types of metadata organized into two groups. The first are the - * attribute type definitions (AttributeTypeDefs). These provide types for properties in full - * type definitions. Full type definitions (TypeDefs) describe types for entities, relationships - * and classifications. - * - * @param userId - unique identifier for requesting user. - * @return TypeDefs - List of different categories of TypeDefs. - * @throws RepositoryErrorException - there is a problem communicating with the metadata repository. - * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation. - */ - public TypeDefGallery getAllTypes(String userId) throws RepositoryErrorException, - UserNotAuthorizedException - { - final String methodName = "getAllTypes"; - - /* - * Validate parameters - */ - this.validateRepositoryConnector(methodName); - parentConnector.validateRepositoryIsActive(methodName); - - 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); - - - /* - * 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> combinedTypeDefResults = new HashMap<>(); - HashMap<String, AttributeTypeDef> combinedAttributeTypeDefResults = 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 (cohortConnector != null) - { - OMRSMetadataCollection metadataCollection = cohortConnector.getMetadataCollection(); - - validateMetadataCollection(metadataCollection, methodName); - - try - { - /* - * Issue the request - */ - TypeDefGallery results = metadataCollection.getAllTypes(userId); - - /* - * Step through the list of returned TypeDefs and consolidate. - */ - if (results != null) - { - 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 (Throwable error) - { - anotherException = error; - } - } - } - - return validatedTypeDefGalleryResults(repositoryName, - combinedTypeDefResults, - combinedAttributeTypeDefResults, - userNotAuthorizedException, - repositoryErrorException, - anotherException, - methodName); - } - - - /** - * Returns a list of type definitions that have the specified name. Type names should be unique. This - * method allows wildcard character to be included in the name. These are * (asterisk) for an - * arbitrary string of characters and ampersand for an arbitrary character. - * - * @param userId - unique identifier for requesting user. - * @param name - name of the TypeDefs to return (including wildcard characters). - * @return TypeDefs list. - * @throws InvalidParameterException - the name of the TypeDef 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 TypeDefGallery findTypesByName(String userId, - String name) throws InvalidParameterException, - RepositoryErrorException, - UserNotAuthorizedException - { - final String methodName = "findTypesByName"; - final String nameParameterName = "name"; - - /* - * Validate parameters - */ - this.validateRepositoryConnector(methodName); - parentConnector.validateRepositoryIsActive(methodName); - - repositoryValidator.validateUserId(repositoryName, userId, methodName); - repositoryValidator.validateTypeName(repositoryName, nameParameterName, name, 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> combinedTypeDefResults = new HashMap<>(); - HashMap<String, AttributeTypeDef> combinedAttributeTypeDefResults = 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 (cohortConnector != null) - { - OMRSMetadataCollection metadataCollection = cohortConnector.getMetadataCollection(); - - validateMetadataCollection(metadataCollection, methodName); - - try - { - /* - * Issue the request - */ - TypeDefGallery results = metadataCollection.findTypesByName(userId, name); - - /* - * Step through the list of returned TypeDefs and consolidate. - */ - if (results != null) - { - 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 (Throwable error) - { - anotherException = error; - } - } - } - - return validatedTypeDefGalleryResults(repositoryName, - combinedTypeDefResults, - combinedAttributeTypeDefResults, - userNotAuthorizedException, - repositoryErrorException, - anotherException, - methodName); - } - - - /** - * Returns all of the TypeDefs for a specific category. - * - * @param userId - unique identifier for requesting user. - * @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 category) throws InvalidParameterException, - RepositoryErrorException, - UserNotAuthorizedException - { - final String methodName = "findTypeDefsByCategory"; - final String categoryParameterName = "category"; - - /* - * Validate parameters - */ - this.validateRepositoryConnector(methodName); - parentConnector.validateRepositoryIsActive(methodName); - - repositoryValidator.validateUserId(repositoryName, userId, methodName); - repositoryValidator.validateTypeDefCategory(repositoryName, categoryParameterName, category, 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 (cohortConnector != null) - { - OMRSMetadataCollection metadataCollection = cohortConnector.getMetadataCollection(); - - validateMetadataCollection(metadataCollection, methodName); - - try - { - /* - * 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; - } - } - } - - return validatedTypeDefListResults(repositoryName, - combinedResults, - userNotAuthorizedException, - repositoryErrorException, - anotherException, - methodName); - } - - - /** - * Returns all of the AttributeTypeDefs for a specific category. - * - * @param userId - unique identifier for requesting user. - * @param category - enum value for the category of an AttributeTypeDef 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<AttributeTypeDef> findAttributeTypeDefsByCategory(String userId, - AttributeTypeDefCategory category) throws InvalidParameterException, - RepositoryErrorException, - UserNotAuthorizedException - { - final String methodName = "findAttributeTypeDefsByCategory"; - final String categoryParameterName = "category"; - - /* - * Validate parameters - */ - this.validateRepositoryConnector(methodName); - parentConnector.validateRepositoryIsActive(methodName); - - repositoryValidator.validateUserId(repositoryName, userId, methodName); - repositoryValidator.validateAttributeTypeDefCategory(repositoryName, categoryParameterName, category, 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, AttributeTypeDef> 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 (cohortConnector != null) - { - OMRSMetadataCollection metadataCollection = cohortConnector.getMetadataCollection(); - - validateMetadataCollection(metadataCollection, methodName); - - try - { - /* - * 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; - } - } - } - - 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"; - - /* - * Validate parameters - */ - 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 (cohortConnector != 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); - } - - - /** - * Return the types that are linked to the elements from the specified standard. - * - * @param userId - unique identifier for requesting user. - * @param standard - name of the standard - null means any. - * @param organization - name of the organization - null means any. - * @param identifier - identifier of the element in the standard - null means any. - * @return TypeDefs list - each entry in the list contains a typedef. This is is a structure - * describing the TypeDef's category and properties. - * @throws InvalidParameterException - all attributes of the external Id are 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> findTypesByExternalID(String userId, - String standard, - String organization, - String identifier) throws InvalidParameterException, - RepositoryErrorException, - UserNotAuthorizedException - { - 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); - - /* - * 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) - { - if (cohortConnector != null) - { - OMRSMetadataCollection metadataCollection = cohortConnector.getMetadataCollection(); - - validateMetadataCollection(metadataCollection, methodName); - - 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 validatedTypeDefListResults(repositoryName, - combinedResults, - userNotAuthorizedException, - repositoryErrorException, - anotherException, - methodName); - } - - - /** - * Return the TypeDefs that match the search criteria. - * - * @param userId - unique identifier for requesting user. - * @param searchCriteria - String - search criteria. - * @return TypeDefs list - each entry in the list contains a typedef. This is is a structure - * describing the TypeDef's category and properties. - * @throws InvalidParameterException - the searchCriteria 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> searchForTypeDefs(String userId, - String searchCriteria) throws InvalidParameterException, - RepositoryErrorException, - UserNotAuthorizedException - { - final String methodName = "searchForTypeDefs"; - final String searchCriteriaParameterName = "searchCriteria"; - - /* - * Validate parameters - */ - this.validateRepositoryConnector(methodName); - parentConnector.validateRepositoryIsActive(methodName); - - repositoryValidator.validateUserId(repositoryName, userId, methodName); - repositoryValidator.validateSearchCriteria(repositoryName, searchCriteriaParameterName, searchCriteria, 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 (cohortConnector != null) - { - OMRSMetadataCollection metadataCollection = cohortConnector.getMetadataCollection(); - - validateMetadataCollection(metadataCollection, methodName); - - try - { - /* - * 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; - } - } - } - - return validatedTypeDefListResults(repositoryName, - combinedResults, - userNotAuthorizedException, - repositoryErrorException, - anotherException, - methodName); - } - - - /** - * Return the TypeDef identified by the GUID. - * - * @param userId - unique identifier for requesting user. - * @param guid - String unique Id of the TypeDef - * @return TypeDef structure describing its category and properties. - * @throws InvalidParameterException - the guid is null. - * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where - * the metadata collection is stored. - * @throws TypeDefNotKnownException - The requested TypeDef is not known in the metadata collection. - * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation. - */ - public TypeDef getTypeDefByGUID(String userId, - String guid) throws InvalidParameterException, - RepositoryErrorException, - TypeDefNotKnownException, - UserNotAuthorizedException - { - final String methodName = "getTypeDefByGUID"; - final String guidParameterName = "guid"; - - /* - * Validate parameters - */ - this.validateRepositoryConnector(methodName); - parentConnector.validateRepositoryIsActive(methodName); - - repositoryValidator.validateUserId(repositoryName, userId, methodName); - repositoryValidator.validateGUID(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.getTypeDefByGUID(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); - throwCapturedTypeDefNotKnownException(typeDefNotKnownException); - - return null; - } - - - /** - * Return the AttributeTypeDef identified by the GUID. - * - * @param userId - unique identifier for requesting user. - * @param guid - String unique id of the TypeDef - * @return TypeDef structure describing its category and properties. - * @throws InvalidParameterException - the guid is null. - * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where - * the metadata collection is stored. - * @throws TypeDefNotKnownException - The requested TypeDef is not known in the metadata collection. - * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation. - */ - public AttributeTypeDef getAttributeTypeDefByGUID(String userId, - String guid) throws InvalidParameterException, - RepositoryErrorException, - TypeDefNotKnownException, - UserNotAuthorizedException - { - final String methodName = "getAttributeTypeDefByGUID"; - final String guidParameterName = "guid"; - - /* - * Validate parameters - */ - this.validateRepositoryConnector(methodName); - parentConnector.validateRepositoryIsActive(methodName); - - repositoryValidator.validateUserId(repositoryName, userId, methodName); - repositoryValidator.validateGUID(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; - } - - - /** - * Return the TypeDef identified by the unique name. - * - * @param userId - unique identifier for requesting user. - * @param name - String name of the TypeDef. - * @return TypeDef structure describing its category and properties. - * @throws InvalidParameterException - the name is null. - * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where - * the metadata collection is stored. - * @throws TypeDefNotKnownException - the requested TypeDef is not found in the metadata collection. - */ - public TypeDef getTypeDefByName(String userId, - String name) throws InvalidParameterException, - RepositoryErrorException, - TypeDefNotKnownException, - UserNotAuthorizedException - { - final String methodName = "getTypeDefByName"; - final String nameParameterName = "name"; - - /* - * Validate parameters - */ - this.validateRepositoryConnector(methodName); - parentConnector.validateRepositoryIsActive(methodName); - - repositoryValidator.validateUserId(repositoryName, userId, methodName); - repositoryValidator.validateTypeName(repositoryName, nameParameterName, name, 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.getTypeDefByName(userId, name); - } - 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); - throwCapturedTypeDefNotKnownException(typeDefNotKnownException); - - return null; - } - - - /** - * Return the AttributeTypeDef identified by the unique name. - * - * @param userId - unique identifier for requesting user. - * @param name - String name of the TypeDef. - * @return TypeDef structure describing its category and properties. - * @throws InvalidParameterException - the name is null. - * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where - * the metadata collection is stored. - * @throws TypeDefNotKnownException - the requested TypeDef is not found in the metadata collection. - * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation. - */ - public AttributeTypeDef getAttributeTypeDefByName(String userId, - String name) throws InvalidParameterException, - RepositoryErrorException, - TypeDefNotKnownException, - UserNotAuthorizedException - { - final String methodName = "getAttributeTypeDefByName"; - final String nameParameterName = "name"; - - /* - * Validate parameters - */ - this.validateRepositoryConnector(methodName); - parentConnector.validateRepositoryIsActive(methodName); - - repositoryValidator.validateUserId(repositoryName, userId, methodName); - repositoryValidator.validateTypeName(repositoryName, nameParameterName, name, 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.getAttributeTypeDefByName(userId, name); - } - 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); - throwCapturedTypeDefNotKnownException(typeDefNotKnownException); - - return null; - } - - - /** - * Create a collection of related types. - * - * @param userId - unique identifier for requesting user. - * @param newTypes - TypeDefGalleryResponse structure describing the new AttributeTypeDefs and TypeDefs. - * @throws FunctionNotSupportedException - the repository does not support this call. - */ - public void addTypeDefGallery(String userId, - TypeDefGallery newTypes) throws FunctionNotSupportedException - - { - final String methodName = "addTypeDefGallery()"; - - throwNotEnterpriseFunction(methodName); - } - - - /** - * Create a definition of a new TypeDef. This new TypeDef is pushed to each repository that will accept it. - * An exception is passed to the caller if the TypeDef is invalid, or if none of the repositories accept it. - * - * @param userId - unique identifier for requesting user. - * @param newTypeDef - TypeDef structure describing the new TypeDef. - * @throws FunctionNotSupportedException - the repository does not support this call. - */ - public void addTypeDef(String userId, - TypeDef newTypeDef) throws FunctionNotSupportedException - { - final String methodName = "addTypeDef()"; - - throwNotEnterpriseFunction(methodName); - } - - - /** - * Create a definition of a new AttributeTypeDef. - * - * @param userId - unique identifier for requesting user. - * @param newAttributeTypeDef - TypeDef structure describing the new TypeDef. - * @throws FunctionNotSupportedException - the repository does not support this call. - */ - public void addAttributeTypeDef(String userId, - AttributeTypeDef newAttributeTypeDef) throws FunctionNotSupportedException - { - final String methodName = "addAttributeTypeDef()"; - - throwNotEnterpriseFunction(methodName); - } - - - /** - * Verify that a definition of a TypeDef is either new - or matches the definition already stored. - * - * @param userId - unique identifier for requesting user. - * @param typeDef - TypeDef structure describing the TypeDef to test. - * @return boolean - true means the TypeDef matches the local definition - false means the TypeDef is not known. - * @throws InvalidParameterException - the TypeDef is null. - * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where - * the metadata collection is stored. - * @throws TypeDefNotSupportedException - the repository is not able to support this TypeDef. - * @throws TypeDefConflictException - the new TypeDef conflicts with an existing TypeDef. - * @throws InvalidTypeDefException - the new TypeDef has invalid contents. - * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation. - */ - public boolean verifyTypeDef(String userId, - TypeDef typeDef) throws InvalidParameterException, - RepositoryErrorException, - TypeDefNotSupportedException, - TypeDefConflictException, - InvalidTypeDefException, - UserNotAuthorizedException - { - final String methodName = "verifyTypeDef"; - final String typeDefParameterName = "typeDef"; - - /* - * Validate parameters - */ - this.validateRepositoryConnector(methodName); - parentConnector.validateRepositoryIsActive(methodName); - - repositoryValidator.validateUserId(repositoryName, userId, methodName); - repositoryValidator.validateTypeDef(repositoryName, typeDefParameterName, typeDef, 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. - */ - TypeDefNotSupportedException typeDefNotSupportedException = 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 (TypeDefConflictException is also returned - * immediately.) - */ - return metadataCollection.verifyTypeDef(userId, typeDef); - } - catch (TypeDefNotSupportedException error) - { - typeDefNotSupportedException = error; - } - catch (RepositoryErrorException error) - { - repositoryErrorException = error; - } - catch (UserNotAuthorizedException error) - { - userNotAuthorizedException = error; - } - catch (Throwable error) - { - anotherException = error; - } - } - } - - throwCapturedRepositoryErrorException(repositoryErrorException); - throwCapturedUserNotAuthorizedException(userNotAuthorizedException); - throwCapturedThrowableException(anotherException, methodName); - throwCapturedTypeDefNotSupportedException(typeDefNotSupportedException); - - return false; - } - - - /** - * Verify that a definition of an AttributeTypeDef is either new - or matches the definition already stored. - * - * @param userId - unique identifier for requesting user. - * @param attributeTypeDef - TypeDef structure describing the TypeDef to test. - * @return boolean - true means the TypeDef matches the local definition - false means the TypeDef is not known. - * @throws InvalidParameterException - the TypeDef is null. - * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where - * the metadata collection is stored. - * @throws TypeDefNotSupportedException - the repository is not able to support this TypeDef. - * @throws TypeDefConflictException - the new TypeDef conflicts with an existing TypeDef. - * @throws InvalidTypeDefException - the new TypeDef has invalid contents. - * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation. - */ - public boolean verifyAttributeTypeDef(String userId, - AttributeTypeDef attributeTypeDef) throws InvalidParameterException, - RepositoryErrorException, - TypeDefNotSupportedException, - TypeDefConflictException, - InvalidTypeDefException, - UserNotAuthorizedException - { - final String methodName = "verifyAttributeTypeDef"; - final String typeDefParameterName = "attributeTypeDef"; - - /* - * Validate parameters - */ - this.validateRepositoryConnector(methodName); - parentConnector.validateRepositoryIsActive(methodName); - - repositoryValidator.validateUserId(repositoryName, userId, methodName); - repositoryValidator.validateAttributeTypeDef(repositoryName, typeDefParameterName, attributeTypeDef, 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. - */ - TypeDefNotSupportedException typeDefNotSupportedException = 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 (TypeDefConflictException is also returned - * immediately.) - */ - return metadataCollection.verifyAttributeTypeDef(userId, attributeTypeDef); - } - catch (TypeDefNotSupportedException error) - { - typeDefNotSupportedException = error; - } - catch (RepositoryErrorException error) - { - repositoryErrorException = error; - } - catch (UserNotAuthorizedException error) - { - userNotAuthorizedException = error; - } - catch (Throwable error) - { - anotherException = error; - } - } - } - - throwCapturedRepositoryErrorException(repositoryErrorException); - throwCapturedUserNotAuthorizedException(userNotAuthorizedException); - throwCapturedThrowableException(anotherException, methodName); - throwCapturedTypeDefNotSupportedException(typeDefNotSupportedException); - - return false; - } - - - /** - * Update one or more properties of the TypeDef. The TypeDefPatch controls what types of updates - * are safe to make to the TypeDef. - * - * @param userId - unique identifier for requesting user. - * @param typeDefPatch - TypeDef patch describing change to TypeDef. - * @return updated TypeDef - * @throws FunctionNotSupportedException - the repository does not support this call. - - */ - public TypeDef updateTypeDef(String userId, - TypeDefPatch typeDefPatch) throws FunctionNotSupportedException - { - final String methodName = "updateTypeDef()"; - - throwNotEnterpriseFunction(methodName); - - return null; - } - - - /** - * Delete the TypeDef. This is only possible if the TypeDef has never been used to create instances or any - * instances of this TypeDef have been purged from the metadata collection. - * - * @param userId - unique identifier for requesting user. - * @param obsoleteTypeDefGUID - String unique identifier for the TypeDef. - * @param obsoleteTypeDefName - String unique name for the TypeDef. - * @throws FunctionNotSupportedException - the repository does not support this call. - */ - public void deleteTypeDef(String userId, - String obsoleteTypeDefGUID, - String obsoleteTypeDefName) throws FunctionNotSupportedException - { - final String methodName = "deleteTypeDef()"; - - throwNotEnterpriseFunction(methodName); - } - - - /** - * Delete an AttributeTypeDef. This is only possible if the AttributeTypeDef has never been used to create - * instances or any instances of this AttributeTypeDef have been purged from the metadata collection. - * - * @param userId - unique identifier for requesting user. - * @param obsoleteTypeDefGUID - String unique identifier for the AttributeTypeDef. - * @param obsoleteTypeDefName - String unique name for the AttributeTypeDef. - * @throws FunctionNotSupportedException - the repository does not support this call. - */ - public void deleteAttributeTypeDef(String userId, - String obsoleteTypeDefGUID, - String obsoleteTypeDefName) throws FunctionNotSupportedException - { - final String methodName = "deleteAttributeTypeDef()"; - - throwNotEnterpriseFunction(methodName); - } - - - /** - * Change the guid or name of an existing TypeDef to a new value. This is used if two different - * TypeDefs are discovered to have the same guid. This is extremely unlikely but not impossible so - * the open metadata protocol has provision for this. - * - * @param userId - unique identifier for requesting user. - * @param originalTypeDefGUID - the original guid of the TypeDef. - * @param originalTypeDefName - the original name of the TypeDef. - * @param newTypeDefGUID - the new identifier for the TypeDef. - * @param newTypeDefName - new name for this TypeDef. - * @return typeDef - new values for this TypeDef, including the new guid/name. - * @throws FunctionNotSupportedException - the repository does not support this call. - */ - public TypeDef reIdentifyTypeDef(String userId, - String originalTypeDefGUID, - String originalTypeDefName, - String newTypeDefGUID, - String newTypeDefName) throws FunctionNotSupportedException - { - final String methodName = "reIdentifyTypeDef()"; - - throwNotEnterpriseFunction(methodName); - - return null; - } - - - /** - * Change the guid or name of an existing TypeDef to a new value. This is used if two different - * TypeDefs are discovered to have the same guid. This is extremely unlikely but not impossible so - * the open metadata protocol has provision for this. - * - * @param userId - unique identifier for requesting user. - * @param originalAttributeTypeDefGUID - the original guid of the AttributeTypeDef. - * @param originalAttributeTypeDefName - the original name of the AttributeTypeDef. - * @param newAttributeTypeDefGUID - the new identifier for the AttributeTypeDef. - * @param newAttributeTypeDefName - new name for this AttributeTypeDef. - * @return attributeTypeDef - new values for this AttributeTypeDef, including the new guid/name. - * @throws FunctionNotSupportedException - the repository does not support this call. - */ - public AttributeTypeDef reIdentifyAttributeTypeDef(String userId, - String originalAttributeTypeDefGUID, - String originalAttributeTypeDefName, - String newAttributeTypeDefGUID, - String newAttributeTypeDefName) throws FunctionNotSupportedException - { - final String methodName = "reIdentifyAttributeTypeDef()"; - - throwNotEnterpriseFunction(methodName); - - return null; - } - - - /* =================================================== - * Group 3: Locating entity and relationship instances - */ - - - /** - * Returns a boolean indicating if the entity is stored in the metadata collection. This entity may be a full - * entity object, or an entity proxy. - * - * @param userId - unique identifier for requesting user. - * @param guid - String unique identifier for the entity - * @return the entity details if the entity is found in the metadata collection; otherwise return null - * @throws InvalidParameterException - the guid is null. - * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where - * the metadata collection is stored. - * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation. - */ - public EntityDetail isEntityKnown(String userId, - String guid) throws InvalidParameterException, - RepositoryErrorException, - UserNotAuthorizedException - { - final String methodName = "isEntityKnown"; - final String guidParameterName = "guid"; - - /* - * Validate parameters - */ - this.validateRepositoryConnector(methodName); - parentConnector.validateRepositoryIsActive(methodName); - - repositoryValidator.validateUserId(repositoryName, userId, methodName); - repositoryValidator.validateGUID(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. - */ - 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 - */ - EntityDetail entity = this.isEntityKnown(userId, guid); - - repositoryValidator.validateEntityFromStore(repositoryName, guid, entity, methodName); - - return entity; - } - - catch (RepositoryErrorException error) - { - repositoryErrorException = error; - } - catch (UserNotAuthorizedException error) - { - userNotAuthorizedException = error; - } - catch (Throwable error) - { - anotherException = error; - } - } - } - - throwCapturedRepositoryErrorException(repositoryErrorException); - throwCapturedUserNotAuthorizedException(userNotAuthorizedException); - throwCapturedThrowableException(anotherException, methodName); - - return null; - } - - - /** - * Return the header and classifications for a specific entity. The returned entity summary may be from - * a full entity object or an entity proxy. - * - * @param userId - unique identifier for requesting user. - * @param guid - String unique identifier for the entity - * @return EntitySummary structure - * @throws InvalidParameterException - the guid is null. - * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where - * the metadata collection is stored. - * @throws EntityNotKnownException - the requested entity instance is not known in the metadata collection. - * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation. - */ - public EntitySummary getEntitySummary(String userId, - String guid) throws InvalidParameterException, - RepositoryErrorException, - EntityNotKnownException, - UserNotAuthorizedException - { - final String methodName = "getEntitySummary"; - final String guidParameterName = "guid"; - - /* - * Validate parameters - */ - this.validateRepositoryConnector(methodName); - parentConnector.validateRepositoryIsActive(methodName); - - repositoryValidator.validateUserId(repositoryName, userId, methodName); - repositoryValidator.validateGUID(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. - */ - EntityNotKnownException entityNotKnownException = 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 - */ - EntitySummary entity = this.getEntitySummary(userId, guid); - - repositoryValidator.validateEntityFromStore(repositoryName, guid, entity, methodName); - - return entity; - } - catch (EntityNotKnownException error) - { - entityNotKnownException = error; - } - catch (RepositoryErrorException error) - { - repositoryErrorException = error; - } - catch (UserNotAuthorizedException error) - { - userNotAuthorizedException = error; - } - catch (Throwable error) - { - anotherException = error; - } - } - } - - throwCapturedRepositoryErrorException(repositoryErrorException); - throwCapturedUserNotAuthorizedException(userNotAuthorizedException); - throwCapturedThrowableException(anotherException, methodName); - throwCapturedEntityNotKnownException(entityNotKnownException); - - return null; - } - - - /** - * Return the header, classifications and properties of a specific entity. - * - * @param userId - unique identifier for requesting user. - * @param guid - String unique identifier for the entity. - * @return EntityDetail structure. - * @throws InvalidParameterException - the guid is null. - * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where - * the metadata collection is stored. - * @throws EntityNotKnownException - the requested entity instance is not known in the metadata collection. - * @throws EntityProxyOnlyException - the requested entity instance is only a proxy in the metadata collection. - * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation. - */ - public EntityDetail getEntityDetail(String userId, - String guid) throws InvalidParameterException, - RepositoryErrorException, - EntityNotKnownException, - EntityProxyOnlyException, - UserNotAuthorizedException - { - final String methodName = "getEntityDetail"; - final String guidParameterName = "guid"; - - /* - * Validate parameters - */ - this.validateRepositoryConnector(methodName); - parentConnector.validateRepositoryIsActive(methodName); - - repositoryValidator.validateUserId(repositoryName, userId, methodName); - repositoryValidator.validateGUID(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. - */ - EntityNotKnownException entityNotKnownException = null; - EntityProxyOnlyException entityProxyOnlyException = 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 - */ - EntityDetail entity = this.getEntityDetail(userId, guid); - - repositoryValidator.validateEntityFromStore(repositoryName, guid, entity, methodName); - - return entity; - } - catch (EntityNotKnownException error) - { - entityNotKnownException = error; - } - catch (EntityProxyOnlyException error) - { - entityProxyOnlyException = error; -
<TRUNCATED>
