Commit 5cfb0228 by Mandy Chessell Committed by David Radley

ATLAS-2585 Fix up validation of TypDef GUIDs

parent 810aceb5
......@@ -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 ",
......
......@@ -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());
}
}
}
}
......@@ -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).
......
......@@ -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);
......
......@@ -26,7 +26,6 @@ import org.apache.atlas.omrs.metadatacollection.properties.instances.InstanceTyp
import org.apache.atlas.omrs.metadatacollection.properties.typedefs.TypeDef;
import org.apache.atlas.omrs.metadatacollection.properties.typedefs.TypeDefSummary;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
......@@ -276,6 +275,9 @@ public class OMRSRepositoryEventExchangeRule
*/
public boolean learnInstanceEvent(InstanceHeader instance)
{
final String methodName = "learnInstanceEvent";
final String parameterName = "instance";
if (repositoryContentManager == null)
{
/*
......@@ -300,8 +302,11 @@ public class OMRSRepositoryEventExchangeRule
try
{
TypeDef typeDef = repositoryContentManager.getTypeDef(sourceName,
parameterName,
parameterName,
type.getTypeDefGUID(),
type.getTypeDefName());
type.getTypeDefName(),
methodName);
if (typeDef != null)
{
......
......@@ -419,23 +419,27 @@ public enum OMRSErrorCode
"The TypeDef \"{0}\" (guid = {1}) passed on the {2} parameter of the {3} operation is not known to the open metadata repository {4}",
"The system is unable to retrieve the properties for the requested TypeDef because the supplied identifier is not recognized.",
"The identifier is supplied by the caller. It may have a logic problem that has corrupted the identifier, or the typedef has been deleted since the identifier was retrieved."),
ATTRIBUTE_TYPEDEF_NOT_KNOWN(404, "OMRS-REPOSITORY-404-004 ",
TYPEDEF_NOT_KNOWN_FOR_INSTANCE(404, "OMRS-REPOSITORY-404-005 ",
"The TypeDef \"{0}\" of category \"{1}\" passed by the {2} operation is not known to the open metadata repository {3}",
"The system is unable to retrieve the properties for the requested TypeDef because the supplied identifier is not recognized.",
"The identifier is supplied by the caller. It may have a logic problem that has corrupted the identifier, or the typedef has been deleted since the identifier was retrieved."),
ATTRIBUTE_TYPEDEF_NOT_KNOWN(404, "OMRS-REPOSITORY-404-006 ",
"The AttributeTypeDef \"{0}\" (guid = {1}) passed on the {2} call is not known to the open metadata repository {3}",
"The system is unable to retrieve the properties for the requested TypeDef because the supplied identifier is not recognized.",
"The identifier is supplied by the caller. It may have a logic problem that has corrupted the identifier, or the typedef has been deleted since the identifier was retrieved."),
TYPEDEF_ID_NOT_KNOWN(404, "OMRS-REPOSITORY-404-005 ",
"The TypeDef unique identifier {0} passed on a {1} request to open metadata repository {2} is not known to this repository",
TYPEDEF_ID_NOT_KNOWN(404, "OMRS-REPOSITORY-404-007 ",
"The TypeDef unique identifier {0} passed as parameter {1} on a {2} request to open metadata repository {3} is not known to this repository",
"The system is unable to retrieve the properties for the requested TypeDef because the supplied identifiers are not recognized.",
"The identifier is supplied by the caller. It may have a logic problem that has corrupted the identifier, or the TypeDef has been deleted since the identifier was retrieved."),
ATTRIBUTE_TYPEDEF_ID_NOT_KNOWN(404, "OMRS-REPOSITORY-404-006 ",
ATTRIBUTE_TYPEDEF_ID_NOT_KNOWN(404, "OMRS-REPOSITORY-404-008 ",
"The AttributeTypeDef \"{0}\" (guid {1}) passed on a {2} request to open metadata repository {3} is not known to this repository",
"The system is unable to retrieve the properties for the requested AttributeTypeDef because the supplied identifiers are not recognized.",
"The identifier is supplied by the caller. It may have a logic problem that has corrupted the identifier, or the AttributeTypeDef has been deleted since the identifier was retrieved."),
TYPEDEF_NAME_NOT_KNOWN(404, "OMRS-REPOSITORY-404-007 ",
TYPEDEF_NAME_NOT_KNOWN(404, "OMRS-REPOSITORY-404-009 ",
"The TypeDef unique name {0} passed on a {1} request to open metadata repository {2} is not known to this repository",
"The system is unable to retrieve the properties for the requested TypeDef because the supplied identifiers are not recognized.",
"The identifier is supplied by the caller. It may have a logic problem that has corrupted the identifier, or the TypeDef has been deleted since the identifier was retrieved."),
ATTRIBUTE_TYPEDEF_NAME_NOT_KNOWN(404, "OMRS-REPOSITORY-404-008 ",
ATTRIBUTE_TYPEDEF_NAME_NOT_KNOWN(404, "OMRS-REPOSITORY-404-010 ",
"The TypeDef unique name {0} passed on a {1} request to open metadata repository {2} is not known to this repository",
"The system is unable to retrieve the properties for the requested TypeDef because the supplied identifiers are not recognized.",
"The identifier is supplied by the caller. It may have a logic problem that has corrupted the identifier, or the TypeDef has been deleted since the identifier was retrieved."),
......@@ -619,7 +623,11 @@ public enum OMRSErrorCode
"An OMRS repository connector {0} has passed an invalid parameter to the repository helper {1} operation as part of the {2} request",
"The open metadata component has called the repository helper operations in the wrong order or has a similar logic error.",
"Raise a Jira to get this fixed."),
NULL_CLASSIFICATION_CREATED(503, "OMRS-LOCAL-REPOSITORY-503-006 ",
CONTENT_MANAGER_LOGIC_ERROR(503, "OMRS-LOCAL-REPOSITORY-503-007 ",
"An OMRS repository connector {0} has passed an invalid parameter to the repository content manager {1} operation as part of the {2} request",
"The open metadata component has called the repository helper operations in the wrong order or has a similar logic error.",
"Raise a Jira to get this fixed."),
NULL_CLASSIFICATION_CREATED(503, "OMRS-LOCAL-REPOSITORY-503-008 ",
"An OMRS repository connector or access server {0} has passed a null classification to the repository helper {1} operation as part of the {2} request",
"The repository connector has called the repository helper operations in the wrong order or has a similar logic error.",
"Raise a Jira to get this fixed."),
......
......@@ -21,7 +21,6 @@ import org.apache.atlas.ocf.properties.beans.Connection;
import org.apache.atlas.omrs.eventmanagement.events.OMRSInstanceEventProcessor;
import org.apache.atlas.omrs.eventmanagement.OMRSRepositoryEventManager;
import org.apache.atlas.omrs.eventmanagement.events.OMRSTypeDefEventProcessor;
import org.apache.atlas.omrs.localrepository.repositorycontentmanager.OMRSTypeDefValidator;
/**
......@@ -48,15 +47,6 @@ public interface OMRSLocalRepository
/**
* Return the TypeDefManager. This is used to validate that a list of type definitions (TypeDefs) are
* compatible with the local repository.
*
* @return OMRSTypeDefValidator object for the local repository.
*/
OMRSTypeDefValidator getTypeDefValidator();
/**
* Return the event manager that the local repository uses to
*
* @return outbound repository event manager
......
......@@ -38,6 +38,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.List;
/**
......@@ -1119,11 +1120,11 @@ public class LocalOMRSInstanceEventProcessor implements OMRSInstanceEventProcess
* @param entities - the retrieved relationships
* @return the validated and processed relationships
*/
public ArrayList<EntityDetail> processRetrievedEntities(String sourceName,
String metadataCollectionId,
ArrayList<EntityDetail> entities)
public List<EntityDetail> processRetrievedEntities(String sourceName,
String metadataCollectionId,
List<EntityDetail> entities)
{
ArrayList<EntityDetail> processedEntities = new ArrayList<>();
List<EntityDetail> processedEntities = new ArrayList<>();
for (EntityDetail entity : entities)
{
......@@ -1221,11 +1222,11 @@ public class LocalOMRSInstanceEventProcessor implements OMRSInstanceEventProcess
* @param relationships - the list of retrieved relationships
* @return the validated and processed relationships
*/
public ArrayList<Relationship> processRetrievedRelationships(String sourceName,
String metadataCollectionId,
ArrayList<Relationship> relationships)
public List<Relationship> processRetrievedRelationships(String sourceName,
String metadataCollectionId,
List<Relationship> relationships)
{
ArrayList<Relationship> processedRelationships = new ArrayList<>();
List<Relationship> processedRelationships = new ArrayList<>();
for (Relationship relationship : relationships)
{
......
......@@ -422,7 +422,7 @@ public class LocalOMRSMetadataCollection extends OMRSMetadataCollection
parentConnector.validateRepositoryIsActive(methodName);
repositoryValidator.validateUserId(repositoryName, userId, methodName);
repositoryValidator.validateTypeGUID(repositoryName, guidParameterName, guid, methodName);
repositoryValidator.validateGUID(repositoryName, guidParameterName, guid, methodName);
/*
* Perform operation
......@@ -460,7 +460,7 @@ public class LocalOMRSMetadataCollection extends OMRSMetadataCollection
parentConnector.validateRepositoryIsActive(methodName);
repositoryValidator.validateUserId(repositoryName, userId, methodName);
repositoryValidator.validateTypeGUID(repositoryName, guidParameterName, guid, methodName);
repositoryValidator.validateGUID(repositoryName, guidParameterName, guid, methodName);
/*
* Perform operation
......@@ -1205,11 +1205,12 @@ public class LocalOMRSMetadataCollection 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.
......@@ -1258,7 +1259,8 @@ public class LocalOMRSMetadataCollection 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
......@@ -1454,6 +1456,8 @@ public class LocalOMRSMetadataCollection 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.
......@@ -1471,6 +1475,7 @@ public class LocalOMRSMetadataCollection extends OMRSMetadataCollection
String sequencingProperty,
SequencingOrder sequencingOrder,
int pageSize) throws InvalidParameterException,
TypeErrorException,
RepositoryErrorException,
EntityNotKnownException,
PropertyErrorException,
......@@ -1481,6 +1486,7 @@ public class LocalOMRSMetadataCollection extends OMRSMetadataCollection
final String methodName = "getRelationshipsForEntity";
final String guidParameterName = "entityGUID";
final String asOfTimeParameter = "asOfTime";
final String typeGUIDParameter = "relationshipTypeGUID";
final String pageSizeParameter = "pageSize";
/*
......@@ -1491,6 +1497,7 @@ public class LocalOMRSMetadataCollection 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);
......@@ -1534,10 +1541,10 @@ public class LocalOMRSMetadataCollection 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.
......@@ -1555,8 +1562,8 @@ public class LocalOMRSMetadataCollection extends OMRSMetadataCollection
String sequencingProperty,
SequencingOrder sequencingOrder,
int pageSize) throws InvalidParameterException,
RepositoryErrorException,
TypeErrorException,
RepositoryErrorException,
PropertyErrorException,
PagingErrorException,
FunctionNotSupportedException,
......@@ -1576,7 +1583,7 @@ public class LocalOMRSMetadataCollection extends OMRSMetadataCollection
parentConnector.validateRepositoryIsActive(methodName);
repositoryValidator.validateUserId(repositoryName, userId, methodName);
repositoryValidator.validateTypeGUID(repositoryName, guidParameterName, entityTypeGUID, methodName);
repositoryValidator.validateOptionalTypeGUID(repositoryName, guidParameterName, entityTypeGUID, methodName);
repositoryValidator.validateAsOfTime(repositoryName, asOfTimeParameter, asOfTime, methodName);
repositoryValidator.validatePageSize(repositoryName, pageSizeParameter, pageSize, methodName);
repositoryValidator.validateMatchCriteria(repositoryName,
......@@ -1627,10 +1634,10 @@ public class LocalOMRSMetadataCollection 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.
......@@ -1649,8 +1656,8 @@ public class LocalOMRSMetadataCollection extends OMRSMetadataCollection
String sequencingProperty,
SequencingOrder sequencingOrder,
int pageSize) throws InvalidParameterException,
RepositoryErrorException,
TypeErrorException,
RepositoryErrorException,
ClassificationErrorException,
PropertyErrorException,
PagingErrorException,
......@@ -1674,16 +1681,31 @@ public class LocalOMRSMetadataCollection 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,
......@@ -1691,11 +1713,6 @@ public class LocalOMRSMetadataCollection extends OMRSMetadataCollection
matchCriteria,
matchClassificationProperties,
methodName);
repositoryValidator.validateClassification(repositoryName,
classificationParameterName,
classificationName,
entityTypeDef.getName(),
methodName);
/*
* Perform operation
......@@ -1740,6 +1757,8 @@ public class LocalOMRSMetadataCollection 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
......@@ -1758,6 +1777,7 @@ public class LocalOMRSMetadataCollection extends OMRSMetadataCollection
String sequencingProperty,
SequencingOrder sequencingOrder,
int pageSize) throws InvalidParameterException,
TypeErrorException,
RepositoryErrorException,
PropertyErrorException,
PagingErrorException,
......@@ -1767,6 +1787,7 @@ public class LocalOMRSMetadataCollection extends OMRSMetadataCollection
final String methodName = "findEntitiesByPropertyValue";
final String searchCriteriaParameterName = "searchCriteria";
final String asOfTimeParameter = "asOfTime";
final String guidParameterName = "entityTypeGUID";
final String pageSizeParameter = "pageSize";
/*
......@@ -1777,6 +1798,7 @@ public class LocalOMRSMetadataCollection extends OMRSMetadataCollection
repositoryValidator.validateUserId(repositoryName, userId, methodName);
repositoryValidator.validateSearchCriteria(repositoryName, searchCriteriaParameterName, searchCriteria, methodName);
repositoryValidator.validateOptionalTypeGUID(repositoryName, guidParameterName, entityTypeGUID, methodName);
repositoryValidator.validateAsOfTime(repositoryName, asOfTimeParameter, asOfTime, methodName);
repositoryValidator.validatePageSize(repositoryName, pageSizeParameter, pageSize, methodName);
......@@ -1940,10 +1962,10 @@ public class LocalOMRSMetadataCollection 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.
......@@ -1960,8 +1982,8 @@ public class LocalOMRSMetadataCollection extends OMRSMetadataCollection
String sequencingProperty,
SequencingOrder sequencingOrder,
int pageSize) throws InvalidParameterException,
RepositoryErrorException,
TypeErrorException,
RepositoryErrorException,
PropertyErrorException,
PagingErrorException,
FunctionNotSupportedException,
......@@ -1981,7 +2003,7 @@ public class LocalOMRSMetadataCollection extends OMRSMetadataCollection
parentConnector.validateRepositoryIsActive(methodName);
repositoryValidator.validateUserId(repositoryName, userId, methodName);
repositoryValidator.validateTypeGUID(repositoryName, guidParameterName, relationshipTypeGUID, methodName);
repositoryValidator.validateOptionalTypeGUID(repositoryName, guidParameterName, relationshipTypeGUID, methodName);
repositoryValidator.validateAsOfTime(repositoryName, asOfTimeParameter, asOfTime, methodName);
repositoryValidator.validatePageSize(repositoryName, pageSizeParameter, pageSize, methodName);
repositoryValidator.validateMatchCriteria(repositoryName,
......@@ -2032,6 +2054,8 @@ public class LocalOMRSMetadataCollection 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.
......@@ -2048,6 +2072,7 @@ public class LocalOMRSMetadataCollection extends OMRSMetadataCollection
String sequencingProperty,
SequencingOrder sequencingOrder,
int pageSize) throws InvalidParameterException,
TypeErrorException,
RepositoryErrorException,
PropertyErrorException,
PagingErrorException,
......@@ -2056,6 +2081,7 @@ public class LocalOMRSMetadataCollection extends OMRSMetadataCollection
{
final String methodName = "findRelationshipsByPropertyValue";
final String asOfTimeParameter = "asOfTime";
final String guidParameter = "relationshipTypeGUID";
final String pageSizeParameter = "pageSize";
/*
......@@ -2065,6 +2091,7 @@ public class LocalOMRSMetadataCollection extends OMRSMetadataCollection
parentConnector.validateRepositoryIsActive(methodName);
repositoryValidator.validateUserId(repositoryName, userId, methodName);
repositoryValidator.validateOptionalTypeGUID(repositoryName, guidParameter, relationshipTypeGUID, methodName);
repositoryValidator.validateAsOfTime(repositoryName, asOfTimeParameter, asOfTime, methodName);
repositoryValidator.validatePageSize(repositoryName, pageSizeParameter, pageSize, methodName);
......@@ -2164,10 +2191,10 @@ public class LocalOMRSMetadataCollection 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.
......@@ -2181,9 +2208,9 @@ public class LocalOMRSMetadataCollection extends OMRSMetadataCollection
List<String> limitResultsByClassification,
Date asOfTime,
int level) throws InvalidParameterException,
TypeErrorException,
RepositoryErrorException,
EntityNotKnownException,
TypeErrorException,
PropertyErrorException,
FunctionNotSupportedException,
UserNotAuthorizedException
......@@ -2209,7 +2236,7 @@ public class LocalOMRSMetadataCollection extends OMRSMetadataCollection
{
for (String guid : entityTypeGUIDs)
{
repositoryValidator.validateGUID(repositoryName, entityTypeGUIDParameterName, guid, methodName);
repositoryValidator.validateTypeGUID(repositoryName, entityTypeGUIDParameterName, guid, methodName);
}
}
......@@ -2217,11 +2244,11 @@ public class LocalOMRSMetadataCollection 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)
{
......@@ -2253,7 +2280,7 @@ public class LocalOMRSMetadataCollection extends OMRSMetadataCollection
*
* @param userId - unique identifier for requesting user.
* @param startEntityGUID - unique identifier of the starting entity
* @param instanceTypes - list of types to search for. Null means any type.
* @param instanceTypes - list of guids of types to search for. Null means any type.
* @param fromEntityElement - starting element for results list. Used in paging. Zero means first element.
* @param limitResultsByStatus - By default, relationships in all statuses are returned. However, it is possible
* to specify a list of statuses (eg ACTIVE) to restrict the results to. Null means all
......@@ -2268,10 +2295,10 @@ public class LocalOMRSMetadataCollection 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 of the requested 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
......@@ -2290,8 +2317,8 @@ public class LocalOMRSMetadataCollection extends OMRSMetadataCollection
String sequencingProperty,
SequencingOrder sequencingOrder,
int pageSize) throws InvalidParameterException,
RepositoryErrorException,
TypeErrorException,
RepositoryErrorException,
EntityNotKnownException,
PropertyErrorException,
PagingErrorException,
......@@ -2300,6 +2327,7 @@ public class LocalOMRSMetadataCollection extends OMRSMetadataCollection
{
final String methodName = "getRelatedEntities";
final String entityGUIDParameterName = "startEntityGUID";
final String instanceTypeParameter = "InstanceTypes";
final String asOfTimeParameter = "asOfTime";
final String pageSizeParameter = "pageSize";
......@@ -2314,6 +2342,14 @@ public class LocalOMRSMetadataCollection extends OMRSMetadataCollection
repositoryValidator.validateAsOfTime(repositoryName, asOfTimeParameter, asOfTime, methodName);
repositoryValidator.validatePageSize(repositoryName, pageSizeParameter, pageSize, methodName);
if (instanceTypes != null)
{
for (String guid : instanceTypes)
{
repositoryValidator.validateTypeGUID(repositoryName, instanceTypeParameter, guid, methodName);
}
}
/*
* Perform operation
*/
......@@ -2385,7 +2421,7 @@ public class LocalOMRSMetadataCollection 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,
......@@ -2457,24 +2493,12 @@ public class LocalOMRSMetadataCollection 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 FunctionNotSupportedException - the repository does not support entity proxies as first class elements.
* @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,
FunctionNotSupportedException,
UserNotAuthorizedException
{
......@@ -2495,36 +2519,11 @@ public class LocalOMRSMetadataCollection extends OMRSMetadataCollection
entityProxy,
methodName);
repositoryValidator.validateInstanceType(repositoryName, entityProxy);
String entityTypeGUID = entityProxy.getType().getTypeDefGUID();
TypeDef typeDef = repositoryHelper.getTypeDef(repositoryName, 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
*
* EntityProxies are used to store a relationship where the entity at one end of the relationship is
* not stored locally.
* not stored locally. Its type may not be supported locally either.
*/
realMetadataCollection.addEntityProxy(userId, entityProxy);
}
......@@ -3259,7 +3258,7 @@ public class LocalOMRSMetadataCollection 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);
......
......@@ -418,18 +418,6 @@ public class LocalOMRSRepositoryConnector extends OMRSRepositoryConnector implem
/**
* Return the TypeDefValidator. This is used to validate that a list of type definitions (TypeDefs) are
* compatible with the local repository.
*
* @return OMRSTypeDefValidator object for the local repository.
*/
public OMRSTypeDefValidator getTypeDefValidator()
{
return typeDefValidator;
}
/**
* Return the event manager that the local repository uses to distribute events from the local repository.
*
* @return outbound repository event manager
......
......@@ -20,7 +20,7 @@ package org.apache.atlas.omrs.localrepository.repositoryconnector;
import org.apache.atlas.omrs.metadatacollection.properties.instances.EntityDetail;
import org.apache.atlas.omrs.metadatacollection.properties.instances.Relationship;
import java.util.ArrayList;
import java.util.List;
/**
......@@ -52,9 +52,9 @@ public interface OMRSInstanceRetrievalEventProcessor
* @param entities - the retrieved relationships
* @return the validated and processed relationships
*/
ArrayList<EntityDetail> processRetrievedEntities(String sourceName,
String metadataCollectionId,
ArrayList<EntityDetail> entities);
List<EntityDetail> processRetrievedEntities(String sourceName,
String metadataCollectionId,
List<EntityDetail> entities);
/**
......@@ -80,7 +80,7 @@ public interface OMRSInstanceRetrievalEventProcessor
* @param relationships - the list of retrieved relationships
* @return the validated and processed relationships
*/
ArrayList<Relationship> processRetrievedRelationships(String sourceName,
String metadataCollectionId,
ArrayList<Relationship> relationships);
List<Relationship> processRetrievedRelationships(String sourceName,
String metadataCollectionId,
List<Relationship> relationships);
}
......@@ -26,12 +26,11 @@ import org.apache.atlas.omrs.ffdc.OMRSErrorCode;
import org.apache.atlas.omrs.ffdc.exception.*;
import org.apache.atlas.omrs.localrepository.repositoryconnector.LocalOMRSRepositoryConnector;
import org.apache.atlas.omrs.metadatacollection.OMRSMetadataCollection;
import org.apache.atlas.omrs.metadatacollection.properties.instances.EntityDetail;
import org.apache.atlas.omrs.metadatacollection.properties.instances.InstanceStatus;
import org.apache.atlas.omrs.metadatacollection.properties.instances.InstanceType;
import org.apache.atlas.omrs.metadatacollection.properties.instances.Relationship;
import org.apache.atlas.omrs.metadatacollection.properties.typedefs.*;
import org.apache.atlas.omrs.metadatacollection.repositoryconnector.OMRSRepositoryConnector;
import org.apache.atlas.omrs.rest.server.OMRSRepositoryRESTServices;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -77,11 +76,14 @@ public class OMRSRepositoryContentManager implements OMRSTypeDefEventProcessor,
private OMRSRepositoryConnector realLocalConnector = null;
private OMRSRepositoryEventExchangeRule saveExchangeRule = null;
private String openTypesOriginGUID = null;
private HashMap<String, TypeDef> knownTypes = new HashMap<>();
private HashMap<String, AttributeTypeDef> knownAttributeTypes = new HashMap<>();
private HashMap<String, TypeDef> activeTypes = new HashMap<>();
private HashMap<String, AttributeTypeDef> activeAttributeTypes = new HashMap<>();
private HashMap<String, TypeDef> knownTypeDefGUIDs = new HashMap<>();
private HashMap<String, TypeDef> knownTypeDefNames = new HashMap<>();
private HashMap<String, AttributeTypeDef> knownAttributeTypeDefGUIDs = new HashMap<>();
private HashMap<String, AttributeTypeDef> knownAttributeTypeDefNames = new HashMap<>();
private HashMap<String, TypeDef> activeTypeDefGUIDs = new HashMap<>();
private HashMap<String, TypeDef> activeTypeDefNames = new HashMap<>();
private HashMap<String, AttributeTypeDef> activeAttributeTypeDefGUIDs = new HashMap<>();
private HashMap<String, AttributeTypeDef> activeAttributeTypeDefNames = new HashMap<>();
/*
......@@ -151,10 +153,13 @@ public class OMRSRepositoryContentManager implements OMRSTypeDefEventProcessor,
{
if (this.validTypeDef(sourceName, newTypeDef))
{
knownTypes.put(newTypeDef.getName(), newTypeDef);
knownTypeDefGUIDs.put(newTypeDef.getGUID(), newTypeDef);
knownTypeDefNames.put(newTypeDef.getName(), newTypeDef);
if (localRepositoryConnector != null)
{
activeTypes.put(newTypeDef.getName(), newTypeDef);
activeTypeDefGUIDs.put(newTypeDef.getGUID(), newTypeDef);
activeTypeDefNames.put(newTypeDef.getName(), newTypeDef);
if (log.isDebugEnabled())
{
......@@ -175,10 +180,13 @@ public class OMRSRepositoryContentManager implements OMRSTypeDefEventProcessor,
{
if (this.validAttributeTypeDef(sourceName, newAttributeTypeDef))
{
knownAttributeTypes.put(newAttributeTypeDef.getName(), newAttributeTypeDef);
knownAttributeTypeDefGUIDs.put(newAttributeTypeDef.getGUID(), newAttributeTypeDef);
knownAttributeTypeDefNames.put(newAttributeTypeDef.getName(), newAttributeTypeDef);
if (localRepositoryConnector != null)
{
activeAttributeTypes.put(newAttributeTypeDef.getName(), newAttributeTypeDef);
activeAttributeTypeDefGUIDs.put(newAttributeTypeDef.getGUID(), newAttributeTypeDef);
activeAttributeTypeDefNames.put(newAttributeTypeDef.getName(), newAttributeTypeDef);
if (log.isDebugEnabled())
{
......@@ -200,45 +208,23 @@ public class OMRSRepositoryContentManager implements OMRSTypeDefEventProcessor,
{
if (this.validTypeDef(sourceName, typeDef))
{
knownTypes.put(typeDef.getName(), typeDef);
if (localRepositoryConnector != null)
{
activeTypes.put(typeDef.getName(), typeDef);
knownTypeDefGUIDs.put(typeDef.getGUID(), typeDef);
knownTypeDefNames.put(typeDef.getName(), typeDef);
if (log.isDebugEnabled())
{
log.debug("Updated Active Type " + typeDef.getName() + " from " + sourceName, typeDef);
}
}
}
}
/**
* Update one or more properties of a cached TypeDef.
*
* @param sourceName - source of the request (used for logging)
* @param attributeTypeDef - AttributeTypeDef structure.
*/
public void updateAttributeTypeDef(String sourceName, AttributeTypeDef attributeTypeDef)
{
if (this.validAttributeTypeDef(sourceName, attributeTypeDef))
{
knownAttributeTypes.put(attributeTypeDef.getName(), attributeTypeDef);
if (localRepositoryConnector != null)
{
activeAttributeTypes.put(attributeTypeDef.getName(), attributeTypeDef);
activeTypeDefGUIDs.put(typeDef.getGUID(), typeDef);
activeTypeDefNames.put(typeDef.getName(), typeDef);
if (log.isDebugEnabled())
{
log.debug("Updated Active AttributeType " + attributeTypeDef.getName() + " from " + sourceName, attributeTypeDef);
log.debug("Updated Active Type " + typeDef.getName() + " from " + sourceName, typeDef);
}
}
}
}
/**
* Delete a cached TypeDef.
*
......@@ -252,15 +238,17 @@ public class OMRSRepositoryContentManager implements OMRSTypeDefEventProcessor,
{
if (this.validTypeId(sourceName, obsoleteTypeDefGUID, obsoleteTypeDefName))
{
knownTypes.remove(obsoleteTypeDefName);
knownTypeDefGUIDs.remove(obsoleteTypeDefGUID);
knownTypeDefNames.remove(obsoleteTypeDefName);
if (localRepositoryConnector != null)
{
activeTypes.remove(obsoleteTypeDefName);
activeTypeDefGUIDs.remove(obsoleteTypeDefGUID);
activeTypeDefNames.remove(obsoleteTypeDefName);
if (log.isDebugEnabled())
{
log.debug("Deleted Active Type " + obsoleteTypeDefName + " from " + sourceName);
log.debug("Deleted Active TypeDef " + obsoleteTypeDefName + " from " + sourceName);
}
}
}
......@@ -271,14 +259,29 @@ public class OMRSRepositoryContentManager implements OMRSTypeDefEventProcessor,
* 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.
*/
public void deleteAttributeTypeDef(String sourceName,
String obsoleteTypeDefGUID,
String obsoleteTypeDefName)
String obsoleteAttributeTypeDefGUID,
String obsoleteAttributeTypeDefName)
{
if (this.validTypeId(sourceName, obsoleteAttributeTypeDefGUID, obsoleteAttributeTypeDefName))
{
knownAttributeTypeDefGUIDs.remove(obsoleteAttributeTypeDefGUID);
knownAttributeTypeDefNames.remove(obsoleteAttributeTypeDefName);
if (localRepositoryConnector != null)
{
activeAttributeTypeDefGUIDs.remove(obsoleteAttributeTypeDefGUID);
activeAttributeTypeDefNames.remove(obsoleteAttributeTypeDefName);
if (log.isDebugEnabled())
{
log.debug("Deleted Active AttributeTypeDef " + obsoleteAttributeTypeDefName + " from " + sourceName);
}
}
}
}
......@@ -295,7 +298,8 @@ public class OMRSRepositoryContentManager implements OMRSTypeDefEventProcessor,
String originalTypeDefName,
TypeDef newTypeDef)
{
// TODO
this.deleteTypeDef(sourceName, originalTypeDefGUID, originalTypeDefName);
this.addTypeDef(sourceName, newTypeDef);
}
......@@ -312,7 +316,8 @@ public class OMRSRepositoryContentManager implements OMRSTypeDefEventProcessor,
String originalAttributeTypeDefName,
AttributeTypeDef newAttributeTypeDef)
{
// TODO
this.deleteAttributeTypeDef(sourceName, originalAttributeTypeDefGUID, originalAttributeTypeDefName);
this.addAttributeTypeDef(sourceName, newAttributeTypeDef);
}
......@@ -324,10 +329,10 @@ public class OMRSRepositoryContentManager implements OMRSTypeDefEventProcessor,
* @return list of String property names
* @throws TypeErrorException - there is an issue with the TypeDef.
*/
private ArrayList<String> getPropertyNames(String sourceName, TypeDef typeDef) throws TypeErrorException
private List<String> getPropertyNames(String sourceName, TypeDef typeDef) throws TypeErrorException
{
final String methodName = "getPropertyNames()";
ArrayList<String> propertyNames = null;
List<String> propertyNames = null;
if (validTypeDef(sourceName, typeDef))
{
......@@ -414,6 +419,7 @@ public class OMRSRepositoryContentManager implements OMRSTypeDefEventProcessor,
* @param sourceName - source of the request (used for logging)
* @param category - category of the instance type required.
* @param typeName - String type name.
* @param methodName - name of calling method.
* @return InstanceType object containing TypeDef properties such as unique identifier (guid),
* typeDef name and version name
* @throws TypeErrorException - the type name is not a recognized type or is of the wrong category or there is
......@@ -421,13 +427,14 @@ public class OMRSRepositoryContentManager implements OMRSTypeDefEventProcessor,
*/
public InstanceType getInstanceType(String sourceName,
TypeDefCategory category,
String typeName) throws TypeErrorException
String typeName,
String methodName) throws TypeErrorException
{
final String methodName = "getInstanceType()";
final String thisMethodName = "getInstanceType";
if (isValidTypeCategory(sourceName, category, typeName))
if (isValidTypeCategory(sourceName, category, typeName, methodName))
{
TypeDef typeDef = knownTypes.get(typeName);
TypeDef typeDef = knownTypeDefNames.get(typeName);
if (typeDef != null)
{
......@@ -444,7 +451,7 @@ public class OMRSRepositoryContentManager implements OMRSTypeDefEventProcessor,
* Extract the properties for this TypeDef. These will be augmented with property names
* from the super type(s).
*/
ArrayList<String> propertyNames = this.getPropertyNames(sourceName, typeDef);
List<String> propertyNames = this.getPropertyNames(sourceName, typeDef);
/*
* If propertyNames is null, it means the TypeDef has no attributes. However the superType
......@@ -458,12 +465,12 @@ public class OMRSRepositoryContentManager implements OMRSTypeDefEventProcessor,
/*
* Work up the TypeDef hierarchy extracting the property names and super type names.
*/
ArrayList<TypeDefLink> superTypes = new ArrayList<>();
List<TypeDefLink> superTypes = new ArrayList<>();
TypeDefLink superTypeLink = typeDef.getSuperType();
while (superTypeLink != null)
{
String superTypeName = superTypeLink.getName();
String superTypeName = superTypeLink.getName();
if (superTypeName != null)
{
......@@ -472,25 +479,46 @@ public class OMRSRepositoryContentManager implements OMRSTypeDefEventProcessor,
log.debug(typeName + " from " + sourceName + " has super type " + superTypeName);
}
/*
* Save the name of the super type into the instance type
*/
superTypes.add(superTypeLink);
TypeDef superTypeDef = knownTypes.get(superTypeName);
/*
* Retrieve the TypeDef for this super type
*/
TypeDef superTypeDef = knownTypeDefNames.get(superTypeName);
if (superTypeDef != null)
{
ArrayList<String> superTypePropertyNames = this.getPropertyNames(sourceName, superTypeDef);
List<String> superTypePropertyNames = this.getPropertyNames(sourceName, superTypeDef);
if (superTypePropertyNames != null)
{
propertyNames.addAll(0, superTypePropertyNames);
}
}
superTypeLink = superTypeDef.getSuperType();
/*
* Retrieve the super type for this typeDef. It will be null if the type is top-level.
*/
superTypeLink = superTypeDef.getSuperType();
}
else
{
/*
* Super type not known so stop processing
*/
log.error(superTypeName + " is not known");
throwContentManagerLogicError(sourceName, methodName, thisMethodName);
}
}
else
{
superTypeLink = null;
/*
* Super type is invalid - corrupted cache
*/
log.error("Corrupted TypeDef cache");
throwContentManagerLogicError(sourceName, methodName, thisMethodName);
}
}
......@@ -512,16 +540,8 @@ public class OMRSRepositoryContentManager implements OMRSTypeDefEventProcessor,
}
else
{
OMRSErrorCode errorCode = OMRSErrorCode.TYPEDEF_NOT_KNOWN;
String errorMessage = errorCode.getErrorMessageId()
+ errorCode.getFormattedErrorMessage(sourceName, typeName, category.getTypeName());
throw new TypeErrorException(errorCode.getHTTPErrorCode(),
this.getClass().getName(),
methodName,
errorMessage,
errorCode.getSystemAction(),
errorCode.getUserAction());
log.error("TypeDef " + typeName + " already validated");
throwContentManagerLogicError(sourceName, methodName, thisMethodName);
}
}
else
......@@ -537,6 +557,8 @@ public class OMRSRepositoryContentManager implements OMRSTypeDefEventProcessor,
errorCode.getSystemAction(),
errorCode.getUserAction());
}
return null;
}
......@@ -552,19 +574,24 @@ public class OMRSRepositoryContentManager implements OMRSTypeDefEventProcessor,
*/
public boolean isValidTypeCategory(String sourceName,
TypeDefCategory category,
String typeName) throws TypeErrorException
String typeName,
String methodName) throws TypeErrorException
{
final String thisMethodName = "isValidTypeCategory";
if (category == null)
{
// TODO throw logic error
throwContentManagerLogicError(sourceName, methodName, thisMethodName);
return false;
}
if (typeName == null)
{
// TODO throw logic error
throwContentManagerLogicError(sourceName, methodName, thisMethodName);
return false;
}
TypeDef typeDef = knownTypes.get(typeName);
TypeDef typeDef = knownTypeDefNames.get(typeName);
if (typeDef != null)
{
......@@ -572,20 +599,29 @@ public class OMRSRepositoryContentManager implements OMRSTypeDefEventProcessor,
if (retrievedTypeDefCategory != null)
{
if (category.getTypeCode() == retrievedTypeDefCategory.getTypeCode())
{
return true;
}
else
{
return false;
}
return (category.getTypeCode() == retrievedTypeDefCategory.getTypeCode());
}
else
{
// TODO Throw logic error
throwContentManagerLogicError(sourceName, methodName, thisMethodName);
}
}
else
{
OMRSErrorCode errorCode = OMRSErrorCode.TYPEDEF_NOT_KNOWN_FOR_INSTANCE;
String errorMessage = errorCode.getErrorMessageId()
+ errorCode.getFormattedErrorMessage(typeName,
category.getTypeName(),
methodName,
sourceName);
throw new TypeErrorException(errorCode.getHTTPErrorCode(),
this.getClass().getName(),
methodName,
errorMessage,
errorCode.getSystemAction(),
errorCode.getUserAction());
}
return false;
}
......@@ -598,18 +634,22 @@ public class OMRSRepositoryContentManager implements OMRSTypeDefEventProcessor,
* @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.
*/
public boolean isValidClassificationForEntity(String sourceName,
String classificationTypeName,
String entityTypeName)
String entityTypeName,
String methodName)
{
final String thisMethodName = "isValidClassificationForEntity";
try
{
if ((isValidTypeCategory(sourceName, TypeDefCategory.CLASSIFICATION_DEF, classificationTypeName)) &&
(isValidTypeCategory(sourceName, TypeDefCategory.ENTITY_DEF, entityTypeName)))
if ((isValidTypeCategory(sourceName, TypeDefCategory.CLASSIFICATION_DEF, classificationTypeName, methodName)) &&
(isValidTypeCategory(sourceName, TypeDefCategory.ENTITY_DEF, entityTypeName, methodName)))
{
ClassificationDef classificationTypeDef = (ClassificationDef)knownTypes.get(classificationTypeName);
ClassificationDef classificationTypeDef = (ClassificationDef) knownTypeDefNames.get(classificationTypeName);
if (classificationTypeDef != null)
{
......@@ -644,7 +684,7 @@ public class OMRSRepositoryContentManager implements OMRSTypeDefEventProcessor,
}
else
{
// TODO log audit record - logic error
throwContentManagerLogicError(sourceName, methodName, thisMethodName);
return false;
}
}
......@@ -655,39 +695,74 @@ public class OMRSRepositoryContentManager implements OMRSTypeDefEventProcessor,
}
catch (TypeErrorException typeError)
{
// TODO log audit record - invalid Types
throwContentManagerLogicError(sourceName, methodName, thisMethodName);
return false;
}
catch (ClassCastException castError)
{
// TODO log audit record - logic error - category not matching TypeDef instance type
throwContentManagerLogicError(sourceName, methodName, thisMethodName);
return false;
}
}
/**
* Return the list of valid InstanceStatus states that instances of this type can handle.
* Return the requested type.
*
* @param sourceName - source of the request (used for logging)
* @param typeName - name of the type
* @param thisMethodName - name of calling method.
* @param originalMethodName - name of original calling method.
* @return list of InstanceStatus enums
* @throws TypeErrorException - the type name is not recognized.
*/
public List<InstanceStatus> getValidStatusList(String sourceName, String typeName) throws TypeErrorException
private TypeDef getTypeDefFromCache(String sourceName,
String typeName,
String thisMethodName,
String originalMethodName) throws TypeErrorException
{
if (typeName == null)
{
// TODO throw TypeError Exception
this.throwContentManagerLogicError(sourceName, thisMethodName, originalMethodName);
}
TypeDef typeDef = knownTypes.get(typeName);
TypeDef typeDef = knownTypeDefNames.get(typeName);
if (typeDef == null)
{
// TODO throw TypeError exception
OMRSErrorCode errorCode = OMRSErrorCode.TYPEDEF_NAME_NOT_KNOWN;
String errorMessage = errorCode.getErrorMessageId()
+ errorCode.getFormattedErrorMessage(typeName, originalMethodName, sourceName);
throw new TypeErrorException(errorCode.getHTTPErrorCode(),
this.getClass().getName(),
originalMethodName,
errorMessage,
errorCode.getSystemAction(),
errorCode.getUserAction());
}
return typeDef;
}
/**
* Return the list of valid InstanceStatus states that instances of this type can handle.
*
* @param sourceName - source of the request (used for logging)
* @param typeName - name of the type
* @param methodName - name of calling method.
* @return list of InstanceStatus enums
* @throws TypeErrorException - the type name is not recognized.
*/
public List<InstanceStatus> getValidStatusList(String sourceName,
String typeName,
String methodName) throws TypeErrorException
{
final String thisMethodName = "validStatusList";
TypeDef typeDef = this.getTypeDefFromCache(sourceName, typeName, thisMethodName, methodName);
return typeDef.getValidInstanceStatusList();
}
......@@ -697,41 +772,45 @@ public class OMRSRepositoryContentManager implements OMRSTypeDefEventProcessor,
*
* @param sourceName - source of the request (used for logging)
* @param typeName - name of the type to extract the initial status from.
* @param methodName - calling method
* @return InstanceStatus enum
* @throws TypeErrorException - the type name is not recognized.
*/
public InstanceStatus getInitialStatus(String sourceName, String typeName) throws TypeErrorException
public InstanceStatus getInitialStatus(String sourceName,
String typeName,
String methodName) throws TypeErrorException
{
if (typeName == null)
{
// TODO throw TypeError Exception
}
TypeDef typeDef = knownTypes.get(typeName);
final String thisMethodName = "getInitialStatus";
if (typeDef == null)
{
// TODO throw TypeError exception
}
TypeDef typeDef = this.getTypeDefFromCache(sourceName, typeName, thisMethodName, methodName);
return typeDef.getInitialStatus();
}
/**
* 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.
*/
public String getInstanceURL(String sourceName, String guid)
public String getEntityURL(String sourceName, String guid)
{
// TODO Need to work out what instance URL's look like for OMRS instances. These URLs will be supported
// TODO by the REST API
return null;
return OMRSRepositoryRESTServices.getEntityURL(guid);
}
/**
* 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.
*/
public String getRelationshipURL(String sourceName, String guid)
{
return OMRSRepositoryRESTServices.getRelationshipURL(guid);
}
......@@ -750,14 +829,14 @@ public class OMRSRepositoryContentManager implements OMRSTypeDefEventProcessor,
{
TypeDefGallery typeDefGallery = new TypeDefGallery();
if (! activeAttributeTypes.isEmpty())
if (! activeAttributeTypeDefNames.isEmpty())
{
typeDefGallery.setAttributeTypeDefs(new ArrayList<>(activeAttributeTypes.values()));
typeDefGallery.setAttributeTypeDefs(new ArrayList<>(activeAttributeTypeDefNames.values()));
}
if (! activeTypes.isEmpty())
if (! activeTypeDefNames.isEmpty())
{
typeDefGallery.setTypeDefs(new ArrayList<>(activeTypes.values()));
typeDefGallery.setTypeDefs(new ArrayList<>(activeTypeDefNames.values()));
}
return typeDefGallery;
......@@ -773,14 +852,14 @@ public class OMRSRepositoryContentManager implements OMRSTypeDefEventProcessor,
{
TypeDefGallery typeDefGallery = new TypeDefGallery();
if (! knownAttributeTypes.isEmpty())
if (! knownAttributeTypeDefNames.isEmpty())
{
typeDefGallery.setAttributeTypeDefs(new ArrayList<>(knownAttributeTypes.values()));
typeDefGallery.setAttributeTypeDefs(new ArrayList<>(knownAttributeTypeDefNames.values()));
}
if (! knownTypes.isEmpty())
if (! knownTypeDefNames.isEmpty())
{
typeDefGallery.setTypeDefs(new ArrayList<>(knownTypes.values()));
typeDefGallery.setTypeDefs(new ArrayList<>(knownTypeDefNames.values()));
}
return typeDefGallery;
......@@ -799,7 +878,7 @@ public class OMRSRepositoryContentManager implements OMRSTypeDefEventProcessor,
public TypeDef getTypeDefByName (String sourceName,
String typeDefName)
{
return knownTypes.get(typeDefName);
return knownTypeDefNames.get(typeDefName);
}
......@@ -815,7 +894,7 @@ public class OMRSRepositoryContentManager implements OMRSTypeDefEventProcessor,
public AttributeTypeDef getAttributeTypeDefByName (String sourceName,
String attributeTypeDefName)
{
return knownAttributeTypes.get(attributeTypeDefName);
return knownAttributeTypeDefNames.get(attributeTypeDefName);
}
......@@ -830,7 +909,62 @@ public class OMRSRepositoryContentManager implements OMRSTypeDefEventProcessor,
public TypeDefGallery getActiveTypesByWildCardName (String sourceName,
String typeDefName)
{
// TODO
if (typeDefName != null)
{
Collection<TypeDef> typeDefs = activeTypeDefNames.values();
List<TypeDef> matchedTypeDefs = new ArrayList<>();
for (TypeDef typeDef : typeDefs)
{
if (typeDef != null)
{
if (typeDef.getName().matches(typeDefName))
{
matchedTypeDefs.add(typeDef);
}
}
}
Collection<AttributeTypeDef> attributeTypeDefs = activeAttributeTypeDefNames.values();
List<AttributeTypeDef> matchedAttributeTypeDefs = new ArrayList<>();
for (AttributeTypeDef attributeTypeDef : attributeTypeDefs)
{
if (attributeTypeDef != null)
{
if (attributeTypeDef.getName().matches(typeDefName))
{
matchedAttributeTypeDefs.add(attributeTypeDef);
}
}
}
if ((! matchedTypeDefs.isEmpty()) || (! matchedAttributeTypeDefs.isEmpty()))
{
TypeDefGallery typeDefGallery = new TypeDefGallery();
if (! matchedTypeDefs.isEmpty())
{
typeDefGallery.setTypeDefs(matchedTypeDefs);
}
else
{
typeDefGallery.setTypeDefs(null);
}
if (! matchedAttributeTypeDefs.isEmpty())
{
typeDefGallery.setAttributeTypeDefs(matchedAttributeTypeDefs);
}
else
{
typeDefGallery.setAttributeTypeDefs(null);
}
return typeDefGallery;
}
}
return null;
}
......@@ -841,13 +975,41 @@ public class OMRSRepositoryContentManager implements OMRSTypeDefEventProcessor,
*
* @param sourceName - source of the request (used for logging)
* @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 guidParameterName,
String typeDefGUID,
String methodName) throws TypeErrorException
{
// TODO
final String thisMethodName = "getTypeDef";
if (typeDefGUID != null)
{
TypeDef typeDef = knownTypeDefGUIDs.get(typeDefGUID);
if (typeDef == null)
{
OMRSErrorCode errorCode = OMRSErrorCode.TYPEDEF_ID_NOT_KNOWN;
String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage(typeDefGUID,
guidParameterName,
methodName,
sourceName);
throw new TypeErrorException(errorCode.getHTTPErrorCode(),
this.getClass().getName(),
methodName,
errorMessage,
errorCode.getSystemAction(),
errorCode.getUserAction());
}
return typeDef;
}
throwContentManagerLogicError(sourceName, methodName, thisMethodName);
return null;
}
......@@ -858,13 +1020,37 @@ public class OMRSRepositoryContentManager implements OMRSTypeDefEventProcessor,
*
* @param sourceName - source of the request (used for logging)
* @param attributeTypeDefGUID - unique identifier for the AttributeTypeDef
* @param methodName - calling method
* @return TypeDef object
* @throws TypeErrorException - unknown or invalid type
*/
public AttributeTypeDef getAttributeTypeDef (String sourceName,
String attributeTypeDefGUID) throws TypeErrorException
String attributeTypeDefGUID,
String methodName) throws TypeErrorException
{
// TODO
final String thisMethodName = "getAttributeTypeDef";
if (attributeTypeDefGUID != null)
{
AttributeTypeDef attributeTypeDef = knownAttributeTypeDefGUIDs.get(attributeTypeDefGUID);
if (attributeTypeDef == null)
{
OMRSErrorCode errorCode = OMRSErrorCode.BAD_TYPEDEF;
String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage(sourceName);
throw new TypeErrorException(errorCode.getHTTPErrorCode(),
this.getClass().getName(),
methodName,
errorMessage,
errorCode.getSystemAction(),
errorCode.getUserAction());
}
return attributeTypeDef;
}
throwContentManagerLogicError(sourceName, methodName, thisMethodName);
return null;
}
......@@ -875,18 +1061,20 @@ public class OMRSRepositoryContentManager implements OMRSTypeDefEventProcessor,
* @param sourceName - source of the request (used for logging)
* @param typeDefGUID - unique identifier for the TypeDef
* @param typeDefName - unique name for the TypeDef
* @return TypeDef object or null if the
* @param methodName - calling method
* @return TypeDef object or null if the
* @throws TypeErrorException - 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 (validTypeId(sourceName, typeDefGUID, typeDefName))
{
return knownTypes.get(typeDefName);
return knownTypeDefNames.get(typeDefName);
}
else
{
......@@ -911,18 +1099,18 @@ public class OMRSRepositoryContentManager implements OMRSTypeDefEventProcessor,
* @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()";
if (validTypeId(sourceName, attributeTypeDefGUID, attributeTypeDefName))
{
return knownAttributeTypes.get(attributeTypeDefName);
return knownAttributeTypeDefNames.get(attributeTypeDefName);
}
else
{
......@@ -944,55 +1132,6 @@ public class OMRSRepositoryContentManager implements OMRSTypeDefEventProcessor,
* 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
*/
public ArrayList<TypeDefSummary> getLocalTypeDefs()
{
ArrayList<TypeDefSummary> activeTypeDefSummaries = null;
if (! activeTypes.isEmpty())
{
activeTypeDefSummaries = new ArrayList<>();
for (TypeDef activeType : activeTypes.values())
{
activeTypeDefSummaries.add(activeType);
}
}
return activeTypeDefSummaries;
}
/**
* 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)
{
// TODO if invalid typeDefs are detected, they are logged and TypeDef conflict messages are sent to
// TODO the typeDefEventProcessor methods to distributed
}
/**
* Return a boolean flag indicating whether the list of TypeDefs passed are compatible with the
......@@ -1015,7 +1154,7 @@ public class OMRSRepositoryContentManager implements OMRSTypeDefEventProcessor,
{
if (!isKnownType(sourceName, typeDef.getGUID(), typeDef.getName()))
{
knownTypes.put(typeDef.getName(), typeDef);
knownTypeDefNames.put(typeDef.getName(), typeDef);
}
}
else
......@@ -1055,7 +1194,7 @@ public class OMRSRepositoryContentManager implements OMRSTypeDefEventProcessor,
{
if (!isKnownType(sourceName, attributeTypeDef.getGUID(), attributeTypeDef.getName()))
{
knownAttributeTypes.put(attributeTypeDef.getName(), attributeTypeDef);
knownAttributeTypeDefNames.put(attributeTypeDef.getName(), attributeTypeDef);
}
}
else
......@@ -1078,15 +1217,15 @@ public class OMRSRepositoryContentManager implements OMRSTypeDefEventProcessor,
* Return boolean indicating whether the TypeDef is one of the standard open metadata types.
*
* @param sourceName - source of the TypeDef (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
*/
public boolean isOpenType(String sourceName, String typeDefGUID, String typeDefName)
public boolean isOpenType(String sourceName, String typeGUID, String typeName)
{
if (validTypeId(sourceName, typeDefGUID, typeDefName))
if (validTypeId(sourceName, typeGUID, typeName))
{
TypeDef typeDef = knownTypes.get(typeDefName);
TypeDef typeDef = knownTypeDefNames.get(typeName);
if (typeDef == null)
{
......@@ -1097,12 +1236,12 @@ public class OMRSRepositoryContentManager implements OMRSTypeDefEventProcessor,
{
if (openTypesOriginGUID.equals(typeDef.getOrigin()))
{
log.debug("TypeDef " + typeDefName + " (GUID = " + typeDefGUID + ") from " + sourceName + " is an open type");
log.debug("TypeDef " + typeName + " (GUID = " + typeGUID + ") from " + sourceName + " is an open type");
return true;
}
else
{
log.debug("TypeDef " + typeDefName + " (GUID = " + typeDefGUID + ") from " + sourceName + " is NOT an open type");
log.debug("TypeDef " + typeName + " (GUID = " + typeGUID + ") from " + sourceName + " is NOT an open type");
}
}
}
......@@ -1112,38 +1251,68 @@ public class OMRSRepositoryContentManager implements OMRSTypeDefEventProcessor,
/**
* Return boolean indicating whether the (Attribute)TypeDef is known, either as an open type, or one defined
* 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
* @return boolean result
*/
public boolean isOpenTypeId(String sourceName, String typeGUID)
{
if (typeGUID != null)
{
TypeDef typeDef = knownTypeDefGUIDs.get(typeGUID);
if (typeDef != null)
{
String originGUID = typeDef.getOrigin();
if (originGUID != null)
{
if (originGUID.equals(openTypesOriginGUID))
{
return true;
}
}
}
}
return false;
}
/**
* Return boolean indicating whether the (AttributeTypeDef/TypeDef 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 TypeDef (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
*/
public boolean isKnownType(String sourceName, String typeDefGUID, String typeDefName)
public boolean isKnownType(String sourceName, String typeGUID, String typeName)
{
if (this.validTypeId(sourceName, typeDefGUID, typeDefName))
if (this.validTypeId(sourceName, typeGUID, typeName))
{
TypeDef typeDef = knownTypes.get(typeDefName);
TypeDef typeDef = knownTypeDefNames.get(typeName);
if (typeDef == null)
{
AttributeTypeDef attributeTypeDef = knownAttributeTypes.get(typeDefName);
AttributeTypeDef attributeTypeDef = knownAttributeTypeDefNames.get(typeName);
if (attributeTypeDef == null)
{
log.debug("Unknown (Attribute)TypeDef " + typeDefName + " (GUID = " + typeDefGUID + ") from " + sourceName);
log.debug("Unknown (Attribute)TypeDef " + typeName + " (GUID = " + typeGUID + ") from " + sourceName);
return false;
}
else
{
log.debug("Known AttributeTypeDef " + typeDefName + " (GUID = " + typeDefGUID + ") from " + sourceName);
log.debug("Known AttributeTypeDef " + typeName + " (GUID = " + typeGUID + ") from " + sourceName);
return true;
}
}
else
{
log.debug("Known TypeDef " + typeDefName + " (GUID = " + typeDefGUID + ") from " + sourceName);
log.debug("Known TypeDef " + typeName + " (GUID = " + typeGUID + ") from " + sourceName);
return true;
}
}
......@@ -1157,37 +1326,64 @@ public class OMRSRepositoryContentManager implements OMRSTypeDefEventProcessor,
/**
* 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
*/
public boolean isKnownTypeId(String sourceName, String typeGUID)
{
if (typeGUID != null)
{
if (knownTypeDefGUIDs.get(typeGUID) != null)
{
return true;
}
if (knownAttributeTypeDefGUIDs.get(typeGUID) != null)
{
return true;
}
}
return false;
}
/**
* Return boolean indicating whether the TypeDef is in use in the repository.
*
* @param sourceName - source of the TypeDef (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
*/
public boolean isActiveType(String sourceName, String typeDefGUID, String typeDefName)
public boolean isActiveType(String sourceName, String typeGUID, String typeName)
{
if (this.validTypeId(sourceName, typeDefGUID, typeDefName))
if (this.validTypeId(sourceName, typeGUID, typeName))
{
TypeDef typeDef = activeTypes.get(typeDefName);
TypeDef typeDef = activeTypeDefNames.get(typeName);
if (typeDef == null)
{
AttributeTypeDef attributeTypeDef = activeAttributeTypes.get(typeDefName);
AttributeTypeDef attributeTypeDef = activeAttributeTypeDefNames.get(typeName);
if (attributeTypeDef == null)
{
log.debug("Inactive (Attribute)TypeDef " + typeDefName + " (GUID = " + typeDefGUID + ") from " + sourceName);
log.debug("Inactive (Attribute)TypeDef " + typeName + " (GUID = " + typeGUID + ") from " + sourceName);
return false;
}
else
{
log.debug("Active AttributeTypeDef " + typeDefName + " (GUID = " + typeDefGUID + ") from " + sourceName);
log.debug("Active AttributeTypeDef " + typeName + " (GUID = " + typeGUID + ") from " + sourceName);
return true;
}
}
else
{
log.debug("Active TypeDef " + typeDefName + " (GUID = " + typeDefGUID + ") from " + sourceName);
log.debug("Active TypeDef " + typeName + " (GUID = " + typeGUID + ") from " + sourceName);
return true;
}
}
......@@ -1201,18 +1397,43 @@ public class OMRSRepositoryContentManager implements OMRSTypeDefEventProcessor,
/**
* 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
*/
public boolean isActiveTypeId(String sourceName, String typeGUID)
{
if (typeGUID != null)
{
if (activeTypeDefGUIDs.get(typeGUID) != null)
{
return true;
}
if (activeAttributeTypeDefGUIDs.get(typeGUID) != null)
{
return true;
}
}
return false;
}
/**
* Return boolean indicating whether the (Attribute)TypeDef identifiers are valid or not.
*
* @param sourceName - source of the TypeDef (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)
{
if (typeDefName == null)
if (typeName == null)
{
/*
* A null TypeDef name is invalid
......@@ -1222,7 +1443,7 @@ public class OMRSRepositoryContentManager implements OMRSTypeDefEventProcessor,
return false;
}
if (typeDefGUID == null)
if (typeGUID == null)
{
/*
* A null guid is invalid
......@@ -1232,14 +1453,14 @@ public class OMRSRepositoryContentManager implements OMRSTypeDefEventProcessor,
return false;
}
TypeDef typeDef = knownTypes.get(typeDefName);
TypeDef typeDef = knownTypeDefNames.get(typeName);
if (typeDef == null)
{
/*
* This TypeDef is unknown so see if it is an AttributeTypeDef
*/
AttributeTypeDef attributeTypeDef = knownAttributeTypes.get(typeDefName);
AttributeTypeDef attributeTypeDef = knownAttributeTypeDefNames.get(typeName);
if (attributeTypeDef == null)
{
......@@ -1247,12 +1468,12 @@ public class OMRSRepositoryContentManager implements OMRSTypeDefEventProcessor,
}
else
{
if (!typeDefGUID.equals(attributeTypeDef.getGUID()))
if (!typeGUID.equals(attributeTypeDef.getGUID()))
{
/*
* The requested guid does not equal the stored one.
*/
log.error("GUID Mismatch in AttributeTypeDef " + typeDefName + " from " + sourceName + " received GUID is " + typeDefGUID + "; stored GUID is " + attributeTypeDef.getGUID());
log.error("GUID Mismatch in AttributeTypeDef " + typeName + " from " + sourceName + " received GUID is " + typeGUID + "; stored GUID is " + attributeTypeDef.getGUID());
return false;
}
......@@ -1264,12 +1485,12 @@ public class OMRSRepositoryContentManager implements OMRSTypeDefEventProcessor,
return true;
}
if (! typeDefGUID.equals(typeDef.getGUID()))
if (! typeGUID.equals(typeDef.getGUID()))
{
/*
* The requested guid does not equal the stored one.
*/
log.error("GUID Mismatch in TypeDef " + typeDefName + " from " + sourceName + " received GUID is " + typeDefGUID + "; stored GUID is " + typeDef.getGUID());
log.error("GUID Mismatch in TypeDef " + typeName + " from " + sourceName + " received GUID is " + typeGUID + "; stored GUID is " + typeDef.getGUID());
return false;
}
......@@ -1296,7 +1517,7 @@ public class OMRSRepositoryContentManager implements OMRSTypeDefEventProcessor,
return false;
}
TypeDef typeDef = knownTypes.get(typeDefName);
TypeDef typeDef = knownTypeDefNames.get(typeDefName);
if (typeDef != null)
{
......@@ -1341,7 +1562,7 @@ public class OMRSRepositoryContentManager implements OMRSTypeDefEventProcessor,
return false;
}
AttributeTypeDef attributeTypeDef = knownAttributeTypes.get(attributeTypeDefName);
AttributeTypeDef attributeTypeDef = knownAttributeTypeDefNames.get(attributeTypeDefName);
if (attributeTypeDef != null)
{
......@@ -1388,7 +1609,7 @@ public class OMRSRepositoryContentManager implements OMRSTypeDefEventProcessor,
return false;
}
TypeDef typeDef = knownTypes.get(typeDefName);
TypeDef typeDef = knownTypeDefNames.get(typeDefName);
if (typeDef == null)
{
......@@ -1431,7 +1652,7 @@ public class OMRSRepositoryContentManager implements OMRSTypeDefEventProcessor,
return false;
}
TypeDef typeDef = knownTypes.get(attributeTypeDefName);
TypeDef typeDef = knownTypeDefNames.get(attributeTypeDefName);
if (typeDef == null)
{
......@@ -1604,7 +1825,7 @@ public class OMRSRepositoryContentManager implements OMRSTypeDefEventProcessor,
/*
* Update the active TypeDefs as this new TypeDef has been accepted by the local repository.
*/
activeTypes.put(typeDef.getName(), typeDef);
activeTypeDefNames.put(typeDef.getName(), typeDef);
OMRSAuditCode auditCode = OMRSAuditCode.NEW_TYPE_ADDED;
auditLog.logRecord(actionDescription,
......@@ -1660,7 +1881,7 @@ public class OMRSRepositoryContentManager implements OMRSTypeDefEventProcessor,
localRepositoryConnector.getOrganizationName(),
typeDef,
originatorMetadataCollectionId,
knownTypes.get(typeDef.getName()),
knownTypeDefNames.get(typeDef.getName()),
null);
}
catch (InvalidTypeDefException error)
......@@ -1742,7 +1963,7 @@ public class OMRSRepositoryContentManager implements OMRSTypeDefEventProcessor,
/*
* Update the active TypeDefs as this new TypeDef has been accepted by the local repository.
*/
activeAttributeTypes.put(attributeTypeDef.getName(), attributeTypeDef);
activeAttributeTypeDefNames.put(attributeTypeDef.getName(), attributeTypeDef);
OMRSAuditCode auditCode = OMRSAuditCode.NEW_TYPE_ADDED;
auditLog.logRecord(actionDescription,
......@@ -1797,7 +2018,7 @@ public class OMRSRepositoryContentManager implements OMRSTypeDefEventProcessor,
localRepositoryConnector.getOrganizationName(),
attributeTypeDef,
originatorMetadataCollectionId,
knownAttributeTypes.get(
knownAttributeTypeDefNames.get(
attributeTypeDef.getName()),
null);
}
......@@ -2102,4 +2323,35 @@ public class OMRSRepositoryContentManager implements OMRSTypeDefEventProcessor,
{
}
/* ========================
* Private error handling
*/
/**
* Throws a logic error exception when the repository content manager is called with invalid parameters.
* Normally this means the repository content manager methods have been called in the wrong order.
*
* @param sourceName - source of the request (used for logging)
* @param originatingMethodName - method that called the repository validator
* @param localMethodName - local method that deleted the error
*/
private void throwContentManagerLogicError(String sourceName,
String originatingMethodName,
String localMethodName)
{
OMRSErrorCode errorCode = OMRSErrorCode.CONTENT_MANAGER_LOGIC_ERROR;
String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage(sourceName,
localMethodName,
originatingMethodName);
throw new OMRSLogicErrorException(errorCode.getHTTPErrorCode(),
this.getClass().getName(),
localMethodName,
errorMessage,
errorCode.getSystemAction(),
errorCode.getUserAction());
}
}
......@@ -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());
}
}
}
......@@ -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)
......
......@@ -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;
}
......@@ -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);
}
......@@ -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);
/**
......
......@@ -692,7 +692,8 @@ public abstract class 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
......@@ -709,7 +710,8 @@ public abstract class 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
......@@ -729,7 +731,8 @@ public abstract class OMRSMetadataCollection
/**
* Return the header, classifications and properties of a specific entity.
* Return the header, classifications and properties of a specific entity. This requires the full entity
* object to be available.
*
* @param userId - unique identifier for requesting user.
* @param guid - String unique identifier for the entity.
......@@ -797,6 +800,7 @@ public abstract class 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.
......@@ -814,6 +818,7 @@ public abstract class OMRSMetadataCollection
String sequencingProperty,
SequencingOrder sequencingOrder,
int pageSize) throws InvalidParameterException,
TypeErrorException,
RepositoryErrorException,
EntityNotKnownException,
PropertyErrorException,
......@@ -847,10 +852,10 @@ public abstract class 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.
......@@ -900,10 +905,10 @@ public abstract class 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.
......@@ -922,8 +927,8 @@ public abstract class OMRSMetadataCollection
String sequencingProperty,
SequencingOrder sequencingOrder,
int pageSize) throws InvalidParameterException,
RepositoryErrorException,
TypeErrorException,
RepositoryErrorException,
ClassificationErrorException,
PropertyErrorException,
PagingErrorException,
......@@ -956,6 +961,8 @@ public abstract class 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
......@@ -974,6 +981,7 @@ public abstract class OMRSMetadataCollection
String sequencingProperty,
SequencingOrder sequencingOrder,
int pageSize) throws InvalidParameterException,
TypeErrorException,
RepositoryErrorException,
PropertyErrorException,
PagingErrorException,
......@@ -1066,10 +1074,10 @@ public abstract class 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.
......@@ -1086,8 +1094,8 @@ public abstract class OMRSMetadataCollection
String sequencingProperty,
SequencingOrder sequencingOrder,
int pageSize) throws InvalidParameterException,
RepositoryErrorException,
TypeErrorException,
RepositoryErrorException,
PropertyErrorException,
PagingErrorException,
FunctionNotSupportedException,
......@@ -1118,6 +1126,8 @@ public abstract class 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.
......@@ -1134,11 +1144,12 @@ public abstract class OMRSMetadataCollection
String sequencingProperty,
SequencingOrder sequencingOrder,
int pageSize) throws InvalidParameterException,
RepositoryErrorException,
PropertyErrorException,
PagingErrorException,
FunctionNotSupportedException,
UserNotAuthorizedException;
TypeErrorException,
RepositoryErrorException,
PropertyErrorException,
PagingErrorException,
FunctionNotSupportedException,
UserNotAuthorizedException;
/**
......@@ -1194,10 +1205,10 @@ public abstract class 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 TypeErrorException - one 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 - one or more of the type guids passed on the request is not known by the
* metadata collection.
* @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.
......@@ -1211,8 +1222,8 @@ public abstract class OMRSMetadataCollection
List<String> limitResultsByClassification,
Date asOfTime,
int level) throws InvalidParameterException,
RepositoryErrorException,
TypeErrorException,
RepositoryErrorException,
EntityNotKnownException,
PropertyErrorException,
FunctionNotSupportedException,
......@@ -1225,7 +1236,7 @@ public abstract class OMRSMetadataCollection
*
* @param userId - unique identifier for requesting user.
* @param startEntityGUID - unique identifier of the starting entity.
* @param instanceTypes - list of types to search for. Null means any type.
* @param instanceTypes - list of guids for types to search for. Null means any type.
* @param fromEntityElement - starting element for results list. Used in paging. Zero means first element.
* @param limitResultsByStatus - By default, relationships in all statuses are returned. However, it is possible
* to specify a list of statuses (eg ACTIVE) to restrict the results to. Null means all
......@@ -1240,10 +1251,10 @@ public abstract class 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 of 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 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
......@@ -1262,8 +1273,8 @@ public abstract class OMRSMetadataCollection
String sequencingProperty,
SequencingOrder sequencingOrder,
int pageSize) throws InvalidParameterException,
RepositoryErrorException,
TypeErrorException,
RepositoryErrorException,
EntityNotKnownException,
PropertyErrorException,
PagingErrorException,
......@@ -1320,24 +1331,12 @@ public abstract class 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 FunctionNotSupportedException - the repository does not support entity proxies as first class elements.
* @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
*/
public abstract void addEntityProxy(String userId,
EntityProxy entityProxy) throws InvalidParameterException,
RepositoryErrorException,
TypeErrorException,
PropertyErrorException,
ClassificationErrorException,
StatusNotSupportedException,
FunctionNotSupportedException,
UserNotAuthorizedException;
......
......@@ -492,7 +492,7 @@ public abstract class OMRSMetadataCollectionBase extends OMRSMetadataCollection
parentConnector.validateRepositoryIsActive(methodName);
repositoryValidator.validateUserId(repositoryName, userId, methodName);
repositoryValidator.validateTypeGUID(repositoryName, guidParameterName, guid, methodName);
repositoryValidator.validateGUID(repositoryName, guidParameterName, guid, methodName);
/*
* Perform operation
......@@ -540,7 +540,7 @@ public abstract class OMRSMetadataCollectionBase extends OMRSMetadataCollection
parentConnector.validateRepositoryIsActive(methodName);
repositoryValidator.validateUserId(repositoryName, userId, methodName);
repositoryValidator.validateTypeGUID(repositoryName, guidParameterName, guid, methodName);
repositoryValidator.validateGUID(repositoryName, guidParameterName, guid, methodName);
/*
* Perform operation
......@@ -1259,11 +1259,12 @@ public abstract class OMRSMetadataCollectionBase 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.
* @param guid - String unique identifier for the entity
* @return the entity details if the entity is found in the metadata collection; otherwise return null
* @throws InvalidParameterException - the guid is null.
* @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
* the metadata collection is stored.
......@@ -1480,6 +1481,8 @@ public abstract class OMRSMetadataCollectionBase 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.
......@@ -1497,6 +1500,7 @@ public abstract class OMRSMetadataCollectionBase extends OMRSMetadataCollection
String sequencingProperty,
SequencingOrder sequencingOrder,
int pageSize) throws InvalidParameterException,
TypeErrorException,
RepositoryErrorException,
EntityNotKnownException,
PropertyErrorException,
......@@ -1506,6 +1510,7 @@ public abstract class OMRSMetadataCollectionBase extends OMRSMetadataCollection
{
final String methodName = "getRelationshipsForEntity";
final String guidParameterName = "entityGUID";
final String typeGUIDParameter = "relationshipTypeGUID";
final String asOfTimeParameter = "asOfTime";
final String pageSizeParameter = "pageSize";
......@@ -1518,6 +1523,7 @@ public abstract class OMRSMetadataCollectionBase extends OMRSMetadataCollection
repositoryValidator.validateUserId(repositoryName, userId, methodName);
repositoryValidator.validateGUID(repositoryName, guidParameterName, entityGUID, methodName);
repositoryValidator.validateAsOfTime(repositoryName, asOfTimeParameter, asOfTime, methodName);
repositoryValidator.validateOptionalTypeGUID(repositoryName, typeGUIDParameter, relationshipTypeGUID, methodName);
repositoryValidator.validatePageSize(repositoryName, pageSizeParameter, pageSize, methodName);
/*
......@@ -1563,10 +1569,10 @@ public abstract class OMRSMetadataCollectionBase extends OMRSMetadataCollection
* 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.
......@@ -1584,8 +1590,8 @@ public abstract class OMRSMetadataCollectionBase extends OMRSMetadataCollection
String sequencingProperty,
SequencingOrder sequencingOrder,
int pageSize) throws InvalidParameterException,
RepositoryErrorException,
TypeErrorException,
RepositoryErrorException,
PropertyErrorException,
PagingErrorException,
FunctionNotSupportedException,
......@@ -1594,7 +1600,7 @@ public abstract class OMRSMetadataCollectionBase extends OMRSMetadataCollection
final String methodName = "findEntitiesByProperty";
final String matchCriteriaParameterName = "matchCriteria";
final String matchPropertiesParameterName = "matchProperties";
final String guidParameterName = "entityTypeGUID";
final String typeGUIDParameterName = "entityTypeGUID";
final String asOfTimeParameter = "asOfTime";
final String pageSizeParameter = "pageSize";
......@@ -1605,7 +1611,7 @@ public abstract class OMRSMetadataCollectionBase extends OMRSMetadataCollection
parentConnector.validateRepositoryIsActive(methodName);
repositoryValidator.validateUserId(repositoryName, userId, methodName);
repositoryValidator.validateTypeGUID(repositoryName, guidParameterName, entityTypeGUID, methodName);
repositoryValidator.validateOptionalTypeGUID(repositoryName, typeGUIDParameterName, entityTypeGUID, methodName);
repositoryValidator.validateAsOfTime(repositoryName, asOfTimeParameter, asOfTime, methodName);
repositoryValidator.validatePageSize(repositoryName, pageSizeParameter, pageSize, methodName);
repositoryValidator.validateMatchCriteria(repositoryName,
......@@ -1656,10 +1662,10 @@ public abstract class OMRSMetadataCollectionBase 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.
......@@ -1678,8 +1684,8 @@ public abstract class OMRSMetadataCollectionBase extends OMRSMetadataCollection
String sequencingProperty,
SequencingOrder sequencingOrder,
int pageSize) throws InvalidParameterException,
RepositoryErrorException,
TypeErrorException,
RepositoryErrorException,
ClassificationErrorException,
PropertyErrorException,
PagingErrorException,
......@@ -1702,16 +1708,31 @@ public abstract class OMRSMetadataCollectionBase 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,
......@@ -1719,11 +1740,6 @@ public abstract class OMRSMetadataCollectionBase extends OMRSMetadataCollection
matchCriteria,
matchClassificationProperties,
methodName);
repositoryValidator.validateClassification(repositoryName,
classificationParameterName,
classificationName,
entityTypeDef.getName(),
methodName);
/*
* Perform operation
......@@ -1768,6 +1784,8 @@ public abstract class OMRSMetadataCollectionBase 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
......@@ -1786,6 +1804,7 @@ public abstract class OMRSMetadataCollectionBase extends OMRSMetadataCollection
String sequencingProperty,
SequencingOrder sequencingOrder,
int pageSize) throws InvalidParameterException,
TypeErrorException,
RepositoryErrorException,
PropertyErrorException,
PagingErrorException,
......@@ -1794,6 +1813,7 @@ public abstract class OMRSMetadataCollectionBase extends OMRSMetadataCollection
{
final String methodName = "findEntitiesByPropertyValue";
final String searchCriteriaParameterName = "searchCriteria";
final String typeGUIDParameter = "entityTypeGUID";
final String asOfTimeParameter = "asOfTime";
final String pageSizeParameter = "pageSize";
......@@ -1805,6 +1825,7 @@ public abstract class OMRSMetadataCollectionBase extends OMRSMetadataCollection
repositoryValidator.validateUserId(repositoryName, userId, methodName);
repositoryValidator.validateSearchCriteria(repositoryName, searchCriteriaParameterName, searchCriteria, methodName);
repositoryValidator.validateOptionalTypeGUID(repositoryName, typeGUIDParameter, entityTypeGUID, methodName);
repositoryValidator.validateAsOfTime(repositoryName, asOfTimeParameter, asOfTime, methodName);
repositoryValidator.validatePageSize(repositoryName, pageSizeParameter, pageSize, methodName);
......@@ -1999,10 +2020,10 @@ public abstract class OMRSMetadataCollectionBase 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.
......@@ -2019,8 +2040,8 @@ public abstract class OMRSMetadataCollectionBase extends OMRSMetadataCollection
String sequencingProperty,
SequencingOrder sequencingOrder,
int pageSize) throws InvalidParameterException,
RepositoryErrorException,
TypeErrorException,
RepositoryErrorException,
PropertyErrorException,
PagingErrorException,
FunctionNotSupportedException,
......@@ -2040,7 +2061,7 @@ public abstract class OMRSMetadataCollectionBase extends OMRSMetadataCollection
parentConnector.validateRepositoryIsActive(methodName);
repositoryValidator.validateUserId(repositoryName, userId, methodName);
repositoryValidator.validateTypeGUID(repositoryName, guidParameterName, relationshipTypeGUID, methodName);
repositoryValidator.validateOptionalTypeGUID(repositoryName, guidParameterName, relationshipTypeGUID, methodName);
repositoryValidator.validateAsOfTime(repositoryName, asOfTimeParameter, asOfTime, methodName);
repositoryValidator.validatePageSize(repositoryName, pageSizeParameter, pageSize, methodName);
repositoryValidator.validateMatchCriteria(repositoryName,
......@@ -2092,6 +2113,8 @@ public abstract class OMRSMetadataCollectionBase 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.
......@@ -2108,6 +2131,7 @@ public abstract class OMRSMetadataCollectionBase extends OMRSMetadataCollection
String sequencingProperty,
SequencingOrder sequencingOrder,
int pageSize) throws InvalidParameterException,
TypeErrorException,
RepositoryErrorException,
PropertyErrorException,
PagingErrorException,
......@@ -2116,6 +2140,7 @@ public abstract class OMRSMetadataCollectionBase extends OMRSMetadataCollection
{
final String methodName = "findRelationshipsByPropertyName";
final String asOfTimeParameter = "asOfTime";
final String typeGUIDParameter = "relationshipTypeGUID";
final String pageSizeParameter = "pageSize";
/*
......@@ -2125,6 +2150,7 @@ public abstract class OMRSMetadataCollectionBase extends OMRSMetadataCollection
parentConnector.validateRepositoryIsActive(methodName);
repositoryValidator.validateUserId(repositoryName, userId, methodName);
repositoryValidator.validateOptionalTypeGUID(repositoryName, typeGUIDParameter, relationshipTypeGUID, methodName);
repositoryValidator.validateAsOfTime(repositoryName, asOfTimeParameter, asOfTime, methodName);
repositoryValidator.validatePageSize(repositoryName, pageSizeParameter, pageSize, methodName);
......@@ -2232,10 +2258,10 @@ public abstract class OMRSMetadataCollectionBase 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 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 - one or more of the type guids passed on the request is not known by the
* metadata collection.
* @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.
......@@ -2249,9 +2275,9 @@ public abstract class OMRSMetadataCollectionBase extends OMRSMetadataCollection
List<String> limitResultsByClassification,
Date asOfTime,
int level) throws InvalidParameterException,
TypeErrorException,
RepositoryErrorException,
EntityNotKnownException,
TypeErrorException,
PropertyErrorException,
FunctionNotSupportedException,
UserNotAuthorizedException
......@@ -2277,7 +2303,7 @@ public abstract class OMRSMetadataCollectionBase extends OMRSMetadataCollection
{
for (String guid : entityTypeGUIDs)
{
repositoryValidator.validateGUID(repositoryName, entityTypeGUIDParameterName, guid, methodName);
repositoryValidator.validateTypeGUID(repositoryName, entityTypeGUIDParameterName, guid, methodName);
}
}
......@@ -2285,11 +2311,11 @@ public abstract class OMRSMetadataCollectionBase 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)
{
......@@ -2339,10 +2365,10 @@ public abstract class OMRSMetadataCollectionBase 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 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
......@@ -2361,8 +2387,8 @@ public abstract class OMRSMetadataCollectionBase extends OMRSMetadataCollection
String sequencingProperty,
SequencingOrder sequencingOrder,
int pageSize) throws InvalidParameterException,
RepositoryErrorException,
TypeErrorException,
RepositoryErrorException,
EntityNotKnownException,
PropertyErrorException,
PagingErrorException,
......@@ -2371,6 +2397,7 @@ public abstract class OMRSMetadataCollectionBase extends OMRSMetadataCollection
{
final String methodName = "getRelatedEntities";
final String entityGUIDParameterName = "startEntityGUID";
final String instanceTypesParameter = "instanceTypes";
final String asOfTimeParameter = "asOfTime";
final String pageSizeParameter = "pageSize";
......@@ -2385,6 +2412,14 @@ public abstract class OMRSMetadataCollectionBase extends OMRSMetadataCollection
repositoryValidator.validateAsOfTime(repositoryName, asOfTimeParameter, asOfTime, methodName);
repositoryValidator.validatePageSize(repositoryName, pageSizeParameter, pageSize, methodName);
if (instanceTypes != null)
{
for (String guid : instanceTypes)
{
repositoryValidator.validateTypeGUID(repositoryName, instanceTypesParameter, guid, methodName);
}
}
/*
* Perform operation
*/
......@@ -2457,7 +2492,7 @@ public abstract class OMRSMetadataCollectionBase 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,
......@@ -2505,24 +2540,12 @@ public abstract class OMRSMetadataCollectionBase 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 FunctionNotSupportedException - the repository does not support entity proxies as first class elements.
* @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,
FunctionNotSupportedException,
UserNotAuthorizedException
{
......@@ -2543,31 +2566,6 @@ public abstract class OMRSMetadataCollectionBase extends OMRSMetadataCollection
entityProxy,
methodName);
repositoryValidator.validateInstanceType(repositoryName, entityProxy);
String entityTypeGUID = entityProxy.getType().getTypeDefGUID();
TypeDef typeDef = repositoryHelper.getTypeDef(repositoryName, 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
*/
......@@ -3181,7 +3179,7 @@ public abstract class OMRSMetadataCollectionBase 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);
......
......@@ -1000,11 +1000,12 @@ public class OMRSRESTMetadataCollection 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.
* @param guid - String unique identifier for the entity
* @return the entity details if the entity is found in the metadata collection; otherwise return null
* @throws InvalidParameterException - the guid is null.
* @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
* the metadata collection is stored.
......@@ -1032,10 +1033,11 @@ public class OMRSRESTMetadataCollection 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.
* @param guid - String unique identifier for the entity
* @return EntitySummary structure
* @throws InvalidParameterException - the guid is null.
* @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
......@@ -1170,6 +1172,8 @@ public class OMRSRESTMetadataCollection 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.
......@@ -1187,6 +1191,7 @@ public class OMRSRESTMetadataCollection extends OMRSMetadataCollection
String sequencingProperty,
SequencingOrder sequencingOrder,
int pageSize) throws InvalidParameterException,
TypeErrorException,
RepositoryErrorException,
EntityNotKnownException,
PropertyErrorException,
......@@ -1213,6 +1218,7 @@ public class OMRSRESTMetadataCollection extends OMRSMetadataCollection
this.detectAndThrowEntityNotKnownException(methodName, restResult);
this.detectAndThrowFunctionNotSupportedException(methodName, restResult);
this.detectAndThrowPropertyErrorException(methodName, restResult);
this.detectAndThrowTypeErrorException(methodName, restResult);
this.detectAndThrowPagingErrorException(methodName, restResult);
this.detectAndThrowUserNotAuthorizedException(methodName, restResult);
this.detectAndThrowRepositoryErrorException(methodName, restResult);
......@@ -1246,10 +1252,10 @@ public class OMRSRESTMetadataCollection extends OMRSMetadataCollection
* 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.
......@@ -1267,8 +1273,8 @@ public class OMRSRESTMetadataCollection extends OMRSMetadataCollection
String sequencingProperty,
SequencingOrder sequencingOrder,
int pageSize) throws InvalidParameterException,
RepositoryErrorException,
TypeErrorException,
RepositoryErrorException,
PropertyErrorException,
PagingErrorException,
FunctionNotSupportedException,
......@@ -1326,6 +1332,7 @@ public class OMRSRESTMetadataCollection 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
......@@ -1348,8 +1355,8 @@ public class OMRSRESTMetadataCollection extends OMRSMetadataCollection
String sequencingProperty,
SequencingOrder sequencingOrder,
int pageSize) throws InvalidParameterException,
RepositoryErrorException,
TypeErrorException,
RepositoryErrorException,
ClassificationErrorException,
PropertyErrorException,
PagingErrorException,
......@@ -1411,6 +1418,7 @@ public class OMRSRESTMetadataCollection 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
......@@ -1429,6 +1437,7 @@ public class OMRSRESTMetadataCollection extends OMRSMetadataCollection
String sequencingProperty,
SequencingOrder sequencingOrder,
int pageSize) throws InvalidParameterException,
TypeErrorException,
RepositoryErrorException,
PropertyErrorException,
PagingErrorException,
......@@ -1454,6 +1463,7 @@ public class OMRSRESTMetadataCollection extends OMRSMetadataCollection
this.detectAndThrowFunctionNotSupportedException(methodName, restResult);
this.detectAndThrowInvalidParameterException(methodName, restResult);
this.detectAndThrowPropertyErrorException(methodName, restResult);
this.detectAndThrowTypeErrorException(methodName, restResult);
this.detectAndThrowPagingErrorException(methodName, restResult);
this.detectAndThrowUserNotAuthorizedException(methodName, restResult);
this.detectAndThrowRepositoryErrorException(methodName, restResult);
......@@ -1594,6 +1604,7 @@ public class OMRSRESTMetadataCollection 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
......@@ -1614,8 +1625,8 @@ public class OMRSRESTMetadataCollection extends OMRSMetadataCollection
String sequencingProperty,
SequencingOrder sequencingOrder,
int pageSize) throws InvalidParameterException,
RepositoryErrorException,
TypeErrorException,
RepositoryErrorException,
PropertyErrorException,
PagingErrorException,
FunctionNotSupportedException,
......@@ -1673,6 +1684,7 @@ public class OMRSRESTMetadataCollection 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.
......@@ -1689,6 +1701,7 @@ public class OMRSRESTMetadataCollection extends OMRSMetadataCollection
String sequencingProperty,
SequencingOrder sequencingOrder,
int pageSize) throws InvalidParameterException,
TypeErrorException,
RepositoryErrorException,
PropertyErrorException,
PagingErrorException,
......@@ -1713,6 +1726,7 @@ public class OMRSRESTMetadataCollection extends OMRSMetadataCollection
this.detectAndThrowFunctionNotSupportedException(methodName, restResult);
this.detectAndThrowInvalidParameterException(methodName, restResult);
this.detectAndThrowPropertyErrorException(methodName, restResult);
this.detectAndThrowTypeErrorException(methodName, restResult);
this.detectAndThrowPagingErrorException(methodName, restResult);
this.detectAndThrowUserNotAuthorizedException(methodName, restResult);
this.detectAndThrowRepositoryErrorException(methodName, restResult);
......@@ -1866,6 +1880,7 @@ public class OMRSRESTMetadataCollection 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 of 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 requested type is not known, or not supported in the metadata repository
......@@ -1995,24 +2010,12 @@ public class OMRSRESTMetadataCollection 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 FunctionNotSupportedException - the repository does not support entity proxies as first class elements.
* @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,
FunctionNotSupportedException,
UserNotAuthorizedException
{
......@@ -2026,10 +2029,6 @@ public class OMRSRESTMetadataCollection extends OMRSMetadataCollection
this.detectAndThrowFunctionNotSupportedException(methodName, restResult);
this.detectAndThrowInvalidParameterException(methodName, restResult);
this.detectAndThrowTypeErrorException(methodName, restResult);
this.detectAndThrowPropertyErrorException(methodName, restResult);
this.detectAndThrowClassificationErrorException(methodName, restResult);
this.detectAndThrowStatusNotSupportedException(methodName, restResult);
this.detectAndThrowUserNotAuthorizedException(methodName, restResult);
this.detectAndThrowRepositoryErrorException(methodName, restResult);
}
......
......@@ -120,6 +120,37 @@ public class OMRSRepositoryRESTServices
/**
* Return the URL for the requested instance.
*
* @param guid - unique identifier of the instance
* @return url
*/
public static String getEntityURL(String guid)
{
final String urlTemplate = "/instances/entity/{0}";
MessageFormat mf = new MessageFormat(urlTemplate);
return localServerURL + mf.format(guid);
}
/**
* Return the URL for the requested instance.
*
* @param guid - unique identifier of the instance
* @return url
*/
public static String getRelationshipURL(String guid)
{
final String urlTemplate = "/instances/relationship/{0}";
MessageFormat mf = new MessageFormat(urlTemplate);
return localServerURL + mf.format(guid);
}
/**
* Default constructor
*/
public OMRSRepositoryRESTServices()
......@@ -1332,15 +1363,15 @@ public class OMRSRepositoryRESTServices
/**
* 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 EntityDetailResponse:
* entity details if the entity is found in the metadata collection; otherwise return null or
* InvalidParameterException - the guid is null or
* @param guid - String unique identifier for the entity
* @return the entity details if the entity is found in the metadata collection; otherwise return null
* InvalidParameterException - the guid is null.
* RepositoryErrorException - there is a problem communicating with the metadata repository where
* the metadata collection is stored or
* the metadata collection is stored.
* UserNotAuthorizedException - the userId is not permitted to perform this operation.
*/
@RequestMapping(method = RequestMethod.GET, path = "/{userId}/instances/entity/{guid}/existence")
......@@ -1376,16 +1407,16 @@ public class OMRSRepositoryRESTServices
/**
* 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.
* @return EntitySummaryResponse:
* EntitySummary structure or
* InvalidParameterException - the guid is null or
* @param guid - String unique identifier for the entity
* @return EntitySummary structure or
* InvalidParameterException - the guid is null.
* RepositoryErrorException - there is a problem communicating with the metadata repository where
* the metadata collection is stored or
* EntityNotKnownException - the requested entity instance is not known in the metadata collection or
* the metadata collection is stored.
* EntityNotKnownException - the requested entity instance is not known in the metadata collection.
* UserNotAuthorizedException - the userId is not permitted to perform this operation.
*/
@RequestMapping(method = RequestMethod.GET, path = "/{userId}/instances/entity/{guid}/summary")
......@@ -1585,6 +1616,7 @@ public class OMRSRepositoryRESTServices
* @return RelationshipListResponse:
* Relationships list. Null means no relationships associated with the entity or
* InvalidParameterException - a parameter is invalid or null or
* TypeErrorException - the type guid passed on the request is not known by the metadata collection or
* RepositoryErrorException - there is a problem communicating with the metadata repository where
* the metadata collection is stored or
* EntityNotKnownException - the requested entity instance is not known in the metadata collection or
......@@ -1669,6 +1701,10 @@ public class OMRSRepositoryRESTServices
{
capturePropertyErrorException(response, error);
}
catch (TypeErrorException error)
{
captureTypeErrorException(response, error);
}
catch (PagingErrorException error)
{
capturePagingErrorException(response, error);
......@@ -1703,10 +1739,9 @@ public class OMRSRepositoryRESTServices
* a list of entities matching the supplied criteria - null means no matching entities in the metadata
* collection or
* InvalidParameterException - a parameter is invalid or null or
* TypeErrorException - the type guid passed on the request is not known by the metadata collection or
* RepositoryErrorException - there is a problem communicating with the metadata repository where
* the metadata collection is stored or
* TypeErrorException - the type guid passed on the request is not known by the
* metadata collection or
* PropertyErrorException - the properties specified are not valid for any of the requested types of
* entity or
* PagingErrorException - the paging/sequencing parameters are set up incorrectly or
......@@ -1828,10 +1863,9 @@ public class OMRSRepositoryRESTServices
* a list of entities matching the supplied criteria - null means no matching entities in the metadata
* collection or
* InvalidParameterException - a parameter is invalid or null or
* TypeErrorException - the type guid passed on the request is not known by the metadata collection or
* RepositoryErrorException - there is a problem communicating with the metadata repository where
* the metadata collection is stored or
* TypeErrorException - the type guid passed on the request is not known by the
* metadata collection or
* ClassificationErrorException - the classification request is not known to the metadata collection.
* PropertyErrorException - the properties specified are not valid for the requested type of
* classification or
......@@ -1933,7 +1967,6 @@ public class OMRSRepositoryRESTServices
}
/**
* Return a list of entities whose string based property values match the search criteria. The
* search criteria may include regex style wild cards.
......@@ -1959,6 +1992,7 @@ public class OMRSRepositoryRESTServices
* a list of entities matching the supplied criteria - null means no matching entities in the metadata
* collection or
* InvalidParameterException - a parameter is invalid or null or
* TypeErrorException - the type guid passed on the request is not known by the metadata collection or
* RepositoryErrorException - there is a problem communicating with the metadata repository where
* the metadata collection is stored or
* PropertyErrorException - the sequencing property specified is not valid for any of the requested types of
......@@ -1969,16 +2003,16 @@ public class OMRSRepositoryRESTServices
*/
@RequestMapping(method = RequestMethod.GET, path = "/{userId}/instances/entities/by-property-value")
public EntityListResponse fndEntitiesByPropertyValue(@PathVariable String userId,
@RequestParam(required = false) String entityTypeGUID,
@RequestParam String searchCriteria,
@RequestParam(required = false) int fromEntityElement,
@RequestParam(required = false) List<InstanceStatus> limitResultsByStatus,
@RequestParam(required = false) List<String> limitResultsByClassification,
@RequestParam(required = false) Date asOfTime,
@RequestParam(required = false) String sequencingProperty,
@RequestParam(required = false) SequencingOrder sequencingOrder,
@RequestParam(required = false) int pageSize)
public EntityListResponse findEntitiesByPropertyValue(@PathVariable String userId,
@RequestParam(required = false) String entityTypeGUID,
@RequestParam String searchCriteria,
@RequestParam(required = false) int fromEntityElement,
@RequestParam(required = false) List<InstanceStatus> limitResultsByStatus,
@RequestParam(required = false) List<String> limitResultsByClassification,
@RequestParam(required = false) Date asOfTime,
@RequestParam(required = false) String sequencingProperty,
@RequestParam(required = false) SequencingOrder sequencingOrder,
@RequestParam(required = false) int pageSize)
{
final String methodName = "findEntitiesByPropertyValue";
......@@ -2041,6 +2075,10 @@ public class OMRSRepositoryRESTServices
{
capturePropertyErrorException(response, error);
}
catch (TypeErrorException error)
{
captureTypeErrorException(response, error);
}
catch (PagingErrorException error)
{
capturePagingErrorException(response, error);
......@@ -2247,10 +2285,9 @@ public class OMRSRepositoryRESTServices
* @return RelationshipListResponse:
* a list of relationships. Null means no matching relationships or
* InvalidParameterException - one of the parameters is invalid or null or
* TypeErrorException - the type guid passed on the request is not known by the metadata collection or
* RepositoryErrorException - there is a problem communicating with the metadata repository where
* the metadata collection is stored or
* TypeErrorException - the type guid passed on the request is not known by the
* metadata collection or
* PropertyErrorException - the properties specified are not valid for any of the requested types of
* relationships or
* PagingErrorException - the paging/sequencing parameters are set up incorrectly or
......@@ -2367,6 +2404,7 @@ public class OMRSRepositoryRESTServices
* @return RelationshipListResponse:
* a list of relationships. Null means no matching relationships or
* InvalidParameterException - one of the parameters is invalid or null or
* TypeErrorException - the type guid passed on the request is not known by the metadata collection or
* RepositoryErrorException - there is a problem communicating with the metadata repository where
* the metadata collection is stored or
* PropertyErrorException - there is a problem with one of the other parameters or
......@@ -2445,6 +2483,10 @@ public class OMRSRepositoryRESTServices
{
capturePropertyErrorException(response, error);
}
catch (TypeErrorException error)
{
captureTypeErrorException(response, error);
}
catch (PagingErrorException error)
{
capturePagingErrorException(response, error);
......@@ -2555,10 +2597,9 @@ public class OMRSRepositoryRESTServices
* @return InstanceGraphResponse
* the sub-graph that represents the returned linked entities and their relationships or
* InvalidParameterException - one of the parameters is invalid or null or
* TypeErrorException - one of the type guids passed on the request is not known by the metadata collection or
* RepositoryErrorException - there is a problem communicating with the metadata repository where
* the metadata collection is stored or
* TypeErrorException - one or more of the type guids passed on the request is not known by the
* metadata collection or
* EntityNotKnownException - the entity identified by the entityGUID is not found in the metadata collection or
* PropertyErrorException - there is a problem with one of the other parameters or
* FunctionNotSupportedException - the repository does not support satOfTime parameter or
......@@ -2653,6 +2694,7 @@ public class OMRSRepositoryRESTServices
* @return EntityListResponse:
* list of entities either directly or indirectly connected to the start entity or
* InvalidParameterException - one of the parameters is invalid or null or
* TypeErrorException - one of the type guids passed on the request is not known by the metadata collection or
* RepositoryErrorException - there is a problem communicating with the metadata repository where
* the metadata collection is stored or
* TypeErrorException - the requested type is not known, or not supported in the metadata repository
......@@ -2894,22 +2936,6 @@ public class OMRSRepositoryRESTServices
{
captureInvalidParameterException(response, error);
}
catch (TypeErrorException error)
{
captureTypeDefErrorException(response, error);
}
catch (StatusNotSupportedException error)
{
captureStatusNotSupportedException(response, error);
}
catch (PropertyErrorException error)
{
capturePropertyErrorException(response, error);
}
catch (ClassificationErrorException error)
{
captureClassificationErrorException(response, error);
}
return response;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment