ATLAS-2585 Fix up validation of TypDef GUIDs Signed-off-by: David Radley <[email protected]>
Project: http://git-wip-us.apache.org/repos/asf/atlas/repo Commit: http://git-wip-us.apache.org/repos/asf/atlas/commit/5cfb0228 Tree: http://git-wip-us.apache.org/repos/asf/atlas/tree/5cfb0228 Diff: http://git-wip-us.apache.org/repos/asf/atlas/diff/5cfb0228 Branch: refs/heads/master Commit: 5cfb0228eceae7b626c7ff14d9580d5067056274 Parents: 810aceb Author: Mandy Chessell <[email protected]> Authored: Mon Apr 23 18:21:25 2018 +0100 Committer: David Radley <[email protected]> Committed: Mon Apr 30 15:44:14 2018 +0100 ---------------------------------------------------------------------- .../ffdc/AssetConsumerErrorCode.java | 2 +- .../InMemoryOMRSMetadataCollection.java | 249 ++++--- .../omrs/admin/OMRSOperationalServices.java | 14 +- .../EnterpriseOMRSMetadataCollection.java | 207 +++--- .../OMRSRepositoryEventExchangeRule.java | 9 +- .../apache/atlas/omrs/ffdc/OMRSErrorCode.java | 22 +- .../localrepository/OMRSLocalRepository.java | 10 - .../LocalOMRSInstanceEventProcessor.java | 17 +- .../LocalOMRSMetadataCollection.java | 147 ++-- .../LocalOMRSRepositoryConnector.java | 12 - .../OMRSInstanceRetrievalEventProcessor.java | 14 +- .../OMRSRepositoryContentManager.java | 722 +++++++++++++------ .../OMRSRepositoryHelper.java | 506 ++++++------- .../OMRSRepositoryValidator.java | 329 +++++---- .../OMRSTypeDefHelper.java | 24 +- .../OMRSTypeDefManager.java | 49 +- .../OMRSTypeDefValidator.java | 91 ++- .../OMRSMetadataCollection.java | 69 +- .../OMRSMetadataCollectionBase.java | 144 ++-- .../OMRSRESTMetadataCollection.java | 51 +- .../rest/server/OMRSRepositoryRESTServices.java | 122 ++-- 21 files changed, 1523 insertions(+), 1287 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/atlas/blob/5cfb0228/omas-assetconsumer/src/main/java/org/apache/atlas/omas/assetconsumer/ffdc/AssetConsumerErrorCode.java ---------------------------------------------------------------------- diff --git a/omas-assetconsumer/src/main/java/org/apache/atlas/omas/assetconsumer/ffdc/AssetConsumerErrorCode.java b/omas-assetconsumer/src/main/java/org/apache/atlas/omas/assetconsumer/ffdc/AssetConsumerErrorCode.java index 226aea9..3b13004 100644 --- a/omas-assetconsumer/src/main/java/org/apache/atlas/omas/assetconsumer/ffdc/AssetConsumerErrorCode.java +++ b/omas-assetconsumer/src/main/java/org/apache/atlas/omas/assetconsumer/ffdc/AssetConsumerErrorCode.java @@ -77,7 +77,7 @@ public enum AssetConsumerErrorCode "The system is unable to process the request.", "Verify the access rights of the user."), PROPERTY_SERVER_ERROR(400, "OMAS-ASSETCONSUMER-400-009 ", - "An unexpected error with message \'{0}\' was returned by the property server during {1} request for open metadata access service {2} on server {3}", + "An unexpected error was returned by the property server during {1} request for open metadata access service {2} on server {3}; message was {0}", "The system is unable to process the request.", "Verify the access rights of the user."), NULL_ENUM(400, "OMAS-ASSETCONSUMER-400-010 ", http://git-wip-us.apache.org/repos/asf/atlas/blob/5cfb0228/omrs/src/main/java/org/apache/atlas/omrs/adapters/inmemory/repositoryconnector/InMemoryOMRSMetadataCollection.java ---------------------------------------------------------------------- diff --git a/omrs/src/main/java/org/apache/atlas/omrs/adapters/inmemory/repositoryconnector/InMemoryOMRSMetadataCollection.java b/omrs/src/main/java/org/apache/atlas/omrs/adapters/inmemory/repositoryconnector/InMemoryOMRSMetadataCollection.java index 2d4f007..0ab1a4e 100644 --- a/omrs/src/main/java/org/apache/atlas/omrs/adapters/inmemory/repositoryconnector/InMemoryOMRSMetadataCollection.java +++ b/omrs/src/main/java/org/apache/atlas/omrs/adapters/inmemory/repositoryconnector/InMemoryOMRSMetadataCollection.java @@ -511,7 +511,7 @@ public class InMemoryOMRSMetadataCollection extends OMRSMetadataCollection parentConnector.validateRepositoryIsActive(methodName); repositoryValidator.validateUserId(repositoryName, userId, methodName); - repositoryValidator.validateTypeGUID(repositoryName, guidParameterName, guid, methodName); + repositoryValidator.validateGUID(repositoryName, guidParameterName, guid, methodName); /* * Perform operation @@ -525,7 +525,8 @@ public class InMemoryOMRSMetadataCollection extends OMRSMetadataCollection OMRSErrorCode errorCode = OMRSErrorCode.TYPEDEF_ID_NOT_KNOWN; - String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage(guid, methodName, repositoryName); + String errorMessage = errorCode.getErrorMessageId() + + errorCode.getFormattedErrorMessage(guid, guidParameterName, methodName, repositoryName); throw new TypeDefNotKnownException(errorCode.getHTTPErrorCode(), this.getClass().getName(), @@ -565,7 +566,7 @@ public class InMemoryOMRSMetadataCollection extends OMRSMetadataCollection parentConnector.validateRepositoryIsActive(methodName); repositoryValidator.validateUserId(repositoryName, userId, methodName); - repositoryValidator.validateTypeGUID(repositoryName, guidParameterName, guid, methodName); + repositoryValidator.validateGUID(repositoryName, guidParameterName, guid, methodName); /* * Perform operation @@ -579,7 +580,8 @@ public class InMemoryOMRSMetadataCollection extends OMRSMetadataCollection OMRSErrorCode errorCode = OMRSErrorCode.TYPEDEF_ID_NOT_KNOWN; - String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage(guid, methodName, repositoryName); + String errorMessage = errorCode.getErrorMessageId() + + errorCode.getFormattedErrorMessage(guid, guidParameterName, methodName, repositoryName); throw new TypeDefNotKnownException(errorCode.getHTTPErrorCode(), this.getClass().getName(), @@ -1030,6 +1032,7 @@ public class InMemoryOMRSMetadataCollection extends OMRSMetadataCollection String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage(typeDefPatch.getTypeDefGUID(), typeDefParameterName, + methodName, repositoryName); throw new TypeDefNotKnownException(errorCode.getHTTPErrorCode(), @@ -1094,12 +1097,14 @@ public class InMemoryOMRSMetadataCollection extends OMRSMetadataCollection * Perform operation */ TypeDef typeDef = repositoryStore.getTypeDef(obsoleteTypeDefGUID); + if (typeDef == null) { OMRSErrorCode errorCode = OMRSErrorCode.TYPEDEF_ID_NOT_KNOWN; String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage(typeDef.getGUID(), guidParameterName, + methodName, repositoryName); throw new TypeDefNotKnownException(errorCode.getHTTPErrorCode(), @@ -1171,12 +1176,14 @@ public class InMemoryOMRSMetadataCollection extends OMRSMetadataCollection * Perform operation */ AttributeTypeDef attributeTypeDef = repositoryStore.getAttributeTypeDef(obsoleteTypeDefGUID); + if (attributeTypeDef == null) { OMRSErrorCode errorCode = OMRSErrorCode.TYPEDEF_ID_NOT_KNOWN; String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage(obsoleteTypeDefGUID, guidParameterName, + methodName, repositoryName); throw new TypeDefNotKnownException(errorCode.getHTTPErrorCode(), @@ -1264,8 +1271,9 @@ public class InMemoryOMRSMetadataCollection extends OMRSMetadataCollection { OMRSErrorCode errorCode = OMRSErrorCode.TYPEDEF_ID_NOT_KNOWN; String errorMessage = errorCode.getErrorMessageId() - + errorCode.getFormattedErrorMessage(originalTypeDefName, - originalTypeDefGUID, + + errorCode.getFormattedErrorMessage(originalTypeDefGUID, + originalGUIDParameterName, + methodName, repositoryName); throw new TypeDefNotKnownException(errorCode.getHTTPErrorCode(), @@ -1609,6 +1617,7 @@ public class InMemoryOMRSMetadataCollection extends OMRSMetadataCollection * unrestricted return results size. * @return Relationships list. Null means no relationships associated with the entity. * @throws InvalidParameterException - a parameter is invalid or null. + * @throws TypeErrorException - the type guid passed on the request is not known by the metadata collection. * @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. @@ -1625,6 +1634,7 @@ public class InMemoryOMRSMetadataCollection extends OMRSMetadataCollection String sequencingProperty, SequencingOrder sequencingOrder, int pageSize) throws InvalidParameterException, + TypeErrorException, RepositoryErrorException, EntityNotKnownException, PropertyErrorException, @@ -1633,6 +1643,7 @@ public class InMemoryOMRSMetadataCollection extends OMRSMetadataCollection { final String methodName = "getRelationshipsForEntity"; final String guidParameterName = "entityGUID"; + final String typeGUIDParameterName = "relationshipTypeGUID"; final String asOfTimeParameter = "asOfTime"; final String pageSizeParameter = "pageSize"; @@ -1647,6 +1658,8 @@ public class InMemoryOMRSMetadataCollection extends OMRSMetadataCollection repositoryValidator.validateAsOfTime(repositoryName, asOfTimeParameter, asOfTime, methodName); repositoryValidator.validatePageSize(repositoryName, pageSizeParameter, pageSize, methodName); + this.validateTypeGUID(repositoryName, typeGUIDParameterName, relationshipTypeGUID, methodName); + /* * Perform operation */ @@ -1664,24 +1677,18 @@ public class InMemoryOMRSMetadataCollection extends OMRSMetadataCollection { repositoryValidator.validRelationship(repositoryName, storedRelationship); - if (relationshipTypeGUID != null) - { - if (! relationshipTypeGUID.equals(storedRelationship.getType().getTypeDefGUID())) - { - if (repositoryHelper.relatedEntity(repositoryName, - entityGUID, - storedRelationship)) - { - entityRelationships.add(storedRelationship); - } - } - } - if (repositoryHelper.relatedEntity(repositoryName, entityGUID, storedRelationship)) { - entityRelationships.add(storedRelationship); + if (relationshipTypeGUID == null) + { + entityRelationships.add(storedRelationship); + } + else if (relationshipTypeGUID.equals(storedRelationship.getType().getTypeDefGUID())) + { + entityRelationships.add(storedRelationship); + } } } } @@ -1724,10 +1731,9 @@ public class InMemoryOMRSMetadataCollection extends OMRSMetadataCollection * collection. * * @throws InvalidParameterException - a parameter is invalid or null. + * @throws TypeErrorException - the type guid passed on the request is not known by the metadata collection. * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where * the metadata collection is stored. - * @throws TypeErrorException - the type guid passed on the request is not known by the - * metadata collection. * @throws PropertyErrorException - the properties specified are not valid for any of the requested types of * entity. * @throws PagingErrorException - the paging/sequencing parameters are set up incorrectly. @@ -1764,7 +1770,6 @@ public class InMemoryOMRSMetadataCollection extends OMRSMetadataCollection parentConnector.validateRepositoryIsActive(methodName); repositoryValidator.validateUserId(repositoryName, userId, methodName); - repositoryValidator.validateTypeGUID(repositoryName, guidParameterName, entityTypeGUID, methodName); repositoryValidator.validateAsOfTime(repositoryName, asOfTimeParameter, asOfTime, methodName); repositoryValidator.validatePageSize(repositoryName, pageSizeParameter, pageSize, methodName); repositoryValidator.validateMatchCriteria(repositoryName, @@ -1773,6 +1778,7 @@ public class InMemoryOMRSMetadataCollection extends OMRSMetadataCollection matchCriteria, matchProperties, methodName); + this.validateTypeGUID(repositoryName, guidParameterName, entityTypeGUID, methodName); /* * Perform operation @@ -1826,10 +1832,9 @@ public class InMemoryOMRSMetadataCollection extends OMRSMetadataCollection * @return a list of entities matching the supplied criteria - null means no matching entities in the metadata * collection. * @throws InvalidParameterException - a parameter is invalid or null. + * @throws TypeErrorException - the type guid passed on the request is not known by the metadata collection. * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where * the metadata collection is stored. - * @throws TypeErrorException - the type guid passed on the request is not known by the - * metadata collection. * @throws ClassificationErrorException - the classification is not known to the metadata collection. * @throws PropertyErrorException - the properties specified are not valid for the requested type of * classification. @@ -1847,8 +1852,8 @@ public class InMemoryOMRSMetadataCollection extends OMRSMetadataCollection String sequencingProperty, SequencingOrder sequencingOrder, int pageSize) throws InvalidParameterException, - RepositoryErrorException, TypeErrorException, + RepositoryErrorException, ClassificationErrorException, PropertyErrorException, PagingErrorException, @@ -1871,16 +1876,36 @@ public class InMemoryOMRSMetadataCollection extends OMRSMetadataCollection parentConnector.validateRepositoryIsActive(methodName); repositoryValidator.validateUserId(repositoryName, userId, methodName); - repositoryValidator.validateGUID(repositoryName, entityTypeGUIDParameterName, entityTypeGUID, methodName); repositoryValidator.validateAsOfTime(repositoryName, asOfTimeParameter, asOfTime, methodName); repositoryValidator.validatePageSize(repositoryName, pageSizeParameter, pageSize, methodName); + this.validateTypeGUID(repositoryName, entityTypeGUIDParameterName, entityTypeGUID, methodName); /* * Validate TypeDef */ - TypeDef entityTypeDef = repositoryStore.getTypeDef(entityTypeGUID); + if (entityTypeGUID != null) + { + TypeDef entityTypeDef = repositoryStore.getTypeDef(entityTypeGUID); + + repositoryValidator.validateTypeDefForInstance(repositoryName, + entityTypeGUIDParameterName, + entityTypeDef, + methodName); - repositoryValidator.validateTypeDefForInstance(repositoryName, entityTypeGUIDParameterName, entityTypeDef, methodName); + repositoryValidator.validateClassification(repositoryName, + classificationParameterName, + classificationName, + entityTypeDef.getName(), + methodName); + } + else + { + repositoryValidator.validateClassification(repositoryName, + classificationParameterName, + classificationName, + null, + methodName); + } repositoryValidator.validateMatchCriteria(repositoryName, matchCriteriaParameterName, @@ -1888,11 +1913,6 @@ public class InMemoryOMRSMetadataCollection extends OMRSMetadataCollection matchCriteria, matchClassificationProperties, methodName); - repositoryValidator.validateClassification(repositoryName, - classificationParameterName, - classificationName, - entityTypeDef.getName(), - methodName); /* * Perform operation @@ -1972,6 +1992,7 @@ public class InMemoryOMRSMetadataCollection extends OMRSMetadataCollection * @return a list of entities matching the supplied criteria - null means no matching entities in the metadata * collection. * @throws InvalidParameterException - a parameter is invalid or null. + * @throws TypeErrorException - the type guid passed on the request is not known by the metadata collection. * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where * the metadata collection is stored. * @throws PropertyErrorException - the sequencing property specified is not valid for any of the requested types of @@ -1990,6 +2011,7 @@ public class InMemoryOMRSMetadataCollection extends OMRSMetadataCollection String sequencingProperty, SequencingOrder sequencingOrder, int pageSize) throws InvalidParameterException, + TypeErrorException, RepositoryErrorException, PropertyErrorException, PagingErrorException, @@ -1999,6 +2021,7 @@ public class InMemoryOMRSMetadataCollection extends OMRSMetadataCollection final String methodName = "findEntitiesByPropertyValue"; final String searchCriteriaParameterName = "searchCriteria"; final String asOfTimeParameter = "asOfTime"; + final String typeGUIDParameter = "entityTypeGUID"; final String pageSizeParameter = "pageSize"; /* @@ -2012,6 +2035,8 @@ public class InMemoryOMRSMetadataCollection extends OMRSMetadataCollection repositoryValidator.validateAsOfTime(repositoryName, asOfTimeParameter, asOfTime, methodName); repositoryValidator.validatePageSize(repositoryName, pageSizeParameter, pageSize, methodName); + this.validateTypeGUID(repositoryName, typeGUIDParameter, entityTypeGUID, methodName); + /* * Process operation * @@ -2185,10 +2210,9 @@ public class InMemoryOMRSMetadataCollection extends OMRSMetadataCollection * unrestricted return results size. * @return a list of relationships. Null means no matching relationships. * @throws InvalidParameterException - one of the parameters is invalid or null. + * @throws TypeErrorException - the type guid passed on the request is not known by the metadata collection. * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where * the metadata collection is stored. - * @throws TypeErrorException - the type guid passed on the request is not known by the - * metadata collection. * @throws PropertyErrorException - the properties specified are not valid for any of the requested types of * relationships. * @throws PagingErrorException - the paging/sequencing parameters are set up incorrectly. @@ -2204,8 +2228,8 @@ public class InMemoryOMRSMetadataCollection extends OMRSMetadataCollection String sequencingProperty, SequencingOrder sequencingOrder, int pageSize) throws InvalidParameterException, - RepositoryErrorException, TypeErrorException, + RepositoryErrorException, PropertyErrorException, PagingErrorException, UserNotAuthorizedException @@ -2224,7 +2248,6 @@ public class InMemoryOMRSMetadataCollection extends OMRSMetadataCollection parentConnector.validateRepositoryIsActive(methodName); repositoryValidator.validateUserId(repositoryName, userId, methodName); - repositoryValidator.validateTypeGUID(repositoryName, guidParameterName, relationshipTypeGUID, methodName); repositoryValidator.validateAsOfTime(repositoryName, asOfTimeParameter, asOfTime, methodName); repositoryValidator.validatePageSize(repositoryName, pageSizeParameter, pageSize, methodName); repositoryValidator.validateMatchCriteria(repositoryName, @@ -2234,6 +2257,8 @@ public class InMemoryOMRSMetadataCollection extends OMRSMetadataCollection matchProperties, methodName); + this.validateTypeGUID(repositoryName, guidParameterName, relationshipTypeGUID, methodName); + /* * Perform operation * @@ -2290,6 +2315,7 @@ public class InMemoryOMRSMetadataCollection extends OMRSMetadataCollection * unrestricted return results size. * @return a list of relationships. Null means no matching relationships. * @throws InvalidParameterException - one of the parameters is invalid or null. + * @throws TypeErrorException - the type guid passed on the request is not known by the metadata collection. * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where * the metadata collection is stored. * @throws PropertyErrorException - there is a problem with one of the other parameters. @@ -2305,6 +2331,7 @@ public class InMemoryOMRSMetadataCollection extends OMRSMetadataCollection String sequencingProperty, SequencingOrder sequencingOrder, int pageSize) throws InvalidParameterException, + TypeErrorException, RepositoryErrorException, PropertyErrorException, PagingErrorException, @@ -2313,6 +2340,7 @@ public class InMemoryOMRSMetadataCollection extends OMRSMetadataCollection final String methodName = "findRelationshipsByPropertyValue"; final String asOfTimeParameter = "asOfTime"; final String pageSizeParameter = "pageSize"; + final String typeGUIDParameter = "relationshipTypeGUID"; /* * Validate parameters @@ -2324,6 +2352,8 @@ public class InMemoryOMRSMetadataCollection extends OMRSMetadataCollection repositoryValidator.validateAsOfTime(repositoryName, asOfTimeParameter, asOfTime, methodName); repositoryValidator.validatePageSize(repositoryName, pageSizeParameter, pageSize, methodName); + this.validateTypeGUID(repositoryName, typeGUIDParameter, relationshipTypeGUID, methodName); + /* * Perform operation * @@ -2405,8 +2435,16 @@ public class InMemoryOMRSMetadataCollection extends OMRSMetadataCollection * Perform operation */ // todo + OMRSErrorCode errorCode = OMRSErrorCode.METHOD_NOT_IMPLEMENTED; + + String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage(methodName, this.getClass().getName(), repositoryName); - return null; + throw new RepositoryErrorException(errorCode.getHTTPErrorCode(), + this.getClass().getName(), + methodName, + errorMessage, + errorCode.getSystemAction(), + errorCode.getUserAction()); } @@ -2473,7 +2511,7 @@ public class InMemoryOMRSMetadataCollection extends OMRSMetadataCollection { for (String guid : entityTypeGUIDs) { - repositoryValidator.validateGUID(repositoryName, entityTypeGUIDParameterName, guid, methodName); + this.validateTypeGUID(repositoryName, entityTypeGUIDParameterName, guid, methodName); } } @@ -2481,11 +2519,11 @@ public class InMemoryOMRSMetadataCollection extends OMRSMetadataCollection { for (String guid : relationshipTypeGUIDs) { - repositoryValidator.validateGUID(repositoryName, relationshipTypeGUIDParameterName, guid, methodName); + this.validateTypeGUID(repositoryName, relationshipTypeGUIDParameterName, guid, methodName); } } - if (relationshipTypeGUIDs != null) + if (limitResultsByClassification != null) { for (String classificationName : limitResultsByClassification) { @@ -2564,6 +2602,7 @@ public class InMemoryOMRSMetadataCollection extends OMRSMetadataCollection { final String methodName = "getRelatedEntities"; final String entityGUIDParameterName = "startEntityGUID"; + final String instanceTypesParameter = "instanceTypes"; final String asOfTimeParameter = "asOfTime"; final String pageSizeParameter = "pageSize"; @@ -2578,14 +2617,32 @@ public class InMemoryOMRSMetadataCollection extends OMRSMetadataCollection repositoryValidator.validateAsOfTime(repositoryName, asOfTimeParameter, asOfTime, methodName); repositoryValidator.validatePageSize(repositoryName, pageSizeParameter, pageSize, methodName); + if (instanceTypes != null) + { + for (String guid : instanceTypes) + { + this.validateTypeGUID(repositoryName, instanceTypesParameter, guid, methodName); + } + } + /* * Perform operation */ List<EntityDetail> relatedEntities = new ArrayList<>(); - // todo + OMRSErrorCode errorCode = OMRSErrorCode.METHOD_NOT_IMPLEMENTED; + + String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage(methodName, this.getClass().getName(), repositoryName); - return formatEntityResults(relatedEntities, fromEntityElement, sequencingProperty, sequencingOrder, pageSize); + throw new RepositoryErrorException(errorCode.getHTTPErrorCode(), + this.getClass().getName(), + methodName, + errorMessage, + errorCode.getSystemAction(), + errorCode.getUserAction()); + + + // return formatEntityResults(relatedEntities, fromEntityElement, sequencingProperty, sequencingOrder, pageSize); } @@ -2705,23 +2762,11 @@ public class InMemoryOMRSMetadataCollection extends OMRSMetadataCollection * @throws InvalidParameterException - the entity proxy is null. * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where * the metadata collection is stored. - * @throws TypeErrorException - the requested type is not known, or not supported in the metadata repository - * hosting the metadata collection. - * @throws PropertyErrorException - one or more of the requested properties are not defined, or have different - * characteristics in the TypeDef for this entity's type. - * @throws ClassificationErrorException - one or more of the requested classifications are either not known or - * not defined for this entity type. - * @throws StatusNotSupportedException - the metadata repository hosting the metadata collection does not support - * the requested status. * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation. */ public void addEntityProxy(String userId, EntityProxy entityProxy) throws InvalidParameterException, RepositoryErrorException, - TypeErrorException, - PropertyErrorException, - ClassificationErrorException, - StatusNotSupportedException, UserNotAuthorizedException { final String methodName = "addEntityProxy"; @@ -2741,31 +2786,6 @@ public class InMemoryOMRSMetadataCollection extends OMRSMetadataCollection entityProxy, methodName); - repositoryValidator.validateInstanceType(repositoryName, entityProxy); - - String entityTypeGUID = entityProxy.getType().getTypeDefGUID(); - - TypeDef typeDef = repositoryStore.getTypeDef(entityTypeGUID); - - repositoryValidator.validateTypeDefForInstance(repositoryName, proxyParameterName, typeDef, methodName); - repositoryValidator.validateClassificationList(repositoryName, - proxyParameterName, - entityProxy.getClassifications(), - typeDef.getName(), - methodName); - - repositoryValidator.validatePropertiesForType(repositoryName, - proxyParameterName, - typeDef, - entityProxy.getUniqueProperties(), - methodName); - - repositoryValidator.validateInstanceStatus(repositoryName, - proxyParameterName, - entityProxy.getStatus(), - typeDef, - methodName); - /* * Validation complete */ @@ -2835,7 +2855,7 @@ public class InMemoryOMRSMetadataCollection extends OMRSMetadataCollection updatedEntity.setStatus(newStatus); - repositoryHelper.incrementVersion(userId, entity, updatedEntity); + updatedEntity = repositoryHelper.incrementVersion(userId, entity, updatedEntity); repositoryStore.updateEntityInStore(updatedEntity); @@ -2914,7 +2934,7 @@ public class InMemoryOMRSMetadataCollection extends OMRSMetadataCollection entity.getProperties(), properties)); - repositoryHelper.incrementVersion(userId, entity, updatedEntity); + updatedEntity = repositoryHelper.incrementVersion(userId, entity, updatedEntity); repositoryStore.updateEntityInStore(updatedEntity); @@ -3045,7 +3065,7 @@ public class InMemoryOMRSMetadataCollection extends OMRSMetadataCollection updatedEntity.setStatusOnDelete(entity.getStatus()); updatedEntity.setStatus(InstanceStatus.DELETED); - repositoryHelper.incrementVersion(userId, entity, updatedEntity); + updatedEntity = repositoryHelper.incrementVersion(userId, entity, updatedEntity); repositoryStore.removeEntityFromStore(updatedEntity); @@ -3285,7 +3305,7 @@ public class InMemoryOMRSMetadataCollection extends OMRSMetadataCollection newClassification, methodName); - repositoryHelper.incrementVersion(userId, entity, updatedEntity); + updatedEntity = repositoryHelper.incrementVersion(userId, entity, updatedEntity); repositoryStore.updateEntityInStore(updatedEntity); @@ -3351,7 +3371,7 @@ public class InMemoryOMRSMetadataCollection extends OMRSMetadataCollection classificationName, methodName); - repositoryHelper.incrementVersion(userId, entity, updatedEntity); + updatedEntity = repositoryHelper.incrementVersion(userId, entity, updatedEntity); repositoryStore.updateEntityInStore(updatedEntity); @@ -3468,7 +3488,7 @@ public class InMemoryOMRSMetadataCollection extends OMRSMetadataCollection newClassification, methodName); - repositoryHelper.incrementVersion(userId, entity, updatedEntity); + updatedEntity = repositoryHelper.incrementVersion(userId, entity, updatedEntity); repositoryStore.updateEntityInStore(updatedEntity); @@ -3647,7 +3667,7 @@ public class InMemoryOMRSMetadataCollection extends OMRSMetadataCollection updatedRelationship.setStatus(newStatus); - repositoryHelper.incrementVersion(userId, relationship, updatedRelationship); + updatedRelationship = repositoryHelper.incrementVersion(userId, relationship, updatedRelationship); repositoryStore.updateRelationshipInStore(updatedRelationship); @@ -3718,7 +3738,7 @@ public class InMemoryOMRSMetadataCollection extends OMRSMetadataCollection updatedRelationship.setProperties(repositoryHelper.mergeInstanceProperties(repositoryName, relationship.getProperties(), properties)); - repositoryHelper.incrementVersion(userId, relationship, updatedRelationship); + updatedRelationship = repositoryHelper.incrementVersion(userId, relationship, updatedRelationship); repositoryStore.updateRelationshipInStore(updatedRelationship); @@ -3830,7 +3850,7 @@ public class InMemoryOMRSMetadataCollection extends OMRSMetadataCollection updatedRelationship.setStatusOnDelete(relationship.getStatus()); updatedRelationship.setStatus(InstanceStatus.DELETED); - repositoryHelper.incrementVersion(userId, relationship, updatedRelationship); + updatedRelationship = repositoryHelper.incrementVersion(userId, relationship, updatedRelationship); repositoryStore.removeRelationshipFromStore(updatedRelationship); @@ -4020,7 +4040,7 @@ public class InMemoryOMRSMetadataCollection extends OMRSMetadataCollection updatedEntity.setGUID(newEntityGUID); - repositoryHelper.incrementVersion(userId, entity, updatedEntity); + updatedEntity = repositoryHelper.incrementVersion(userId, entity, updatedEntity); repositoryStore.removeEntityFromStore(entity); repositoryStore.createEntityInStore(updatedEntity); @@ -4116,7 +4136,7 @@ public class InMemoryOMRSMetadataCollection extends OMRSMetadataCollection updatedEntity.setType(newInstanceType); - repositoryHelper.incrementVersion(userId, entity, updatedEntity); + updatedEntity = repositoryHelper.incrementVersion(userId, entity, updatedEntity); repositoryStore.updateEntityInStore(entity); @@ -4199,7 +4219,7 @@ public class InMemoryOMRSMetadataCollection extends OMRSMetadataCollection updatedEntity.setMetadataCollectionId(newHomeMetadataCollectionId); updatedEntity.setInstanceProvenanceType(InstanceProvenanceType.LOCAL_COHORT); - repositoryHelper.incrementVersion(userId, entity, updatedEntity); + updatedEntity = repositoryHelper.incrementVersion(userId, entity, updatedEntity); repositoryStore.updateEntityInStore(updatedEntity); @@ -4275,7 +4295,7 @@ public class InMemoryOMRSMetadataCollection extends OMRSMetadataCollection updatedRelationship.setGUID(newRelationshipGUID); - repositoryHelper.incrementVersion(userId, relationship, updatedRelationship); + updatedRelationship = repositoryHelper.incrementVersion(userId, relationship, updatedRelationship); repositoryStore.removeRelationshipFromStore(relationship); repositoryStore.createRelationshipInStore(updatedRelationship); @@ -4357,11 +4377,11 @@ public class InMemoryOMRSMetadataCollection extends OMRSMetadataCollection updatedRelationship.setType(newInstanceType); - repositoryHelper.incrementVersion(userId, relationship, updatedRelationship); + updatedRelationship = repositoryHelper.incrementVersion(userId, relationship, updatedRelationship); - repositoryStore.updateRelationshipInStore(relationship); + repositoryStore.updateRelationshipInStore(updatedRelationship); - return null; + return updatedRelationship; } @@ -4431,7 +4451,7 @@ public class InMemoryOMRSMetadataCollection extends OMRSMetadataCollection updatedRelationship.setMetadataCollectionId(newHomeMetadataCollectionId); updatedRelationship.setInstanceProvenanceType(InstanceProvenanceType.LOCAL_COHORT); - repositoryHelper.incrementVersion(userId, relationship, updatedRelationship); + updatedRelationship = repositoryHelper.incrementVersion(userId, relationship, updatedRelationship); repositoryStore.updateRelationshipInStore(updatedRelationship); @@ -4857,4 +4877,37 @@ public class InMemoryOMRSMetadataCollection extends OMRSMetadataCollection return new ArrayList<>(fullResults.subList(fromElement, fromElement + pageSize - 1)); } + + + /** + * Validate that type's identifier is not null. + * + * @param sourceName - source of the request (used for logging) + * @param guidParameterName - name of the parameter that passed the guid. + * @param guid - unique identifier for a type or an instance passed on the request + * @param methodName - method receiving the call + * @throws TypeErrorException - no guid provided + */ + public void validateTypeGUID(String sourceName, + String guidParameterName, + String guid, + String methodName) throws TypeErrorException + { + if (guid != null) + { + if (repositoryStore.getTypeDef(guid) == null) + { + OMRSErrorCode errorCode = OMRSErrorCode.TYPEDEF_ID_NOT_KNOWN; + String errorMessage = errorCode.getErrorMessageId() + + errorCode.getFormattedErrorMessage(guid, guidParameterName, methodName, sourceName); + + throw new TypeErrorException(errorCode.getHTTPErrorCode(), + this.getClass().getName(), + methodName, + errorMessage, + errorCode.getSystemAction(), + errorCode.getUserAction()); + } + } + } } http://git-wip-us.apache.org/repos/asf/atlas/blob/5cfb0228/omrs/src/main/java/org/apache/atlas/omrs/admin/OMRSOperationalServices.java ---------------------------------------------------------------------- diff --git a/omrs/src/main/java/org/apache/atlas/omrs/admin/OMRSOperationalServices.java b/omrs/src/main/java/org/apache/atlas/omrs/admin/OMRSOperationalServices.java index f540b0d..e72d783 100644 --- a/omrs/src/main/java/org/apache/atlas/omrs/admin/OMRSOperationalServices.java +++ b/omrs/src/main/java/org/apache/atlas/omrs/admin/OMRSOperationalServices.java @@ -267,6 +267,13 @@ public class OMRSOperationalServices List<CohortConfig> cohortConfigList = repositoryServicesConfig.getCohortConfigList(); /* + * The local repository is optional. However, the repository content manager is still + * used to manage the validation of TypeDefs and the creation of metadata instances. + * It is loaded with any TypeDefs from the archives to seed its in-memory TypeDef cache. + */ + localRepositoryContentManager = new OMRSRepositoryContentManager(); + + /* * Begin with the enterprise repository services. They are always needed since the * Open Metadata Access Services (OMAS) is dependent on them. There are 2 modes of operation: local only * and enterprise access. Enterprise access provide an enterprise view of metadata @@ -287,13 +294,6 @@ public class OMRSOperationalServices archiveManager = initializeOpenMetadataArchives(repositoryServicesConfig.getOpenMetadataArchiveConnections()); /* - * The local repository is optional. However, the repository content manager is still - * used to manage the validation of TypeDefs and the creation of metadata instances. - * It is loaded with any TypeDefs from the archives to seed its in-memory TypeDef cache. - */ - localRepositoryContentManager = new OMRSRepositoryContentManager(); - - /* * The repository validator and helper are used by repository connectors to verify the types and instances * they receive from external parties and to build new types and instances. Instances of these * classes are created in each of the repository connectors (and possibly the event mappers as well). http://git-wip-us.apache.org/repos/asf/atlas/blob/5cfb0228/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 e930361..5b0165f 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 @@ -856,7 +856,7 @@ public class EnterpriseOMRSMetadataCollection extends OMRSMetadataCollection parentConnector.validateRepositoryIsActive(methodName); repositoryValidator.validateUserId(repositoryName, userId, methodName); - repositoryValidator.validateTypeGUID(repositoryName, guidParameterName, guid, methodName); + repositoryValidator.validateGUID(repositoryName, guidParameterName, guid, methodName); /* * The list of cohort connectors are retrieved for each request to ensure that any changes in @@ -949,7 +949,7 @@ public class EnterpriseOMRSMetadataCollection extends OMRSMetadataCollection parentConnector.validateRepositoryIsActive(methodName); repositoryValidator.validateUserId(repositoryName, userId, methodName); - repositoryValidator.validateTypeGUID(repositoryName, guidParameterName, guid, methodName); + repositoryValidator.validateGUID(repositoryName, guidParameterName, guid, methodName); /* * The list of cohort connectors are retrieved for each request to ensure that any changes in @@ -1568,11 +1568,12 @@ public class EnterpriseOMRSMetadataCollection extends OMRSMetadataCollection /** - * Returns a boolean indicating if the entity is stored in the metadata collection. + * 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 entity details if the entity is found in the metadata collection; otherwise return null + * @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. @@ -1658,7 +1659,8 @@ public class EnterpriseOMRSMetadataCollection extends OMRSMetadataCollection /** - * Return the header and classifications for a specific entity. + * 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 @@ -1978,81 +1980,6 @@ public class EnterpriseOMRSMetadataCollection extends OMRSMetadataCollection /** - * Return the header, classifications, properties and relationships for a specific entity. The entity - * detail can come from any server. The relationships may be distributed over all of the repositories. - * - * @param userId - unique identifier for requesting user. - * @param guid - String unique identifier for the entity. - * @return EntityUniverse 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 EntityProxyOnlyException - the requested entity instance is only a proxy in the metadata collection. - * @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 EntityUniverse getEntityUniverse(String userId, - String guid) throws InvalidParameterException, - RepositoryErrorException, - EntityNotKnownException, - EntityProxyOnlyException, - UserNotAuthorizedException - { - final String methodName = "getEntityUniverse"; - - /* - * Retrieve the core entity details - */ - EntityDetail entityDetail = this.getEntityDetail(userId, guid); - - /* - * Step through the registered open metadata repositories to locate all of the active relationships. - */ - List<Relationship> relationships = null; - - try - { - List<InstanceStatus> instanceStatuses = new ArrayList<>(); - - instanceStatuses.add(InstanceStatus.ACTIVE); - relationships = this.getRelationshipsForEntity(userId, - guid, - null, - 0, - instanceStatuses, - null, - null, - null, - 0); - } - catch (RepositoryErrorException error) - { - throw error; - } - catch (UserNotAuthorizedException error) - { - /* - * The user does not have access to the relationships so just return the entity detail - */ - relationships = null; - } - catch (Throwable error) - { - throwCapturedThrowableException(error, methodName); - } - - /* - * The entity universe combines the entity detail and the relationship list. - */ - - EntityUniverse entityUniverse = new EntityUniverse(entityDetail); - entityUniverse.setEntityRelationships(relationships); - - return entityUniverse; - } - - - /** * Return the relationships for a specific entity. * * @param userId - unique identifier for requesting user. @@ -2073,6 +2000,8 @@ public class EnterpriseOMRSMetadataCollection extends OMRSMetadataCollection * unrestricted return results size. * @return Relationships list. Null means no relationships associated with the entity. * @throws InvalidParameterException - a parameter is invalid or null. + * @throws TypeErrorException - the type guid passed on the request is not known by the + * metadata collection. * @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. @@ -2090,6 +2019,7 @@ public class EnterpriseOMRSMetadataCollection extends OMRSMetadataCollection String sequencingProperty, SequencingOrder sequencingOrder, int pageSize) throws InvalidParameterException, + TypeErrorException, RepositoryErrorException, EntityNotKnownException, PropertyErrorException, @@ -2100,6 +2030,7 @@ public class EnterpriseOMRSMetadataCollection extends OMRSMetadataCollection final String methodName = "getRelationshipsForEntity"; final String guidParameterName = "entityGUID"; final String asOfTimeParameter = "asOfTime"; + final String typeGUIDParameter = "relationshipTypeGUID"; final String pageSizeParameter = "pageSize"; /* @@ -2110,6 +2041,7 @@ public class EnterpriseOMRSMetadataCollection extends OMRSMetadataCollection repositoryValidator.validateUserId(repositoryName, userId, methodName); repositoryValidator.validateGUID(repositoryName, guidParameterName, entityGUID, methodName); + repositoryValidator.validateOptionalTypeGUID(repositoryName, typeGUIDParameter, relationshipTypeGUID, methodName); repositoryValidator.validateAsOfTime(repositoryName, asOfTimeParameter, asOfTime, methodName); repositoryValidator.validatePageSize(repositoryName, pageSizeParameter, pageSize, methodName); @@ -2250,10 +2182,10 @@ public class EnterpriseOMRSMetadataCollection extends OMRSMetadataCollection * @return a list of entities matching the supplied criteria - null means no matching entities in the metadata * collection. * @throws InvalidParameterException - a parameter is invalid or null. - * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where - * the metadata collection is stored. * @throws TypeErrorException - the type guid passed on the request is not known by the * metadata collection. + * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where + * the metadata collection is stored. * @throws PropertyErrorException - the properties specified are not valid for any of the requested types of * entity. * @throws PagingErrorException - the paging/sequencing parameters are set up incorrectly. @@ -2271,8 +2203,8 @@ public class EnterpriseOMRSMetadataCollection extends OMRSMetadataCollection String sequencingProperty, SequencingOrder sequencingOrder, int pageSize) throws InvalidParameterException, - RepositoryErrorException, TypeErrorException, + RepositoryErrorException, PropertyErrorException, PagingErrorException, FunctionNotSupportedException, @@ -2281,8 +2213,8 @@ public class EnterpriseOMRSMetadataCollection extends OMRSMetadataCollection final String methodName = "findEntitiesByProperty"; final String matchCriteriaParameterName = "matchCriteria"; final String matchPropertiesParameterName = "matchProperties"; - final String guidParameterName = "entityTypeGUID"; final String asOfTimeParameter = "asOfTime"; + final String guidParameter = "entityTypeGUID"; final String pageSizeParameter = "pageSize"; /* @@ -2292,7 +2224,7 @@ public class EnterpriseOMRSMetadataCollection extends OMRSMetadataCollection parentConnector.validateRepositoryIsActive(methodName); repositoryValidator.validateUserId(repositoryName, userId, methodName); - repositoryValidator.validateTypeGUID(repositoryName, guidParameterName, entityTypeGUID, methodName); + repositoryValidator.validateOptionalTypeGUID(repositoryName, guidParameter, entityTypeGUID, methodName); repositoryValidator.validateAsOfTime(repositoryName, asOfTimeParameter, asOfTime, methodName); repositoryValidator.validatePageSize(repositoryName, pageSizeParameter, pageSize, methodName); repositoryValidator.validateMatchCriteria(repositoryName, @@ -2440,10 +2372,10 @@ public class EnterpriseOMRSMetadataCollection extends OMRSMetadataCollection * @return a list of entities matching the supplied criteria - null means no matching entities in the metadata * collection. * @throws InvalidParameterException - a parameter is invalid or null. - * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where - * the metadata collection is stored. * @throws TypeErrorException - the type guid passed on the request is not known by the * metadata collection. + * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where + * the metadata collection is stored. * @throws ClassificationErrorException - the classification request is not known to the metadata collection. * @throws PropertyErrorException - the properties specified are not valid for the requested type of * classification. @@ -2462,8 +2394,8 @@ public class EnterpriseOMRSMetadataCollection extends OMRSMetadataCollection String sequencingProperty, SequencingOrder sequencingOrder, int pageSize) throws InvalidParameterException, - RepositoryErrorException, TypeErrorException, + RepositoryErrorException, ClassificationErrorException, PropertyErrorException, PagingErrorException, @@ -2486,16 +2418,31 @@ public class EnterpriseOMRSMetadataCollection extends OMRSMetadataCollection parentConnector.validateRepositoryIsActive(methodName); repositoryValidator.validateUserId(repositoryName, userId, methodName); - repositoryValidator.validateGUID(repositoryName, entityTypeGUIDParameterName, entityTypeGUID, methodName); + repositoryValidator.validateOptionalTypeGUID(repositoryName, entityTypeGUIDParameterName, entityTypeGUID, methodName); repositoryValidator.validateAsOfTime(repositoryName, asOfTimeParameter, asOfTime, methodName); repositoryValidator.validatePageSize(repositoryName, pageSizeParameter, pageSize, methodName); /* * Validate TypeDef */ - TypeDef entityTypeDef = repositoryHelper.getTypeDef(repositoryName, entityTypeGUID); + if (entityTypeGUID != null) + { + TypeDef entityTypeDef = repositoryHelper.getTypeDef(repositoryName, + entityTypeGUIDParameterName, + entityTypeGUID, + methodName); - repositoryValidator.validateTypeDefForInstance(repositoryName, entityTypeGUIDParameterName, entityTypeDef, methodName); + repositoryValidator.validateTypeDefForInstance(repositoryName, + entityTypeGUIDParameterName, + entityTypeDef, + methodName); + + repositoryValidator.validateClassification(repositoryName, + classificationParameterName, + classificationName, + entityTypeDef.getName(), + methodName); + } repositoryValidator.validateMatchCriteria(repositoryName, matchCriteriaParameterName, @@ -2503,11 +2450,6 @@ public class EnterpriseOMRSMetadataCollection extends OMRSMetadataCollection matchCriteria, matchClassificationProperties, methodName); - repositoryValidator.validateClassification(repositoryName, - classificationParameterName, - classificationName, - entityTypeDef.getName(), - methodName); /* * Perform operation @@ -2649,6 +2591,8 @@ public class EnterpriseOMRSMetadataCollection extends OMRSMetadataCollection * @return a list of entities matching the supplied criteria - null means no matching entities in the metadata * collection. * @throws InvalidParameterException - a parameter is invalid or null. + * @throws TypeErrorException - the type guid passed on the request is not known by the + * metadata collection. * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where * the metadata collection is stored. * @throws PropertyErrorException - the sequencing property specified is not valid for any of the requested types of @@ -2667,6 +2611,7 @@ public class EnterpriseOMRSMetadataCollection extends OMRSMetadataCollection String sequencingProperty, SequencingOrder sequencingOrder, int pageSize) throws InvalidParameterException, + TypeErrorException, RepositoryErrorException, PropertyErrorException, PagingErrorException, @@ -2676,6 +2621,7 @@ public class EnterpriseOMRSMetadataCollection extends OMRSMetadataCollection final String methodName = "findEntitiesByPropertyValue"; final String searchCriteriaParameterName = "searchCriteria"; final String asOfTimeParameter = "asOfTime"; + final String guidParameter = "entityTypeGUID"; final String pageSizeParameter = "pageSize"; /* @@ -2686,6 +2632,7 @@ public class EnterpriseOMRSMetadataCollection extends OMRSMetadataCollection repositoryValidator.validateUserId(repositoryName, userId, methodName); repositoryValidator.validateSearchCriteria(repositoryName, searchCriteriaParameterName, searchCriteria, methodName); + repositoryValidator.validateOptionalTypeGUID(repositoryName, guidParameter, entityTypeGUID, methodName); repositoryValidator.validateAsOfTime(repositoryName, asOfTimeParameter, asOfTime, methodName); repositoryValidator.validatePageSize(repositoryName, pageSizeParameter, pageSize, methodName); @@ -2707,6 +2654,7 @@ public class EnterpriseOMRSMetadataCollection extends OMRSMetadataCollection InvalidParameterException invalidParameterException = null; FunctionNotSupportedException functionNotSupportedException = null; + TypeErrorException typeErrorException = null; PropertyErrorException propertyErrorException = null; UserNotAuthorizedException userNotAuthorizedException = null; RepositoryErrorException repositoryErrorException = null; @@ -2756,6 +2704,10 @@ public class EnterpriseOMRSMetadataCollection extends OMRSMetadataCollection { functionNotSupportedException = error; } + catch (TypeErrorException error) + { + typeErrorException = error; + } catch (PropertyErrorException error) { propertyErrorException = error; @@ -2781,6 +2733,7 @@ public class EnterpriseOMRSMetadataCollection extends OMRSMetadataCollection throwCapturedRepositoryErrorException(repositoryErrorException); throwCapturedUserNotAuthorizedException(userNotAuthorizedException); throwCapturedThrowableException(anotherException, methodName); + throwCapturedTypeErrorException(typeErrorException); throwCapturedPropertyErrorException(propertyErrorException); throwCapturedInvalidParameterException(invalidParameterException); throwCapturedFunctionNotSupportedException(functionNotSupportedException); @@ -3117,10 +3070,10 @@ public class EnterpriseOMRSMetadataCollection extends OMRSMetadataCollection * unrestricted return results size. * @return a list of relationships. Null means no matching relationships. * @throws InvalidParameterException - one of the parameters is invalid or null. - * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where - * the metadata collection is stored. * @throws TypeErrorException - the type guid passed on the request is not known by the * metadata collection. + * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where + * the metadata collection is stored. * @throws PropertyErrorException - the properties specified are not valid for any of the requested types of * relationships. * @throws PagingErrorException - the paging/sequencing parameters are set up incorrectly. @@ -3137,8 +3090,8 @@ public class EnterpriseOMRSMetadataCollection extends OMRSMetadataCollection String sequencingProperty, SequencingOrder sequencingOrder, int pageSize) throws InvalidParameterException, - RepositoryErrorException, TypeErrorException, + RepositoryErrorException, PropertyErrorException, PagingErrorException, FunctionNotSupportedException, @@ -3147,8 +3100,8 @@ public class EnterpriseOMRSMetadataCollection extends OMRSMetadataCollection final String methodName = "findRelationshipsByProperty"; final String matchCriteriaParameterName = "matchCriteria"; final String matchPropertiesParameterName = "matchProperties"; - final String guidParameterName = "relationshipTypeGUID"; final String asOfTimeParameter = "asOfTime"; + final String guidParameter = "relationshipTypeGUID"; final String pageSizeParameter = "pageSize"; /* @@ -3158,7 +3111,7 @@ public class EnterpriseOMRSMetadataCollection extends OMRSMetadataCollection parentConnector.validateRepositoryIsActive(methodName); repositoryValidator.validateUserId(repositoryName, userId, methodName); - repositoryValidator.validateTypeGUID(repositoryName, guidParameterName, relationshipTypeGUID, methodName); + repositoryValidator.validateOptionalTypeGUID(repositoryName, guidParameter, relationshipTypeGUID, methodName); repositoryValidator.validateAsOfTime(repositoryName, asOfTimeParameter, asOfTime, methodName); repositoryValidator.validatePageSize(repositoryName, pageSizeParameter, pageSize, methodName); repositoryValidator.validateMatchCriteria(repositoryName, @@ -3306,6 +3259,8 @@ public class EnterpriseOMRSMetadataCollection extends OMRSMetadataCollection * unrestricted return results size. * @return a list of relationships. Null means no matching relationships. * @throws InvalidParameterException - one of the parameters is invalid or null. + * @throws TypeErrorException - the type guid passed on the request is not known by the + * metadata collection. * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where * the metadata collection is stored. * @throws PropertyErrorException - there is a problem with one of the other parameters. @@ -3322,14 +3277,16 @@ public class EnterpriseOMRSMetadataCollection extends OMRSMetadataCollection String sequencingProperty, SequencingOrder sequencingOrder, int pageSize) throws InvalidParameterException, - RepositoryErrorException, - PropertyErrorException, - PagingErrorException, - FunctionNotSupportedException, - UserNotAuthorizedException + TypeErrorException, + RepositoryErrorException, + PropertyErrorException, + PagingErrorException, + FunctionNotSupportedException, + UserNotAuthorizedException { final String methodName = "findRelationshipsByPropertyValue"; final String asOfTimeParameter = "asOfTime"; + final String guidParameter = "relationshipTypeGUID"; final String pageSizeParameter = "pageSize"; /* @@ -3340,6 +3297,7 @@ public class EnterpriseOMRSMetadataCollection extends OMRSMetadataCollection repositoryValidator.validateUserId(repositoryName, userId, methodName); repositoryValidator.validateAsOfTime(repositoryName, asOfTimeParameter, asOfTime, methodName); + repositoryValidator.validateOptionalTypeGUID(repositoryName, guidParameter, relationshipTypeGUID, methodName); repositoryValidator.validatePageSize(repositoryName, pageSizeParameter, pageSize, methodName); /* @@ -3361,6 +3319,7 @@ public class EnterpriseOMRSMetadataCollection extends OMRSMetadataCollection InvalidParameterException invalidParameterException = null; FunctionNotSupportedException functionNotSupportedException = null; PropertyErrorException propertyErrorException = null; + TypeErrorException typeErrorException = null; UserNotAuthorizedException userNotAuthorizedException = null; RepositoryErrorException repositoryErrorException = null; Throwable anotherException = null; @@ -3412,6 +3371,10 @@ public class EnterpriseOMRSMetadataCollection extends OMRSMetadataCollection { propertyErrorException = error; } + catch (TypeErrorException error) + { + typeErrorException = error; + } catch (RepositoryErrorException error) { repositoryErrorException = error; @@ -3433,6 +3396,7 @@ public class EnterpriseOMRSMetadataCollection extends OMRSMetadataCollection throwCapturedRepositoryErrorException(repositoryErrorException); throwCapturedUserNotAuthorizedException(userNotAuthorizedException); throwCapturedThrowableException(anotherException, methodName); + throwCapturedTypeErrorException(typeErrorException); throwCapturedPropertyErrorException(propertyErrorException); throwCapturedInvalidParameterException(invalidParameterException); throwCapturedFunctionNotSupportedException(functionNotSupportedException); @@ -3619,10 +3583,10 @@ public class EnterpriseOMRSMetadataCollection extends OMRSMetadataCollection * gather results. * @return InstanceGraph - the sub-graph that represents the returned linked entities and their relationships. * @throws InvalidParameterException - one of the parameters is invalid or null. - * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where - * the metadata collection is stored. * @throws TypeErrorException - one or more of the type guids passed on the request is not known by the * metadata collection. + * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where + * the metadata collection is stored. * @throws EntityNotKnownException - the entity identified by the entityGUID is not found in the metadata collection. * @throws PropertyErrorException - there is a problem with one of the other parameters. * @throws FunctionNotSupportedException - the repository does not support the asOfTime parameter. @@ -3636,9 +3600,9 @@ public class EnterpriseOMRSMetadataCollection extends OMRSMetadataCollection List<String> limitResultsByClassification, Date asOfTime, int level) throws InvalidParameterException, + TypeErrorException, RepositoryErrorException, EntityNotKnownException, - TypeErrorException, PropertyErrorException, FunctionNotSupportedException, UserNotAuthorizedException @@ -3664,7 +3628,7 @@ public class EnterpriseOMRSMetadataCollection extends OMRSMetadataCollection { for (String guid : entityTypeGUIDs) { - repositoryValidator.validateGUID(repositoryName, entityTypeGUIDParameterName, guid, methodName); + repositoryValidator.validateTypeGUID(repositoryName, entityTypeGUIDParameterName, guid, methodName); } } @@ -3672,11 +3636,11 @@ public class EnterpriseOMRSMetadataCollection extends OMRSMetadataCollection { for (String guid : relationshipTypeGUIDs) { - repositoryValidator.validateGUID(repositoryName, relationshipTypeGUIDParameterName, guid, methodName); + repositoryValidator.validateTypeGUID(repositoryName, relationshipTypeGUIDParameterName, guid, methodName); } } - if (relationshipTypeGUIDs != null) + if (limitResultsByClassification != null) { for (String classificationName : limitResultsByClassification) { @@ -3813,10 +3777,10 @@ public class EnterpriseOMRSMetadataCollection extends OMRSMetadataCollection * unrestricted return results size. * @return list of entities either directly or indirectly connected to the start entity * @throws InvalidParameterException - one of the parameters is invalid or null. + * @throws TypeErrorException - one or more of the type guids passed on the request is not known by the + * metadata collection. * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where * the metadata collection is stored. - * @throws TypeErrorException - the requested type is not known, or not supported in the metadata repository - * hosting the metadata collection. * @throws EntityNotKnownException - the entity identified by the startEntityGUID * is not found in the metadata collection. * @throws PropertyErrorException - the sequencing property specified is not valid for any of the requested types of @@ -3835,8 +3799,8 @@ public class EnterpriseOMRSMetadataCollection extends OMRSMetadataCollection String sequencingProperty, SequencingOrder sequencingOrder, int pageSize) throws InvalidParameterException, - RepositoryErrorException, TypeErrorException, + RepositoryErrorException, EntityNotKnownException, PropertyErrorException, PagingErrorException, @@ -3845,6 +3809,7 @@ public class EnterpriseOMRSMetadataCollection extends OMRSMetadataCollection { final String methodName = "getRelatedEntities"; final String entityGUIDParameterName = "startEntityGUID"; + final String typeGUIDParameterName = "instanceTypes"; final String asOfTimeParameter = "asOfTime"; final String pageSizeParameter = "pageSize"; @@ -3859,6 +3824,14 @@ public class EnterpriseOMRSMetadataCollection extends OMRSMetadataCollection repositoryValidator.validateAsOfTime(repositoryName, asOfTimeParameter, asOfTime, methodName); repositoryValidator.validatePageSize(repositoryName, pageSizeParameter, pageSize, methodName); + if (instanceTypes != null) + { + for (String guid : instanceTypes) + { + repositoryValidator.validateTypeGUID(repositoryName, typeGUIDParameterName, guid, methodName); + } + } + /* * Perform operation * @@ -4034,7 +4007,7 @@ public class EnterpriseOMRSMetadataCollection extends OMRSMetadataCollection repositoryValidator.validateUserId(repositoryName, userId, methodName); repositoryValidator.validateTypeGUID(repositoryName, entityGUIDParameterName, entityTypeGUID, methodName); - TypeDef typeDef = repositoryHelper.getTypeDef(repositoryName, entityTypeGUID); + TypeDef typeDef = repositoryHelper.getTypeDef(repositoryName, entityGUIDParameterName, entityTypeGUID, methodName); repositoryValidator.validateTypeDefForInstance(repositoryName, entityGUIDParameterName, typeDef, methodName); repositoryValidator.validateClassificationList(repositoryName, @@ -4957,7 +4930,7 @@ public class EnterpriseOMRSMetadataCollection extends OMRSMetadataCollection repositoryValidator.validateUserId(repositoryName, userId, methodName); repositoryValidator.validateTypeGUID(repositoryName, guidParameterName, relationshipTypeGUID, methodName); - TypeDef typeDef = repositoryHelper.getTypeDef(repositoryName, relationshipTypeGUID); + TypeDef typeDef = repositoryHelper.getTypeDef(repositoryName, guidParameterName, relationshipTypeGUID, methodName); repositoryValidator.validateTypeDefForInstance(repositoryName, guidParameterName, typeDef, methodName);
