Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/odpi/egeria into egeria-code
Browse files Browse the repository at this point in the history
  • Loading branch information
mandy-chessell committed Jul 13, 2021
2 parents f4b9135 + cc5d74f commit e16cf89
Showing 1 changed file with 97 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,8 @@ public void processNewEntityEvent(String sourceName,
methodName,
originatorMetadataCollectionId,
originatorServerName,
entity);
entity,
OMRSInstanceEventType.NEW_ENTITY_EVENT);
}


Expand Down Expand Up @@ -763,7 +764,8 @@ public void processUpdatedEntityEvent(String sourceName,
methodName,
originatorMetadataCollectionId,
originatorServerName,
newEntity);
newEntity,
OMRSInstanceEventType.UPDATED_ENTITY_EVENT);
}


Expand Down Expand Up @@ -793,7 +795,8 @@ public void processUndoneEntityEvent(String sourceName,
methodName,
originatorMetadataCollectionId,
originatorServerName,
entity);
entity,
OMRSInstanceEventType.UNDONE_ENTITY_EVENT);
}


Expand Down Expand Up @@ -1083,7 +1086,8 @@ public void processRestoredEntityEvent(String sourceName,
methodName,
originatorMetadataCollectionId,
originatorServerName,
entity);
entity,
OMRSInstanceEventType.RESTORED_ENTITY_EVENT);
}


Expand Down Expand Up @@ -1117,7 +1121,8 @@ public void processReIdentifiedEntityEvent(String sourceName,
methodName,
originatorMetadataCollectionId,
originatorServerName,
entity);
entity,
OMRSInstanceEventType.RE_IDENTIFIED_ENTITY_EVENT);
}


Expand Down Expand Up @@ -1151,7 +1156,8 @@ public void processReTypedEntityEvent(String sourceName,
methodName,
originatorMetadataCollectionId,
originatorServerName,
entity);
entity,
OMRSInstanceEventType.RETYPED_ENTITY_EVENT);
}


Expand Down Expand Up @@ -1185,7 +1191,8 @@ public void processReHomedEntityEvent(String sourceName,
methodName,
originatorMetadataCollectionId,
originatorServerName,
entity);
entity,
OMRSInstanceEventType.RE_HOMED_ENTITY_EVENT);
}


Expand Down Expand Up @@ -1274,7 +1281,8 @@ public void processRefreshEntityEvent(String sourceName,
methodName,
originatorMetadataCollectionId,
originatorServerName,
entity);
entity,
OMRSInstanceEventType.REFRESHED_ENTITY_EVENT);
}


Expand Down Expand Up @@ -2208,12 +2216,14 @@ private void removeReferenceCopyOfInstance(TypeDefSummary typeDefSummary,
* sent the event.
* @param originatorServerName name of the server that the event came from.
* @param entity details of the new entity
* @param eventType the type of event that triggered this update
*/
private void updateReferenceEntity(String sourceName,
String methodName,
String originatorMetadataCollectionId,
String originatorServerName,
EntityDetail entity)
private void updateReferenceEntity(String sourceName,
String methodName,
String originatorMetadataCollectionId,
String originatorServerName,
EntityDetail entity,
OMRSInstanceEventType eventType)
{
try
{
Expand All @@ -2235,6 +2245,7 @@ private void updateReferenceEntity(String sourceName,
if (compareAndValidateReferenceInstance(originatorServerName,
entity,
storedEntity,
eventType,
methodName))
{
/*
Expand Down Expand Up @@ -2263,13 +2274,15 @@ private void updateReferenceEntity(String sourceName,
* @param originatorServerName sender of the event being processed
* @param incomingInstance this is the instance received
* @param storedInstance this is the instance in the repository
* @param eventType the type of event in which the incoming instance was received
* @param methodName calling method
* @return boolean indicating that it is ok to store the incoming instance
*/
private boolean compareAndValidateReferenceInstance(String originatorServerName,
InstanceHeader incomingInstance,
InstanceHeader storedInstance,
String methodName)
private boolean compareAndValidateReferenceInstance(String originatorServerName,
InstanceHeader incomingInstance,
InstanceHeader storedInstance,
OMRSInstanceEventType eventType,
String methodName)
{
if (storedInstance == null)
{
Expand Down Expand Up @@ -2312,13 +2325,73 @@ private boolean compareAndValidateReferenceInstance(String originatorSe
if (!incomingInstance.getMetadataCollectionId().equals(
storedInstance.getMetadataCollectionId()))
{
auditLog.logMessage(methodName,
OMRSAuditCode.NEW_HOME_INFORMATION.getMessageDefinition(Long.toString(incomingInstance.getVersion()),
incomingInstance.getGUID(),
originatorServerName,
incomingInstance.getMetadataCollectionId(),
storedInstance.getMetadataCollectionId()),
incomingInstance.toString());
if (eventType == OMRSInstanceEventType.RE_HOMED_ENTITY_EVENT || eventType == OMRSInstanceEventType.RE_HOMED_RELATIONSHIP_EVENT)
{
auditLog.logMessage(methodName,
OMRSAuditCode.NEW_HOME_INFORMATION.getMessageDefinition(Long.toString(incomingInstance.getVersion()),
incomingInstance.getGUID(),
originatorServerName,
incomingInstance.getMetadataCollectionId(),
storedInstance.getMetadataCollectionId()),
incomingInstance.toString());
}
else
{
/*
* The metadata collection IDs not matching is only valid for a re-homed instance
* event, in all other cases we should respond with an instance conflict event.
* (Note that the same will be done if the 'createTime' does not match in the
* outermost conditional, and this just further covers the case where the 'createTime'
* is the same but the metadata collection ID differs.)
*/
try
{
AuditLogMessageDefinition messageDefinition = OMRSAuditCode.PROCESS_INSTANCE_GUID_CONFLICT.getMessageDefinition(
incomingInstanceType.getTypeDefName(),
incomingInstanceType.getTypeDefName(),
originatorServerName,
incomingInstance.getMetadataCollectionId(),
storedInstance.getGUID(),
storedInstanceType.getTypeDefName(),
storedInstanceType.getTypeDefGUID());
outboundRepositoryEventProcessor.processConflictingInstancesEvent(localServerName,
localMetadataCollectionId,
localRepositoryConnector.getServerName(),
localRepositoryConnector.getServerType(),
localRepositoryConnector.getOrganizationName(),
incomingInstance.getMetadataCollectionId(),
repositoryHelper.getTypeDef(
localServerName,
"incomingInstanceType",
incomingInstanceType.getTypeDefGUID(),
methodName),
incomingInstance.getGUID(),
localMetadataCollectionId,
storedInstance.getInstanceProvenanceType(),
repositoryHelper.getTypeDef(
localServerName,
"storedInstanceType",
storedInstanceType.getTypeDefGUID(),
methodName),
storedInstance.getGUID(),
messageFormatter.getFormattedMessage(messageDefinition));
}
catch (Exception error)
{
/*
* Don't ever expect to be here - it probably means that the getTypeDef method
* threw an exception because the type name is not known - but then how did we get
* this far if that were the case!
*/
final String localMethodName = "compareAndValidateReferenceInstance";

handleUnexpectedErrorFromEvent(error,
localMethodName,
originatorServerName,
incomingInstance.getMetadataCollectionId());
}
return false;
}
}

if (!incomingInstanceType.getTypeDefName().equals(storedInstanceType.getTypeDefName()))
Expand Down

0 comments on commit e16cf89

Please sign in to comment.