Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Classification events #6226

Merged
merged 8 commits into from
Feb 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions MAINTAINERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,12 @@ The current Egeria maintainers are:

| Name | Email |
| -------------- | -----------------
| Mandy Chessell | [email protected].com |
| Mandy Chessell | mandy.e.chessell@gmail.com |
| Nigel Jones | [email protected] |
| David Radley | [email protected] |
| Graham Wallis | [email protected] |
| Maryna Strelchuk | [email protected] |
| Bogdan Sava | [email protected] |
| Chris Replogle | [email protected] |
| Daniela Valentina Otelea | [email protected] |
| Chris Grote | [email protected] |
| Raluca Popa | [email protected] |
| Chris Replogle | [email protected] |
Expand All @@ -43,6 +41,8 @@ contributions, we have a strong foundation to build on.

| Name | Email |
| -------------- | -----------------
| Graham Wallis | [email protected] |
| Daniela Valentina Otelea | [email protected] |
| Kees van de Fliert | [email protected] |
| Ruxandra Gabriela Rosu | [email protected] |
| Cong Chen | [email protected] |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@ public void processInstanceEvent(OMRSInstanceEvent instanceEvent)
case CLASSIFIED_ENTITY_EVENT:
case RECLASSIFIED_ENTITY_EVENT:
case DECLASSIFIED_ENTITY_EVENT:
processEntityDetail(entityDetail);
if (entityDetail != null) {
processEntityDetail(entityDetail);
}
break;
case NEW_RELATIONSHIP_EVENT :
case UPDATED_RELATIONSHIP_EVENT:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ public List<String> getAssetsByToken(String userId,
* @param userId userId of user making request.
* @param connectionName this may be the qualifiedName or displayName of the connection.
*
* @return Connector connector instance.
* @return Connector connector instance - or null if there is no connection
*
* @throws InvalidParameterException one of the parameters is null or invalid.
* @throws ConnectionCheckedException there are errors in the configuration of the connection which is preventing
Expand All @@ -456,17 +456,24 @@ public Connector getConnectorByName(String userId,
PropertyServerException,
UserNotAuthorizedException
{
final String methodName = "getConnectorByName";
final String nameParameter = "connectionName";
final String methodName = "getConnectorByName";
final String nameParameter = "connectionName";

invalidParameterHandler.validateUserId(userId, methodName);
invalidParameterHandler.validateName(connectionName, nameParameter, methodName);

return this.getConnectorForConnection(restClient,
serviceURLName,
userId,
super.getConnectionByName(restClient, serviceURLName, userId, connectionName),
methodName);
Connection connection = super.getConnectionByName(restClient, serviceURLName, userId, connectionName);

if (connection != null)
{
return this.getConnectorForConnection(restClient,
serviceURLName,
userId,
connection,
methodName);
}

return null;
}


Expand All @@ -476,7 +483,7 @@ public Connector getConnectorByName(String userId,
* @param userId userId of user making request.
* @param assetGUID the unique id for the asset within the metadata repository.
*
* @return Connector connector instance.
* @return Connector connector instance - or null if there is no connection
*
* @throws InvalidParameterException one of the parameters is null or invalid.
* @throws ConnectionCheckedException there are errors in the configuration of the connection which is preventing
Expand All @@ -499,11 +506,18 @@ public Connector getConnectorForAsset(String userId,
invalidParameterHandler.validateUserId(userId, methodName);
invalidParameterHandler.validateGUID(assetGUID, guidParameter, methodName);

return this.getConnectorForConnection(restClient,
serviceURLName,
userId,
this.getConnectionForAsset(restClient, serviceURLName, userId, assetGUID),
methodName);
Connection connection = this.getConnectionForAsset(restClient, serviceURLName, userId, assetGUID);

if (connection != null)
{
return this.getConnectorForConnection(restClient,
serviceURLName,
userId,
connection,
methodName);
}

return null;
}


Expand All @@ -513,7 +527,7 @@ public Connector getConnectorForAsset(String userId,
* @param userId userId of user making request.
* @param connectionGUID the unique id for the connection within the metadata repository.
*
* @return Connector connector instance.
* @return Connector connector instance - or null if there is no connection
*
* @throws InvalidParameterException one of the parameters is null or invalid.
* @throws ConnectionCheckedException there are errors in the configuration of the connection which is preventing
Expand All @@ -536,11 +550,18 @@ public Connector getConnectorByGUID(String userId,
invalidParameterHandler.validateUserId(userId, methodName);
invalidParameterHandler.validateGUID(connectionGUID, guidParameter, methodName);

return this.getConnectorForConnection(restClient,
serviceURLName,
userId,
super.getConnectionByGUID(restClient, serviceURLName, userId, connectionGUID),
methodName);
Connection connection = super.getConnectionByGUID(restClient, serviceURLName, userId, connectionGUID);

if (connection != null)
{
return this.getConnectorForConnection(restClient,
serviceURLName,
userId,
connection,
methodName);
}

return null;
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,13 @@ public void initialize(AccessServiceConfig accessServiceConfig,
this.registerWithEnterpriseTopic(AccessServiceDescription.ASSET_CONSUMER_OMAS.getAccessServiceFullName(),
serverName,
omrsTopicConnector,
new AssetConsumerOMRSTopicListener(eventPublisher,
new AssetConsumerOMRSTopicListener(instance.getAssetHandler(),
eventPublisher,
repositoryConnector.getRepositoryHelper(),
repositoryConnector.getRepositoryValidator(),
accessServiceConfig.getAccessServiceName(),
serverName,
serverUserName,
supportedZones,
auditLog),
auditLog);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
/* Copyright Contributors to the ODPi Egeria project. */
package org.odpi.openmetadata.accessservices.assetconsumer.listener;

import org.odpi.openmetadata.accessservices.assetconsumer.elements.AssetElement;
import org.odpi.openmetadata.accessservices.assetconsumer.events.AssetConsumerEventType;
import org.odpi.openmetadata.accessservices.assetconsumer.events.NewAssetEvent;
import org.odpi.openmetadata.accessservices.assetconsumer.events.UpdatedAssetEvent;
import org.odpi.openmetadata.commonservices.generichandlers.AssetHandler;
import org.odpi.openmetadata.commonservices.generichandlers.OpenMetadataAPIMapper;
import org.odpi.openmetadata.commonservices.ocf.metadatamanagement.converters.AssetConverter;
import org.odpi.openmetadata.frameworks.auditlog.AuditLog;
import org.odpi.openmetadata.frameworks.connectors.properties.beans.Asset;
Expand All @@ -27,47 +30,54 @@
*/
public class AssetConsumerOMRSTopicListener extends OMRSTopicListenerBase
{
private static final String assetTypeName = "Asset";
private static final String assetTypeName = "Asset";

private static final Logger log = LoggerFactory.getLogger(AssetConsumerOMRSTopicListener.class);

private OMRSRepositoryHelper repositoryHelper;
private OMRSRepositoryValidator repositoryValidator;
private String componentName;
private String serverName;
private List<String> supportedZones;
private AssetConsumerPublisher publisher;
private OMRSRepositoryHelper repositoryHelper;
private OMRSRepositoryValidator repositoryValidator;
private String componentName;
private String serverName;
private String serverUserId;
private List<String> supportedZones;
private AssetHandler<AssetElement> assetHandler;
private AssetConsumerPublisher publisher;


/**
* The constructor is given the connection to the out topic for Asset Consumer OMAS
* along with classes for testing and manipulating instances.
*
* @param assetHandler provides access to assets
* @param eventPublisher publisher for the out topic
* @param repositoryHelper provides methods for working with metadata instances
* @param repositoryValidator provides validation of metadata instance
* @param componentName name of component
* @param serverName local server name
* @param serverUserId userId for this server
* @param supportedZones list of zones covered by this instance of the access service.
* @param auditLog log for errors and information messages
*/
public AssetConsumerOMRSTopicListener(AssetConsumerPublisher eventPublisher,
OMRSRepositoryHelper repositoryHelper,
OMRSRepositoryValidator repositoryValidator,
String componentName,
String serverName,
List<String> supportedZones,
AuditLog auditLog)
public AssetConsumerOMRSTopicListener(AssetHandler<AssetElement> assetHandler,
AssetConsumerPublisher eventPublisher,
OMRSRepositoryHelper repositoryHelper,
OMRSRepositoryValidator repositoryValidator,
String componentName,
String serverName,
String serverUserId,
List<String> supportedZones,
AuditLog auditLog)
{
super(componentName, auditLog);

this.repositoryHelper = repositoryHelper;
this.repositoryValidator = repositoryValidator;
this.componentName = componentName;
this.serverName = serverName;
this.serverUserId = serverUserId;
this.supportedZones = supportedZones;

publisher = eventPublisher;
this.assetHandler = assetHandler;
this.publisher = eventPublisher;
}

/**
Expand All @@ -78,6 +88,8 @@ public AssetConsumerOMRSTopicListener(AssetConsumerPublisher eventPublisher,
@Override
public void processInstanceEvent(OMRSInstanceEvent instanceEvent)
{
final String methodName = "processInstanceEvent";

log.debug("Processing instance event: " + instanceEvent);

if (instanceEvent == null)
Expand All @@ -100,15 +112,41 @@ else if (instanceEventType == OMRSInstanceEventType.UPDATED_ENTITY_EVENT)
this.processUpdatedEntity(instanceEvent.getEntity(),
instanceEvent.getOriginalEntity());
}
else if (instanceEventType == OMRSInstanceEventType.CLASSIFIED_ENTITY_EVENT)
{
this.processUpdatedEntity(instanceEvent.getEntity(),
instanceEvent.getOriginalEntity());
}
else if (instanceEventType == OMRSInstanceEventType.RECLASSIFIED_ENTITY_EVENT)
else if ((instanceEventType == OMRSInstanceEventType.CLASSIFIED_ENTITY_EVENT) ||
(instanceEventType == OMRSInstanceEventType.RECLASSIFIED_ENTITY_EVENT))
{
this.processUpdatedEntity(instanceEvent.getEntity(),
instanceEvent.getOriginalEntity());
if (instanceEvent.getEntity() != null)
{
this.processUpdatedEntity(instanceEvent.getEntity(), null);
}
else if (instanceEvent.getEntityProxy() != null)
{
final String parameterName = "entityProxy.getGUID";

try
{
EntityDetail entity = assetHandler.getEntityFromRepository(serverUserId,
instanceEvent.getEntityProxy().getGUID(),
parameterName,
OpenMetadataAPIMapper.ASSET_TYPE_NAME,
null,
null,
false,
false,
supportedZones,
null,
methodName);

if (entity != null)
{
this.processUpdatedEntity(entity, null);
}
}
catch (Exception error)
{
log.debug("No access to asset - probably belongs to another cohort");
}
}
}
}
else
Expand Down Expand Up @@ -181,7 +219,17 @@ private void processUpdatedEntity(EntityDetail entity,
event.setEventType(AssetConsumerEventType.UPDATED_ASSET_EVENT);
event.setAsset(assetBean);
event.setOriginalAsset(assetConverterForOriginal.getAssetBean());
event.setUpdateTime(entity.getUpdateTime());
if (entity.getUpdateTime() != null)
{
event.setUpdateTime(entity.getUpdateTime());
}
else
{
/*
* A classification was updated - need a dedicated classification message
*/
event.setUpdateTime(entity.getCreateTime());
}

publisher.publishUpdatedAssetEvent(event);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ LoggingHandler getLoggingHandler()
* @return handler object
* @throws PropertyServerException the instance has not been initialized successfully
*/
AssetHandler<AssetElement> getAssetHandler() throws PropertyServerException
public AssetHandler<AssetElement> getAssetHandler() throws PropertyServerException
{
final String methodName = "getAssetHandler";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,19 @@ public void processInstanceEvent(OMRSInstanceEvent instanceEvent) {
processDeletedEntity(entityDetail);
break;
case CLASSIFIED_ENTITY_EVENT:
processClassifiedEntityEvent(entityDetail);
if (entityDetail != null) {
processClassifiedEntityEvent(entityDetail);
}
break;
case RECLASSIFIED_ENTITY_EVENT:
processReclassifiedEntityEvent(entityDetail);
if (entityDetail != null) {
processReclassifiedEntityEvent(entityDetail);
}
break;
case DECLASSIFIED_ENTITY_EVENT:
processDeclassifiedEntityEvent(entityDetail);
if (entityDetail != null) {
processDeclassifiedEntityEvent(entityDetail);
}
break;
case NEW_RELATIONSHIP_EVENT:
processNewRelationshipEvent(relationship);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1354,6 +1354,7 @@ public Classification getClassification(String typeName,
{
Classification classification = new Classification();
InstanceType type = this.getInstanceType(typeName);

classification.setName(typeName);
this.setInstanceAuditHeader(classification, type, status);
classification.setProperties(properties);
Expand Down
Loading