http://git-wip-us.apache.org/repos/asf/atlas/blob/5cfb0228/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositorycontentmanager/OMRSRepositoryHelper.java ---------------------------------------------------------------------- diff --git a/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositorycontentmanager/OMRSRepositoryHelper.java b/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositorycontentmanager/OMRSRepositoryHelper.java index 74ca1ac..e8f4662 100644 --- a/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositorycontentmanager/OMRSRepositoryHelper.java +++ b/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositorycontentmanager/OMRSRepositoryHelper.java @@ -88,25 +88,9 @@ public class OMRSRepositoryHelper implements OMRSTypeDefHelper, OMRSInstanceHelp { final String methodName = "getActiveTypeDefGallery"; - if (repositoryContentManager != null) - { - /* - * Delegate call to repository content manager. - */ - return repositoryContentManager.getActiveTypeDefGallery(); - } - else - { - OMRSErrorCode errorCode = OMRSErrorCode.LOCAL_REPOSITORY_CONFIGURATION_ERROR; - String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage(); + validateRepositoryContentManager(methodName); - throw new OMRSLogicErrorException(errorCode.getHTTPErrorCode(), - this.getClass().getName(), - methodName, - errorMessage, - errorCode.getSystemAction(), - errorCode.getUserAction()); - } + return repositoryContentManager.getActiveTypeDefGallery(); } @@ -119,25 +103,9 @@ public class OMRSRepositoryHelper implements OMRSTypeDefHelper, OMRSInstanceHelp { final String methodName = "getKnownTypeDefGallery"; - if (repositoryContentManager != null) - { - /* - * Delegate call to repository content manager. - */ - return repositoryContentManager.getKnownTypeDefGallery(); - } - else - { - OMRSErrorCode errorCode = OMRSErrorCode.LOCAL_REPOSITORY_CONFIGURATION_ERROR; - String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage(); + validateRepositoryContentManager(methodName); - throw new OMRSLogicErrorException(errorCode.getHTTPErrorCode(), - this.getClass().getName(), - methodName, - errorMessage, - errorCode.getSystemAction(), - errorCode.getUserAction()); - } + return repositoryContentManager.getKnownTypeDefGallery(); } @@ -155,25 +123,9 @@ public class OMRSRepositoryHelper implements OMRSTypeDefHelper, OMRSInstanceHelp { final String methodName = "getTypeDefByName"; - if (repositoryContentManager != null) - { - /* - * Delegate call to repository content manager. - */ - return repositoryContentManager.getTypeDefByName(sourceName, typeDefName); - } - else - { - OMRSErrorCode errorCode = OMRSErrorCode.LOCAL_REPOSITORY_CONFIGURATION_ERROR; - String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage(); + validateRepositoryContentManager(methodName); - throw new OMRSLogicErrorException(errorCode.getHTTPErrorCode(), - this.getClass().getName(), - methodName, - errorMessage, - errorCode.getSystemAction(), - errorCode.getUserAction()); - } + return repositoryContentManager.getTypeDefByName(sourceName, typeDefName); } @@ -191,25 +143,9 @@ public class OMRSRepositoryHelper implements OMRSTypeDefHelper, OMRSInstanceHelp { final String methodName = "getAttributeTypeDefByName"; - if (repositoryContentManager != null) - { - /* - * Delegate call to repository content manager. - */ - return repositoryContentManager.getAttributeTypeDefByName(sourceName, attributeTypeDefName); - } - else - { - OMRSErrorCode errorCode = OMRSErrorCode.LOCAL_REPOSITORY_CONFIGURATION_ERROR; - String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage(); + validateRepositoryContentManager(methodName); - throw new OMRSLogicErrorException(errorCode.getHTTPErrorCode(), - this.getClass().getName(), - methodName, - errorMessage, - errorCode.getSystemAction(), - errorCode.getUserAction()); - } + return repositoryContentManager.getAttributeTypeDefByName(sourceName, attributeTypeDefName); } @@ -226,25 +162,9 @@ public class OMRSRepositoryHelper implements OMRSTypeDefHelper, OMRSInstanceHelp { final String methodName = "getActiveTypesByWildCardName"; - if (repositoryContentManager != null) - { - /* - * Delegate call to repository content manager. - */ - return repositoryContentManager.getActiveTypesByWildCardName(sourceName, typeDefName); - } - else - { - OMRSErrorCode errorCode = OMRSErrorCode.LOCAL_REPOSITORY_CONFIGURATION_ERROR; - String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage(); + validateRepositoryContentManager(methodName); - throw new OMRSLogicErrorException(errorCode.getHTTPErrorCode(), - this.getClass().getName(), - methodName, - errorMessage, - errorCode.getSystemAction(), - errorCode.getUserAction()); - } + return repositoryContentManager.getActiveTypesByWildCardName(sourceName, typeDefName); } @@ -253,34 +173,20 @@ public class OMRSRepositoryHelper implements OMRSTypeDefHelper, OMRSInstanceHelp * retrieving a type that only the guid is known. * * @param sourceName - source of the request (used for logging) + * @param parameterName - name of guid parameter * @param typeDefGUID - unique identifier for the TypeDef + * @param methodName - calling method * @return TypeDef object * @throws TypeErrorException - unknown or invalid type */ public TypeDef getTypeDef(String sourceName, - String typeDefGUID) throws TypeErrorException + String parameterName, + String typeDefGUID, + String methodName) throws TypeErrorException { - final String methodName = "getTypeDef"; - - if (repositoryContentManager != null) - { - /* - * Delegate call to repository content manager. - */ - return repositoryContentManager.getTypeDef(sourceName, typeDefGUID); - } - else - { - OMRSErrorCode errorCode = OMRSErrorCode.LOCAL_REPOSITORY_CONFIGURATION_ERROR; - String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage(); + validateRepositoryContentManager(methodName); - throw new OMRSLogicErrorException(errorCode.getHTTPErrorCode(), - this.getClass().getName(), - methodName, - errorMessage, - errorCode.getSystemAction(), - errorCode.getUserAction()); - } + return repositoryContentManager.getTypeDef(sourceName, parameterName, typeDefGUID, methodName); } @@ -294,29 +200,12 @@ public class OMRSRepositoryHelper implements OMRSTypeDefHelper, OMRSInstanceHelp * @throws TypeErrorException - unknown or invalid type */ public AttributeTypeDef getAttributeTypeDef(String sourceName, - String attributeTypeDefGUID) throws TypeErrorException + String attributeTypeDefGUID, + String methodName) throws TypeErrorException { - final String methodName = "getAttributeTypeDef"; + validateRepositoryContentManager(methodName); - if (repositoryContentManager != null) - { - /* - * Delegate call to repository content manager. - */ - return repositoryContentManager.getAttributeTypeDef(sourceName, attributeTypeDefGUID); - } - else - { - OMRSErrorCode errorCode = OMRSErrorCode.LOCAL_REPOSITORY_CONFIGURATION_ERROR; - String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage(); - - throw new OMRSLogicErrorException(errorCode.getHTTPErrorCode(), - this.getClass().getName(), - methodName, - errorMessage, - errorCode.getSystemAction(), - errorCode.getUserAction()); - } + return repositoryContentManager.getAttributeTypeDef(sourceName, attributeTypeDefGUID, methodName); } @@ -325,36 +214,29 @@ public class OMRSRepositoryHelper implements OMRSTypeDefHelper, OMRSInstanceHelp * retrieving a type that should exist. For example, retrieving the type of a metadata instance. * * @param sourceName - source of the request (used for logging) + * @param guidParameterName - name of guid parameter + * @param nameParameterName - name of type name parameter * @param typeDefGUID - unique identifier for the TypeDef * @param typeDefName - unique name for the TypeDef + * @param methodName - calling method * @return TypeDef object * @throws TypeErrorException - unknown or invalid type */ public TypeDef getTypeDef(String sourceName, + String guidParameterName, + String nameParameterName, String typeDefGUID, - String typeDefName) throws TypeErrorException + String typeDefName, + String methodName) throws TypeErrorException { - final String methodName = "getTypeDef"; - - if (repositoryContentManager != null) - { - /* - * Delegate call to repository content manager. - */ - return repositoryContentManager.getTypeDef(sourceName, typeDefGUID, typeDefName); - } - else - { - OMRSErrorCode errorCode = OMRSErrorCode.LOCAL_REPOSITORY_CONFIGURATION_ERROR; - String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage(); - - throw new OMRSLogicErrorException(errorCode.getHTTPErrorCode(), - this.getClass().getName(), - methodName, - errorMessage, - errorCode.getSystemAction(), - errorCode.getUserAction()); - } + validateRepositoryContentManager(methodName); + + return repositoryContentManager.getTypeDef(sourceName, + guidParameterName, + nameParameterName, + typeDefGUID, + typeDefName, + methodName); } @@ -366,34 +248,21 @@ public class OMRSRepositoryHelper implements OMRSTypeDefHelper, OMRSInstanceHelp * @param sourceName - source of the request (used for logging) * @param attributeTypeDefGUID - unique identifier for the AttributeTypeDef * @param attributeTypeDefName - unique name for the AttributeTypeDef + * @param methodName - calling method * @return TypeDef object * @throws TypeErrorException - unknown or invalid type */ public AttributeTypeDef getAttributeTypeDef(String sourceName, String attributeTypeDefGUID, - String attributeTypeDefName) throws TypeErrorException + String attributeTypeDefName, + String methodName) throws TypeErrorException { - final String methodName = "getAttributeTypeDef"; + validateRepositoryContentManager(methodName); - if (repositoryContentManager != null) - { - /* - * Delegate call to repository content manager. - */ - return repositoryContentManager.getAttributeTypeDef(sourceName, attributeTypeDefGUID, attributeTypeDefName); - } - else - { - OMRSErrorCode errorCode = OMRSErrorCode.LOCAL_REPOSITORY_CONFIGURATION_ERROR; - String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage(); - - throw new OMRSLogicErrorException(errorCode.getHTTPErrorCode(), - this.getClass().getName(), - methodName, - errorMessage, - errorCode.getSystemAction(), - errorCode.getUserAction()); - } + return repositoryContentManager.getAttributeTypeDef(sourceName, + attributeTypeDefGUID, + attributeTypeDefName, + methodName); } @@ -414,6 +283,9 @@ public class OMRSRepositoryHelper implements OMRSTypeDefHelper, OMRSInstanceHelp TypeDefPatch typeDefPatch) throws PatchErrorException, InvalidParameterException { + final String methodName = "applyPatch"; + + validateRepositoryContentManager(methodName); TypeDef clonedTypeDef = null; TypeDef updatedTypeDef = null; @@ -765,7 +637,6 @@ public class OMRSRepositoryHelper implements OMRSTypeDefHelper, OMRSInstanceHelp * OMRSInstanceHelper */ - /** * Return an entity with the header and type information filled out. The caller only needs to add properties * and classifications to complete the set up of the entity. @@ -786,36 +657,23 @@ public class OMRSRepositoryHelper implements OMRSTypeDefHelper, OMRSInstanceHelp { final String methodName = "getSkeletonEntity"; - if (repositoryContentManager != null) - { - EntityDetail entity = new EntityDetail(); - String guid = UUID.randomUUID().toString(); + validateRepositoryContentManager(methodName); - entity.setInstanceProvenanceType(provenanceType); - entity.setMetadataCollectionId(metadataCollectionId); - entity.setCreateTime(new Date()); - entity.setGUID(guid); - entity.setVersion(1L); + EntityDetail entity = new EntityDetail(); + String guid = UUID.randomUUID().toString(); - entity.setType(repositoryContentManager.getInstanceType(sourceName, TypeDefCategory.ENTITY_DEF, typeName)); - entity.setStatus(repositoryContentManager.getInitialStatus(sourceName, typeName)); - entity.setCreatedBy(userName); - entity.setInstanceURL(repositoryContentManager.getInstanceURL(sourceName, guid)); + entity.setInstanceProvenanceType(provenanceType); + entity.setMetadataCollectionId(metadataCollectionId); + entity.setCreateTime(new Date()); + entity.setGUID(guid); + entity.setVersion(1L); - return entity; - } - else - { - OMRSErrorCode errorCode = OMRSErrorCode.LOCAL_REPOSITORY_CONFIGURATION_ERROR; - String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage(); + entity.setType(repositoryContentManager.getInstanceType(sourceName, TypeDefCategory.ENTITY_DEF, typeName, methodName)); + entity.setStatus(repositoryContentManager.getInitialStatus(sourceName, typeName, methodName)); + entity.setCreatedBy(userName); + entity.setInstanceURL(repositoryContentManager.getEntityURL(sourceName, guid)); - throw new OMRSLogicErrorException(errorCode.getHTTPErrorCode(), - this.getClass().getName(), - methodName, - errorMessage, - errorCode.getSystemAction(), - errorCode.getUserAction()); - } + return entity; } @@ -837,49 +695,40 @@ public class OMRSRepositoryHelper implements OMRSTypeDefHelper, OMRSInstanceHelp { final String methodName = "getSkeletonClassification"; - if (repositoryContentManager != null) + validateRepositoryContentManager(methodName); + + + if (repositoryContentManager.isValidTypeCategory(sourceName, + TypeDefCategory.CLASSIFICATION_DEF, + classificationTypeName, + methodName)) { - if (repositoryContentManager.isValidTypeCategory(sourceName, - TypeDefCategory.CLASSIFICATION_DEF, - classificationTypeName)) + if (repositoryContentManager.isValidClassificationForEntity(sourceName, + classificationTypeName, + entityTypeName, + methodName)) { - if (repositoryContentManager.isValidClassificationForEntity(sourceName, - classificationTypeName, - entityTypeName)) - { - Classification classification = new Classification(); - - classification.setName(classificationTypeName); - classification.setCreateTime(new Date()); - classification.setCreatedBy(userName); - classification.setVersion(1L); - classification.setType(repositoryContentManager.getInstanceType(sourceName, - TypeDefCategory.CLASSIFICATION_DEF, - classificationTypeName)); - classification.setStatus(repositoryContentManager.getInitialStatus(sourceName, - classificationTypeName)); - - return classification; - } - else - { - OMRSErrorCode errorCode = OMRSErrorCode.INVALID_CLASSIFICATION_FOR_ENTITY; - String errorMessage = errorCode.getErrorMessageId() - + errorCode.getFormattedErrorMessage(classificationTypeName, entityTypeName); - - throw new TypeErrorException(errorCode.getHTTPErrorCode(), - this.getClass().getName(), - methodName, - errorMessage, - errorCode.getSystemAction(), - errorCode.getUserAction()); - } + Classification classification = new Classification(); + + classification.setName(classificationTypeName); + classification.setCreateTime(new Date()); + classification.setCreatedBy(userName); + classification.setVersion(1L); + classification.setType(repositoryContentManager.getInstanceType(sourceName, + TypeDefCategory.CLASSIFICATION_DEF, + classificationTypeName, + methodName)); + classification.setStatus(repositoryContentManager.getInitialStatus(sourceName, + classificationTypeName, + methodName)); + + return classification; } else { - OMRSErrorCode errorCode = OMRSErrorCode.UNKNOWN_CLASSIFICATION; + OMRSErrorCode errorCode = OMRSErrorCode.INVALID_CLASSIFICATION_FOR_ENTITY; String errorMessage = errorCode.getErrorMessageId() - + errorCode.getFormattedErrorMessage(classificationTypeName); + + errorCode.getFormattedErrorMessage(classificationTypeName, entityTypeName); throw new TypeErrorException(errorCode.getHTTPErrorCode(), this.getClass().getName(), @@ -891,15 +740,16 @@ public class OMRSRepositoryHelper implements OMRSTypeDefHelper, OMRSInstanceHelp } else { - OMRSErrorCode errorCode = OMRSErrorCode.LOCAL_REPOSITORY_CONFIGURATION_ERROR; - String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage(); + OMRSErrorCode errorCode = OMRSErrorCode.UNKNOWN_CLASSIFICATION; + String errorMessage = errorCode.getErrorMessageId() + + errorCode.getFormattedErrorMessage(classificationTypeName); - throw new OMRSLogicErrorException(errorCode.getHTTPErrorCode(), - this.getClass().getName(), - methodName, - errorMessage, - errorCode.getSystemAction(), - errorCode.getUserAction()); + throw new TypeErrorException(errorCode.getHTTPErrorCode(), + this.getClass().getName(), + methodName, + errorMessage, + errorCode.getSystemAction(), + errorCode.getUserAction()); } } @@ -924,39 +774,26 @@ public class OMRSRepositoryHelper implements OMRSTypeDefHelper, OMRSInstanceHelp { final String methodName = "getSkeletonRelationship"; + validateRepositoryContentManager(methodName); - if (repositoryContentManager != null) - { - Relationship relationship = new Relationship(); - String guid = UUID.randomUUID().toString(); - - relationship.setInstanceProvenanceType(provenanceType); - relationship.setMetadataCollectionId(metadataCollectionId); - relationship.setCreateTime(new Date()); - relationship.setGUID(guid); - relationship.setVersion(1L); - - relationship.setType(repositoryContentManager.getInstanceType(sourceName, - TypeDefCategory.RELATIONSHIP_DEF, - typeName)); - relationship.setStatus(repositoryContentManager.getInitialStatus(sourceName, typeName)); - relationship.setCreatedBy(userName); - relationship.setInstanceURL(repositoryContentManager.getInstanceURL(sourceName, guid)); - - return relationship; - } - else - { - OMRSErrorCode errorCode = OMRSErrorCode.LOCAL_REPOSITORY_CONFIGURATION_ERROR; - String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage(); + Relationship relationship = new Relationship(); + String guid = UUID.randomUUID().toString(); - throw new OMRSLogicErrorException(errorCode.getHTTPErrorCode(), - this.getClass().getName(), - methodName, - errorMessage, - errorCode.getSystemAction(), - errorCode.getUserAction()); - } + relationship.setInstanceProvenanceType(provenanceType); + relationship.setMetadataCollectionId(metadataCollectionId); + relationship.setCreateTime(new Date()); + relationship.setGUID(guid); + relationship.setVersion(1L); + + relationship.setType(repositoryContentManager.getInstanceType(sourceName, + TypeDefCategory.RELATIONSHIP_DEF, + typeName, + methodName)); + relationship.setStatus(repositoryContentManager.getInitialStatus(sourceName, typeName, methodName)); + relationship.setCreatedBy(userName); + relationship.setInstanceURL(repositoryContentManager.getRelationshipURL(sourceName, guid)); + + return relationship; } @@ -974,24 +811,12 @@ public class OMRSRepositoryHelper implements OMRSTypeDefHelper, OMRSInstanceHelp { final String methodName = "getNewInstanceType"; - if (repositoryContentManager != null) - { - return repositoryContentManager.getInstanceType(sourceName, - typeDefSummary.getCategory(), - typeDefSummary.getName()); - } - else - { - OMRSErrorCode errorCode = OMRSErrorCode.LOCAL_REPOSITORY_CONFIGURATION_ERROR; - String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage(); + validateRepositoryContentManager(methodName); - throw new OMRSLogicErrorException(errorCode.getHTTPErrorCode(), - this.getClass().getName(), - methodName, - errorMessage, - errorCode.getSystemAction(), - errorCode.getUserAction()); - } + return repositoryContentManager.getInstanceType(sourceName, + typeDefSummary.getCategory(), + typeDefSummary.getName(), + methodName); } @@ -1241,7 +1066,7 @@ public class OMRSRepositoryHelper implements OMRSTypeDefHelper, OMRSInstanceHelp { Classification updatedClassification = new Classification(newClassification); - incrementVersion(userName, newClassification, updatedClassification); + updatedClassification = incrementVersion(userName, newClassification, updatedClassification); return this.addClassificationToEntity(sourceName, entity, updatedClassification, methodName); } @@ -1358,7 +1183,7 @@ public class OMRSRepositoryHelper implements OMRSTypeDefHelper, OMRSInstanceHelp * @param newProperties - properties to add/update * @return merged properties */ - public InstanceProperties mergeInstanceProperties(String sourceName, + public InstanceProperties mergeInstanceProperties(String sourceName, InstanceProperties existingProperties, InstanceProperties newProperties) { @@ -1396,15 +1221,59 @@ public class OMRSRepositoryHelper implements OMRSTypeDefHelper, OMRSInstanceHelp * @param originalInstance - original instance before the change * @param updatedInstance - new version of the instance that needs updating */ - public void incrementVersion(String userId, - InstanceAuditHeader originalInstance, - InstanceAuditHeader updatedInstance) + public Relationship incrementVersion(String userId, + InstanceAuditHeader originalInstance, + Relationship updatedInstance) { updatedInstance.setUpdatedBy(userId); updatedInstance.setUpdateTime(new Date()); long currentVersion = originalInstance.getVersion(); updatedInstance.setVersion(currentVersion++); + + return updatedInstance; + } + + + /** + * Changes the control information to reflect an update in an instance. + * + * @param userId - user making the change. + * @param originalInstance - original instance before the change + * @param updatedInstance - new version of the instance that needs updating + */ + public Classification incrementVersion(String userId, + InstanceAuditHeader originalInstance, + Classification updatedInstance) + { + updatedInstance.setUpdatedBy(userId); + updatedInstance.setUpdateTime(new Date()); + + long currentVersion = originalInstance.getVersion(); + updatedInstance.setVersion(currentVersion++); + + return updatedInstance; + } + + + /** + * Changes the control information to reflect an update in an instance. + * + * @param userId - user making the change. + * @param originalInstance - original instance before the change + * @param updatedInstance - new version of the instance that needs updating + */ + public EntityDetail incrementVersion(String userId, + InstanceAuditHeader originalInstance, + EntityDetail updatedInstance) + { + updatedInstance.setUpdatedBy(userId); + updatedInstance.setUpdateTime(new Date()); + + long currentVersion = originalInstance.getVersion(); + updatedInstance.setVersion(currentVersion++); + + return updatedInstance; } @@ -1416,9 +1285,13 @@ public class OMRSRepositoryHelper implements OMRSTypeDefHelper, OMRSInstanceHelp * @return - new entity proxy * @throws RepositoryErrorException - logic error in the repository - corrupted entity */ - public EntityProxy getNewEntityProxy(String sourceName, + public EntityProxy getNewEntityProxy(String sourceName, EntityDetail entity) throws RepositoryErrorException { + final String methodName = "getNewEntityProxy"; + final String parameterName = "entity"; + + validateRepositoryContentManager(methodName); if (entity != null) { @@ -1429,8 +1302,11 @@ public class OMRSRepositoryHelper implements OMRSTypeDefHelper, OMRSInstanceHelp try { TypeDef typeDef = repositoryContentManager.getTypeDef(sourceName, + parameterName, + parameterName, type.getTypeDefGUID(), - type.getTypeDefName()); + type.getTypeDefName(), + methodName); EntityProxy entityProxy = new EntityProxy(entity); InstanceProperties entityProperties = entity.getProperties(); @@ -1464,8 +1340,6 @@ public class OMRSRepositoryHelper implements OMRSTypeDefHelper, OMRSInstanceHelp } catch (TypeErrorException error) { - final String methodName = "getNewEntityProxy"; - OMRSErrorCode errorCode = OMRSErrorCode.REPOSITORY_LOGIC_ERROR; String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage(sourceName, methodName, @@ -1881,4 +1755,28 @@ public class OMRSRepositoryHelper implements OMRSTypeDefHelper, OMRSInstanceHelp errorCode.getSystemAction(), errorCode.getUserAction()); } + + + /** + * Throw a logic error exception if this object does not have a repository content manager. + * This would occur if if is being used in an environment where the OMRS has not been properly + * initialized. + * + * @param methodName - name of calling method. + */ + private void validateRepositoryContentManager(String methodName) + { + if (repositoryContentManager == null) + { + OMRSErrorCode errorCode = OMRSErrorCode.LOCAL_REPOSITORY_CONFIGURATION_ERROR; + String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage(); + + throw new OMRSLogicErrorException(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/localrepository/repositorycontentmanager/OMRSRepositoryValidator.java ---------------------------------------------------------------------- diff --git a/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositorycontentmanager/OMRSRepositoryValidator.java b/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositorycontentmanager/OMRSRepositoryValidator.java index 33add9e..3873e39 100644 --- a/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositorycontentmanager/OMRSRepositoryValidator.java +++ b/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositorycontentmanager/OMRSRepositoryValidator.java @@ -25,7 +25,6 @@ import org.apache.atlas.omrs.metadatacollection.properties.typedefs.*; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.ArrayList; import java.util.Date; import java.util.Iterator; import java.util.List; @@ -81,51 +80,6 @@ public class OMRSRepositoryValidator implements OMRSTypeDefValidator, OMRSInstan /** - * Return a summary list of the TypeDefs supported by the local metadata repository. This is - * broadcast to the other servers/repositories in the cluster during the membership registration exchanges - * managed by the cluster registries. - * - * @return TypeDefSummary iterator - */ - public ArrayList<TypeDefSummary> getLocalTypeDefs() - { - final String methodName = "getLocalTypeDefs()"; - - validateRepositoryContentManager(methodName); - - return repositoryContentManager.getLocalTypeDefs(); - } - - - /** - * Return a boolean flag indicating whether the list of TypeDefs passed are compatible with the - * local metadata repository. A true response means it is ok; false means conflicts have been found. - * - * A valid TypeDef is one that: - * <ul> - * <li> - * Matches name, GUID and version to a TypeDef in the local repository, or - * </li> - * <li> - * Is not defined in the local repository. - * </li> - * </ul> - * - * @param sourceName - source of the request (used for logging) - * @param typeDefSummaries - list of summary information about the TypeDefs. - */ - public void validateAgainstLocalTypeDefs(String sourceName, - List<TypeDefSummary> typeDefSummaries) - { - final String methodName = "validateAgainstLocalTypeDefs()"; - - validateRepositoryContentManager(methodName); - - repositoryContentManager.validateAgainstLocalTypeDefs(sourceName, typeDefSummaries); - } - - - /** * Return a boolean flag indicating whether the list of TypeDefs passed are compatible with the * all known typedefs. * @@ -168,55 +122,107 @@ public class OMRSRepositoryValidator implements OMRSTypeDefValidator, OMRSInstan /** - * Return boolean indicating whether the TypeDef is in use in the repository. + * Return boolean indicating whether the TypeDef/AttributeTypeDef is in use in the repository. + * + * @param sourceName - source of the request (used for logging) + * @param typeGUID - unique identifier of the type + * @param typeName - unique name of the type + * @return boolean flag + */ + public boolean isActiveType(String sourceName, String typeGUID, String typeName) + { + final String methodName = "isActiveType"; + + validateRepositoryContentManager(methodName); + + return repositoryContentManager.isActiveType(sourceName, typeGUID, typeName); + } + + + /** + * Return boolean indicating whether the TypeDef/AttributeTypeDef is in use in the repository. + * + * @param sourceName - source of the request (used for logging) + * @param typeGUID - unique identifier of the type + * @return boolean flag + */ + public boolean isActiveTypeId(String sourceName, String typeGUID) + { + final String methodName = "isActiveTypeId"; + + validateRepositoryContentManager(methodName); + + return repositoryContentManager.isActiveTypeId(sourceName, typeGUID); + } + + + /** + * Return boolean indicating whether the TypeDef is one of the open metadata types. * * @param sourceName - source of the request (used for logging) - * @param typeDefGUID - unique identifier of the type - * @param typeDefName - unique name of the type + * @param typeGUID - unique identifier of the type + * @param typeName - unique name of the type * @return boolean flag */ - public boolean isActiveType(String sourceName, String typeDefGUID, String typeDefName) + public boolean isOpenType(String sourceName, String typeGUID, String typeName) { - final String methodName = "isActiveType()"; + final String methodName = "isOpenType"; validateRepositoryContentManager(methodName); - return repositoryContentManager.isActiveType(sourceName, typeDefGUID, typeDefName); + return repositoryContentManager.isOpenType(sourceName, typeGUID, typeName); } + /** * Return boolean indicating whether the TypeDef is one of the open metadata types. * * @param sourceName - source of the request (used for logging) - * @param typeDefGUID - unique identifier of the type - * @param typeDefName - unique name of the type + * @param typeGUID - unique identifier of the type + * @return boolean flag + */ + public boolean isOpenTypeId(String sourceName, String typeGUID) + { + final String methodName = "isOpenTypeId"; + + validateRepositoryContentManager(methodName); + + return repositoryContentManager.isOpenTypeId(sourceName, typeGUID); + } + + + /** + * Return boolean indicating whether the TypeDef/AttributeTypeDef is in use in the repository. + * + * @param sourceName - source of the request (used for logging) + * @param typeGUID - unique identifier of the type + * @param typeName - unique name of the type * @return boolean flag */ - public boolean isOpenType(String sourceName, String typeDefGUID, String typeDefName) + public boolean isKnownType(String sourceName, String typeGUID, String typeName) { - final String methodName = "isOpenType()"; + final String methodName = "isKnownType"; validateRepositoryContentManager(methodName); - return repositoryContentManager.isOpenType(sourceName, typeDefGUID, typeDefName); + return repositoryContentManager.isKnownType(sourceName, typeGUID, typeName); } /** - * Return boolean indicating whether the TypeDef is in use in the repository. + * Return boolean indicating whether the TypeDef/AttributeTypeDef is in use in the repository. * * @param sourceName - source of the request (used for logging) - * @param typeDefGUID - unique identifier of the type - * @param typeDefName - unique name of the type + * @param typeGUID - unique identifier of the type * @return boolean flag */ - public boolean isKnownType(String sourceName, String typeDefGUID, String typeDefName) + public boolean isKnownTypeId(String sourceName, String typeGUID) { - final String methodName = "isKnownType()"; + final String methodName = "isKnownTypeId"; validateRepositoryContentManager(methodName); - return repositoryContentManager.isKnownType(sourceName, typeDefGUID, typeDefName); + return repositoryContentManager.isKnownTypeId(sourceName, typeGUID); } @@ -224,19 +230,19 @@ public class OMRSRepositoryValidator implements OMRSTypeDefValidator, OMRSInstan * Return boolean indicating whether the TypeDef identifiers are from a single known type or not. * * @param sourceName - source of the request (used for logging) - * @param typeDefGUID - unique identifier of the TypeDef - * @param typeDefName - unique name of the TypeDef + * @param typeGUID - unique identifier of the TypeDef + * @param typeName - unique name of the TypeDef * @return boolean result */ public boolean validTypeId(String sourceName, - String typeDefGUID, - String typeDefName) + String typeGUID, + String typeName) { - final String methodName = "validTypeId()"; + final String methodName = "validTypeId"; validateRepositoryContentManager(methodName); - return repositoryContentManager.validTypeId(sourceName, typeDefGUID, typeDefName); + return repositoryContentManager.validTypeId(sourceName, typeGUID, typeName); } @@ -254,7 +260,7 @@ public class OMRSRepositoryValidator implements OMRSTypeDefValidator, OMRSInstan String typeDefName, TypeDefCategory category) { - final String methodName = "validTypeDefId()"; + final String methodName = "validTypeDefId"; validateRepositoryContentManager(methodName); @@ -275,7 +281,7 @@ public class OMRSRepositoryValidator implements OMRSTypeDefValidator, OMRSInstan String attributeTypeDefName, AttributeTypeDefCategory category) { - final String methodName = "validAttributeTypeDefId()"; + final String methodName = "validAttributeTypeDefId"; validateRepositoryContentManager(methodName); @@ -303,7 +309,7 @@ public class OMRSRepositoryValidator implements OMRSTypeDefValidator, OMRSInstan long typeDefVersion, TypeDefCategory category) { - final String methodName = "validTypeDefId()"; + final String methodName = "validTypeDefId"; validateRepositoryContentManager(methodName); @@ -331,7 +337,7 @@ public class OMRSRepositoryValidator implements OMRSTypeDefValidator, OMRSInstan long attributeTypeDefVersion, AttributeTypeDefCategory category) { - final String methodName = "validAttributeTypeDefId()"; + final String methodName = "validAttributeTypeDefId"; validateRepositoryContentManager(methodName); @@ -354,7 +360,7 @@ public class OMRSRepositoryValidator implements OMRSTypeDefValidator, OMRSInstan public boolean validTypeDef(String sourceName, TypeDef typeDef) { - final String methodName = "validTypeDef()"; + final String methodName = "validTypeDef"; validateRepositoryContentManager(methodName); @@ -372,7 +378,7 @@ public class OMRSRepositoryValidator implements OMRSTypeDefValidator, OMRSInstan public boolean validAttributeTypeDef(String sourceName, AttributeTypeDef attributeTypeDef) { - final String methodName = "validAttributeTypeDef()"; + final String methodName = "validAttributeTypeDef"; validateRepositoryContentManager(methodName); @@ -390,7 +396,7 @@ public class OMRSRepositoryValidator implements OMRSTypeDefValidator, OMRSInstan public boolean validTypeDefSummary(String sourceName, TypeDefSummary typeDefSummary) { - final String methodName = "validTypeDefSummary()"; + final String methodName = "validTypeDefSummary"; validateRepositoryContentManager(methodName); @@ -697,11 +703,13 @@ public class OMRSRepositoryValidator implements OMRSTypeDefValidator, OMRSInstan * @param guid - unique identifier for a type or an instance passed on the request * @param methodName - method receiving the call * @throws InvalidParameterException - no guid provided + * @throws TypeErrorException - guid is not for a recognized type */ public void validateTypeGUID(String sourceName, String guidParameterName, String guid, - String methodName) throws InvalidParameterException + String methodName) throws InvalidParameterException, + TypeErrorException { if (guid == null) { @@ -718,6 +726,44 @@ public class OMRSRepositoryValidator implements OMRSTypeDefValidator, OMRSInstan errorCode.getSystemAction(), errorCode.getUserAction()); } + + validateOptionalTypeGUID(sourceName, guidParameterName, guid, methodName); + } + + + /** + * 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 - unknown type guid + */ + public void validateOptionalTypeGUID(String sourceName, + String guidParameterName, + String guid, + String methodName) throws TypeErrorException + { + if (guid != null) + { + if (! isKnownTypeId(sourceName, guid)) + { + 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()); + } + } } @@ -1462,9 +1508,9 @@ public class OMRSRepositoryValidator implements OMRSTypeDefValidator, OMRSInstan { OMRSErrorCode errorCode = OMRSErrorCode.NULL_CLASSIFICATION_NAME; String errorMessage = errorCode.getErrorMessageId() - + errorCode.getFormattedErrorMessage(parameterName, - methodName, - sourceName); + + errorCode.getFormattedErrorMessage(parameterName, + methodName, + sourceName); throw new InvalidParameterException(errorCode.getHTTPErrorCode(), this.getClass().getName(), @@ -1494,35 +1540,22 @@ public class OMRSRepositoryValidator implements OMRSTypeDefValidator, OMRSInstan String methodName) throws PropertyErrorException, TypeErrorException { - if (repositoryContentManager != null) - { - TypeDef classificationTypeDef = repositoryContentManager.getTypeDefByName(sourceName, classificationName); + validateRepositoryContentManager(methodName); - if (classificationTypeDef != null) - { - validatePropertiesForType(sourceName, propertiesParameterName, classificationTypeDef, classificationProperties, methodName); - } - else - { - /* - * Logic error as the type should be valid - */ - final String thisMethodName = "validateClassificationProperties"; + TypeDef classificationTypeDef = repositoryContentManager.getTypeDefByName(sourceName, classificationName); - throwValidatorLogicError(sourceName, methodName, thisMethodName); - } + if (classificationTypeDef != null) + { + validatePropertiesForType(sourceName, propertiesParameterName, classificationTypeDef, classificationProperties, methodName); } else { - OMRSErrorCode errorCode = OMRSErrorCode.LOCAL_REPOSITORY_CONFIGURATION_ERROR; - String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage(); + /* + * Logic error as the type should be valid + */ + final String thisMethodName = "validateClassificationProperties"; - throw new OMRSLogicErrorException(errorCode.getHTTPErrorCode(), - this.getClass().getName(), - methodName, - errorMessage, - errorCode.getSystemAction(), - errorCode.getUserAction()); + throwValidatorLogicError(sourceName, methodName, thisMethodName); } } @@ -1545,11 +1578,16 @@ public class OMRSRepositoryValidator implements OMRSTypeDefValidator, OMRSInstan String methodName) throws InvalidParameterException, ClassificationErrorException { + validateRepositoryContentManager(methodName); + this.validateClassificationName(sourceName, classificationParameterName, classificationName, methodName); - if (repositoryContentManager != null) + if (entityTypeName != null) { - if (! repositoryContentManager.isValidClassificationForEntity(sourceName, classificationName, entityTypeName)) + if (!repositoryContentManager.isValidClassificationForEntity(sourceName, + classificationName, + entityTypeName, + methodName)) { OMRSErrorCode errorCode = OMRSErrorCode.INVALID_CLASSIFICATION_FOR_ENTITY; String errorMessage = errorCode.getErrorMessageId() @@ -1565,18 +1603,6 @@ public class OMRSRepositoryValidator implements OMRSTypeDefValidator, OMRSInstan errorCode.getUserAction()); } } - else - { - OMRSErrorCode errorCode = OMRSErrorCode.LOCAL_REPOSITORY_CONFIGURATION_ERROR; - String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage(); - - throw new OMRSLogicErrorException(errorCode.getHTTPErrorCode(), - this.getClass().getName(), - methodName, - errorMessage, - errorCode.getSystemAction(), - errorCode.getUserAction()); - } } @@ -1602,41 +1628,28 @@ public class OMRSRepositoryValidator implements OMRSTypeDefValidator, OMRSInstan PropertyErrorException, TypeErrorException { + validateRepositoryContentManager(methodName); + if (classifications != null) { for (Classification classification : classifications) { if (classification != null) { - if (repositoryContentManager != null) - { - this.validateClassification(sourceName, - parameterName, - classification.getName(), - entityTypeName, - methodName); - - - this.validatePropertiesForType(sourceName, - parameterName, - repositoryContentManager.getTypeDefByName(sourceName, - classification.getName()), - classification.getProperties(), - methodName); - } - else - { - OMRSErrorCode errorCode = OMRSErrorCode.LOCAL_REPOSITORY_CONFIGURATION_ERROR; - String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage(); - throw new OMRSLogicErrorException(errorCode.getHTTPErrorCode(), - this.getClass().getName(), - methodName, - errorMessage, - errorCode.getSystemAction(), - errorCode.getUserAction()); - } + this.validateClassification(sourceName, + parameterName, + classification.getName(), + entityTypeName, + methodName); + + this.validatePropertiesForType(sourceName, + parameterName, + repositoryContentManager.getTypeDefByName(sourceName, + classification.getName()), + classification.getProperties(), + methodName); } else { @@ -2025,6 +2038,8 @@ public class OMRSRepositoryValidator implements OMRSTypeDefValidator, OMRSInstan String methodName) throws PropertyErrorException, TypeErrorException { + validateRepositoryContentManager(methodName); + if (typeDefSummary == null) { /* @@ -2035,11 +2050,12 @@ public class OMRSRepositoryValidator implements OMRSTypeDefValidator, OMRSInstan throwValidatorLogicError(sourceName, methodName, thisMethodName); } - validateRepositoryContentManager(methodName); - TypeDef typeDef = repositoryContentManager.getTypeDef(sourceName, + parameterName, + parameterName, typeDefSummary.getGUID(), - typeDefSummary.getName()); + typeDefSummary.getName(), + methodName); this.validatePropertiesForType(sourceName, parameterName, typeDef, properties, methodName); } @@ -2084,8 +2100,9 @@ public class OMRSRepositoryValidator implements OMRSTypeDefValidator, OMRSInstan /** * Verify whether the instance passed to this method is of the type indicated by the type guid. + * A null type guid matches all instances (ie result is true). A null instance returns false. * - * @param instanceTypeGUID - unique identifier of the type. + * @param instanceTypeGUID - unique identifier of the type (or null). * @param instance - instance to test. * @return boolean */ @@ -2094,7 +2111,14 @@ public class OMRSRepositoryValidator implements OMRSTypeDefValidator, OMRSInstan { if (instance != null) { - if (instanceTypeGUID != null) + if (instanceTypeGUID == null) + { + /* + * A null instance type matches all instances + */ + return true; + } + else { InstanceType entityType = instance.getType(); @@ -3165,6 +3189,13 @@ public class OMRSRepositoryValidator implements OMRSTypeDefValidator, OMRSInstan */ + /** + * Throw a logic error exception if this object does not have a repository content manager. + * This would occur if if is being used in an environment where the OMRS has not been properly + * initialized. + * + * @param methodName - name of calling method. + */ private void validateRepositoryContentManager(String methodName) { if (repositoryContentManager == null) http://git-wip-us.apache.org/repos/asf/atlas/blob/5cfb0228/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositorycontentmanager/OMRSTypeDefHelper.java ---------------------------------------------------------------------- diff --git a/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositorycontentmanager/OMRSTypeDefHelper.java b/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositorycontentmanager/OMRSTypeDefHelper.java index 565c267..ed2ed81 100644 --- a/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositorycontentmanager/OMRSTypeDefHelper.java +++ b/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositorycontentmanager/OMRSTypeDefHelper.java @@ -17,13 +17,10 @@ */ package org.apache.atlas.omrs.localrepository.repositorycontentmanager; -import org.apache.atlas.omrs.ffdc.exception.InvalidParameterException; -import org.apache.atlas.omrs.ffdc.exception.PatchErrorException; import org.apache.atlas.omrs.ffdc.exception.TypeErrorException; import org.apache.atlas.omrs.metadatacollection.properties.typedefs.AttributeTypeDef; import org.apache.atlas.omrs.metadatacollection.properties.typedefs.TypeDef; import org.apache.atlas.omrs.metadatacollection.properties.typedefs.TypeDefGallery; -import org.apache.atlas.omrs.metadatacollection.properties.typedefs.TypeDefPatch; /** @@ -91,12 +88,16 @@ public interface OMRSTypeDefHelper * retrieving a type that only the guid is known. * * @param sourceName - source of the request (used for logging) + * @param parameterName - name of parameter * @param typeDefGUID - unique identifier for the TypeDef + * @param methodName - calling method * @return TypeDef object * @throws TypeErrorException - unknown or invalid type */ TypeDef getTypeDef (String sourceName, - String typeDefGUID) throws TypeErrorException; + String parameterName, + String typeDefGUID, + String methodName) throws TypeErrorException; /** @@ -109,7 +110,8 @@ public interface OMRSTypeDefHelper * @throws TypeErrorException - unknown or invalid type */ AttributeTypeDef getAttributeTypeDef (String sourceName, - String attributeTypeDefGUID) throws TypeErrorException; + String attributeTypeDefGUID, + String methodName) throws TypeErrorException; @@ -118,14 +120,20 @@ public interface OMRSTypeDefHelper * retrieving a type that should exist. For example, retrieving the type of a metadata instance. * * @param sourceName - source of the request (used for logging) + * @param guidParameterName - name of guid parameter + * @param nameParameterName - name of name parameter * @param typeDefGUID - unique identifier for the TypeDef * @param typeDefName - unique name for the TypeDef + * @param methodName - calling method * @return TypeDef object * @throws TypeErrorException - unknown or invalid type */ TypeDef getTypeDef (String sourceName, + String guidParameterName, + String nameParameterName, String typeDefGUID, - String typeDefName) throws TypeErrorException; + String typeDefName, + String methodName) throws TypeErrorException; /** @@ -136,10 +144,12 @@ public interface OMRSTypeDefHelper * @param sourceName - source of the request (used for logging) * @param attributeTypeDefGUID - unique identifier for the AttributeTypeDef * @param attributeTypeDefName - unique name for the AttributeTypeDef + * @param methodName - calling method * @return TypeDef object * @throws TypeErrorException - unknown or invalid type */ AttributeTypeDef getAttributeTypeDef (String sourceName, String attributeTypeDefGUID, - String attributeTypeDefName) throws TypeErrorException; + String attributeTypeDefName, + String methodName) throws TypeErrorException; } http://git-wip-us.apache.org/repos/asf/atlas/blob/5cfb0228/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositorycontentmanager/OMRSTypeDefManager.java ---------------------------------------------------------------------- diff --git a/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositorycontentmanager/OMRSTypeDefManager.java b/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositorycontentmanager/OMRSTypeDefManager.java index eb4402a..c4f125a 100644 --- a/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositorycontentmanager/OMRSTypeDefManager.java +++ b/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositorycontentmanager/OMRSTypeDefManager.java @@ -58,15 +58,6 @@ public interface OMRSTypeDefManager /** - * Update one or more properties of a cached TypeDef. - * - * @param sourceName - source of the request (used for logging) - * @param attributeTypeDef - AttributeTypeDef structure. - */ - void updateAttributeTypeDef(String sourceName, AttributeTypeDef attributeTypeDef); - - - /** * Delete a cached TypeDef. * * @param sourceName - source of the request (used for logging) @@ -82,12 +73,12 @@ public interface OMRSTypeDefManager * Delete a cached AttributeTypeDef. * * @param sourceName - source of the request (used for logging) - * @param obsoleteTypeDefGUID - String unique identifier for the AttributeTypeDef. - * @param obsoleteTypeDefName - String unique name for the AttributeTypeDef. + * @param obsoleteAttributeTypeDefGUID - String unique identifier for the AttributeTypeDef. + * @param obsoleteAttributeTypeDefName - String unique name for the AttributeTypeDef. */ void deleteAttributeTypeDef(String sourceName, - String obsoleteTypeDefGUID, - String obsoleteTypeDefName); + String obsoleteAttributeTypeDefGUID, + String obsoleteAttributeTypeDefName); /** @@ -124,13 +115,15 @@ public interface OMRSTypeDefManager * @param sourceName - source of the request (used for logging) * @param category - TypeDefCategory enum value to test * @param typeName - type name to test + * @param methodName - name of calling method. * @return - boolean flag indicating that the type name is of the specified category * @throws TypeErrorException - the type name is not a recognized type or the category is incorrect or there * is an error in the type definition (TypeDef) cached. */ boolean isValidTypeCategory(String sourceName, TypeDefCategory category, - String typeName) throws TypeErrorException; + String typeName, + String methodName) throws TypeErrorException; /** @@ -140,13 +133,15 @@ public interface OMRSTypeDefManager * @param sourceName - source of the request (used for logging) * @param classificationTypeName - name of the classification's type (ClassificationDef) * @param entityTypeName - name of the entity's type (EntityDef) + * @param methodName - name of calling method. * @return boolean indicating if the classification is valid for the entity. * @throws TypeErrorException - the type name is not a recognized type or the category is incorrect or there * is an error in the type definition (TypeDef) cached. */ boolean isValidClassificationForEntity(String sourceName, String classificationTypeName, - String entityTypeName) throws TypeErrorException; + String entityTypeName, + String methodName) throws TypeErrorException; /** @@ -156,13 +151,15 @@ public interface OMRSTypeDefManager * @param sourceName - source of the request (used for logging) * @param category - category of type * @param typeName - String type name - the type name is not recognized or of the wrong category. + * @param methodName - name of calling method. * @return InstanceType object containing TypeDef unique identifier (guid), typeDef name and version * @throws TypeErrorException - the type name is not a recognized type or the category is incorrect or there * is an error in the type definition (TypeDef) cached. */ InstanceType getInstanceType(String sourceName, TypeDefCategory category, - String typeName) throws TypeErrorException; + String typeName, + String methodName) throws TypeErrorException; /** @@ -173,17 +170,27 @@ public interface OMRSTypeDefManager * @return InstanceStatus enum * @throws TypeErrorException - the type name is not recognized. */ - InstanceStatus getInitialStatus(String sourceName, String typeName) throws TypeErrorException; + InstanceStatus getInitialStatus(String sourceName, + String typeName, + String methodName) throws TypeErrorException; + + + /** + * Return the URL string to use for direct access to the metadata instance. + * + * @param sourceName - source of the request (used for logging) + * @param guid - unique identifier for the instance. + * @return String URL with placeholder for variables such as userId. + */ + String getEntityURL(String sourceName, String guid); /** - * Return the URL string to use for direct access to the metadata instance. This can be used for - * entities and relationships. However, not all servers support direct access, in which case, this - * URL is null. + * Return the URL string to use for direct access to the metadata instance. * * @param sourceName - source of the request (used for logging) * @param guid - unique identifier for the instance. * @return String URL with placeholder for variables such as userId. */ - String getInstanceURL(String sourceName, String guid); + String getRelationshipURL(String sourceName, String guid); } http://git-wip-us.apache.org/repos/asf/atlas/blob/5cfb0228/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositorycontentmanager/OMRSTypeDefValidator.java ---------------------------------------------------------------------- diff --git a/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositorycontentmanager/OMRSTypeDefValidator.java b/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositorycontentmanager/OMRSTypeDefValidator.java index 733de07..fc58cdf 100644 --- a/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositorycontentmanager/OMRSTypeDefValidator.java +++ b/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositorycontentmanager/OMRSTypeDefValidator.java @@ -20,7 +20,6 @@ package org.apache.atlas.omrs.localrepository.repositorycontentmanager; import org.apache.atlas.omrs.ffdc.exception.RepositoryErrorException; import org.apache.atlas.omrs.metadatacollection.properties.typedefs.*; -import java.util.ArrayList; import java.util.List; /** @@ -29,37 +28,6 @@ import java.util.List; public interface OMRSTypeDefValidator { /** - * Return a summary list of the TypeDefs supported by the local metadata repository. This is - * broadcast to the other servers/repositories in the cohort during the membership registration exchanges - * managed by the cohort registries. - * - * @return TypeDefSummary list - */ - ArrayList<TypeDefSummary> getLocalTypeDefs(); - - - /** - * Return a boolean flag indicating whether the list of TypeDefs passed are compatible with the - * local metadata repository. A true response means it is ok; false means conflicts have been found. - * - * A valid TypeDef is one that: - * <ul> - * <li> - * Matches name, GUID and version to a TypeDef in the local repository, or - * </li> - * <li> - * Is not defined in the local repository. - * </li> - * </ul> - * - * @param sourceName - source of the request (used for logging) - * @param typeDefSummaries - list of summary information about the TypeDefs. - */ - void validateAgainstLocalTypeDefs(String sourceName, - List<TypeDefSummary> typeDefSummaries); - - - /** * Return a boolean flag indicating whether the list of TypeDefs passed are compatible with the * all known typedefs. * @@ -94,14 +62,24 @@ public interface OMRSTypeDefValidator /** - * Return boolean indicating whether the TypeDef or AttributeTypeDef is one of the standard open metadata types. + * Return boolean indicating whether the TypeDef is one of the standard open metadata types. + * + * @param sourceName - source of the request (used for logging) + * @param typeGUID - unique identifier of the type + * @param typeName - unique name of the type + * @return boolean result + */ + boolean isOpenType(String sourceName, String typeGUID, String typeName); + + + /** + * Return boolean indicating whether the TypeDef is one of the standard open metadata types. * * @param sourceName - source of the request (used for logging) - * @param typeDefGUID - unique identifier of the type - * @param typeDefName - unique name of the type + * @param typeGUID - unique identifier of the type * @return boolean result */ - boolean isOpenType(String sourceName, String typeDefGUID, String typeDefName); + boolean isOpenTypeId(String sourceName, String typeGUID); /** @@ -109,35 +87,56 @@ public interface OMRSTypeDefValidator * by one or more of the members of the cohort. * * @param sourceName - source of the request (used for logging) - * @param typeDefGUID - unique identifier of the type - * @param typeDefName - unique name of the type + * @param typeGUID - unique identifier of the type + * @param typeName - unique name of the type * @return boolean result */ - boolean isKnownType(String sourceName, String typeDefGUID, String typeDefName); + boolean isKnownType(String sourceName, String typeGUID, String typeName); + + + /** + * Return boolean indicating whether the TypeDef/AttributeTypeDef is known, either as an open type, or one defined + * by one or more of the members of the cohort. + * + * @param sourceName - source of the request (used for logging) + * @param typeGUID - unique identifier of the type + * @return boolean result + */ + boolean isKnownTypeId(String sourceName, String typeGUID); /** * Return boolean indicating whether the TypeDef/AttributeTypeDef is in use in the local repository. * * @param sourceName - source of the request (used for logging) - * @param typeDefGUID - unique identifier of the type - * @param typeDefName - unique name of the type + * @param typeGUID - unique identifier of the type + * @param typeName - unique name of the type * @return boolean result */ - boolean isActiveType(String sourceName, String typeDefGUID, String typeDefName); + boolean isActiveType(String sourceName, String typeGUID, String typeName); + + + /** + * Return boolean indicating whether the TypeDef/AttributeTypeDef is in use in the local repository. + * + * @param sourceName - source of the request (used for logging) + * @param typeGUID - unique identifier of the type + * @return boolean result + */ + boolean isActiveTypeId(String sourceName, String typeGUID); /** * Return boolean indicating whether the TypeDef/AttributeTypeDef identifiers are from a single known type or not. * * @param sourceName - source of the request (used for logging) - * @param typeDefGUID - unique identifier of the TypeDef - * @param typeDefName - unique name of the TypeDef + * @param typeGUID - unique identifier of the TypeDef + * @param typeName - unique name of the TypeDef * @return boolean result */ boolean validTypeId(String sourceName, - String typeDefGUID, - String typeDefName); + String typeGUID, + String typeName); /**
