You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@atlas.apache.org by da...@apache.org on 2018/04/06 08:28:22 UTC
[18/31] atlas git commit: ATLAS-2122 OMAG Server Application and OMRS
APIs
http://git-wip-us.apache.org/repos/asf/atlas/blob/a1fd4068/omrs/src/main/java/org/apache/atlas/omrs/enterprise/repositoryconnector/EnterpriseOMRSRepositoryConnector.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/enterprise/repositoryconnector/EnterpriseOMRSRepositoryConnector.java b/omrs/src/main/java/org/apache/atlas/omrs/enterprise/repositoryconnector/EnterpriseOMRSRepositoryConnector.java
index f74a772..0e18748 100644
--- a/omrs/src/main/java/org/apache/atlas/omrs/enterprise/repositoryconnector/EnterpriseOMRSRepositoryConnector.java
+++ b/omrs/src/main/java/org/apache/atlas/omrs/enterprise/repositoryconnector/EnterpriseOMRSRepositoryConnector.java
@@ -17,14 +17,20 @@
*/
package org.apache.atlas.omrs.enterprise.repositoryconnector;
+import org.apache.atlas.ocf.Connector;
import org.apache.atlas.ocf.ffdc.ConnectorCheckedException;
+import org.apache.atlas.omrs.auditlog.OMRSAuditCode;
import org.apache.atlas.omrs.enterprise.connectormanager.OMRSConnectorConsumer;
import org.apache.atlas.omrs.enterprise.connectormanager.OMRSConnectorManager;
import org.apache.atlas.omrs.ffdc.exception.RepositoryErrorException;
+import org.apache.atlas.omrs.localrepository.repositorycontentmanager.OMRSRepositoryHelper;
+import org.apache.atlas.omrs.localrepository.repositorycontentmanager.OMRSRepositoryValidator;
import org.apache.atlas.omrs.metadatacollection.OMRSMetadataCollection;
import org.apache.atlas.omrs.metadatacollection.repositoryconnector.OMRSRepositoryConnector;
import org.apache.atlas.omrs.ffdc.OMRSErrorCode;
import org.apache.atlas.omrs.ffdc.exception.OMRSRuntimeException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.Iterator;
@@ -57,6 +63,7 @@ public class EnterpriseOMRSRepositoryConnector extends OMRSRepositoryConnector i
private FederatedConnector localCohortConnector = null;
private ArrayList<FederatedConnector> remoteCohortConnectors = new ArrayList<>();
+ private static final Logger log = LoggerFactory.getLogger(EnterpriseOMRSRepositoryConnector.class);
/**
* Constructor used by the EnterpriseOMRSConnectorProvider.
@@ -106,6 +113,8 @@ public class EnterpriseOMRSRepositoryConnector extends OMRSRepositoryConnector i
if (metadataCollectionId != null)
{
enterpriseMetadataCollection = new EnterpriseOMRSMetadataCollection(this,
+ repositoryHelper,
+ repositoryValidator,
enterpriseMetadataCollectionId,
enterpriseMetadataCollectionName);
@@ -143,12 +152,25 @@ public class EnterpriseOMRSRepositoryConnector extends OMRSRepositoryConnector i
}
/**
+ * Indicates that the connector is completely configured and can begin processing.
+ *
+ * @throws ConnectorCheckedException - there is a problem within the connector.
+ */
+ public void start() throws ConnectorCheckedException
+ {
+ super.start();
+ }
+
+
+ /**
* Free up any resources held since the connector is no longer needed.
*
* @throws ConnectorCheckedException - there is a problem disconnecting the connector.
*/
public void disconnect() throws ConnectorCheckedException
{
+ super.disconnect();
+
if ((connectorManager != null) && (connectorConsumerId != null))
{
connectorManager.unregisterConnectorConsumer(connectorConsumerId);
@@ -228,9 +250,31 @@ public class EnterpriseOMRSRepositoryConnector extends OMRSRepositoryConnector i
/**
+ * Return a repository helper that can be used by an OMAS to create types and instance objects.
+ *
+ * @return an OMRSRepositoryHelper object that is linked to the repository content manager for this server.
+ */
+ public OMRSRepositoryHelper getRepositoryHelper()
+ {
+ return super.repositoryHelper;
+ }
+
+
+ /**
+ * Return a repository validator that can be used by an OMAS to validate types and instance objects.
+ *
+ * @return an OMRSRepositoryValidator object that is linked to the repository content manager for this server.
+ */
+ public OMRSRepositoryValidator getRepositoryValidator()
+ {
+ return super.repositoryValidator;
+ }
+
+
+ /**
* Save the connector to the local repository. This is passed from the OMRSConnectorManager.
*
- * @param metadataCollectionId - Unique identifier for the metadata collection
+ * @param metadataCollectionId - Unique identifier for the metadata collection.
* @param localConnector - OMRSRepositoryConnector object for the local repository.
*/
public void setLocalConnector(String metadataCollectionId,
@@ -252,7 +296,7 @@ public class EnterpriseOMRSRepositoryConnector extends OMRSRepositoryConnector i
/**
* Pass the connector to one of the remote repositories in the metadata repository cohort.
*
- * @param metadataCollectionId - Unique identifier for the metadata collection
+ * @param metadataCollectionId - Unique identifier for the metadata collection.
* @param remoteConnector - OMRSRepositoryConnector object providing access to the remote repository.
*/
public void addRemoteConnector(String metadataCollectionId,
@@ -282,6 +326,7 @@ public class EnterpriseOMRSRepositoryConnector extends OMRSRepositoryConnector i
if (registeredConnector.getMetadataCollectionId().equals(metadataCollectionId))
{
+ this.disconnectConnector(registeredConnector);
iterator.remove();
}
}
@@ -292,11 +337,52 @@ public class EnterpriseOMRSRepositoryConnector extends OMRSRepositoryConnector i
*/
public void disconnectAllConnectors()
{
- // TODO
+ if (localCohortConnector != null)
+ {
+ this.disconnectConnector(localCohortConnector);
+
+ if (remoteCohortConnectors != null)
+ {
+ for (FederatedConnector remoteConnector : remoteCohortConnectors)
+ {
+ if (remoteConnector != null)
+ {
+ this.disconnectConnector(remoteConnector);
+ }
+ }
+ }
+ }
}
/**
+ * Issue a disconnect call on the supplied connector.
+ *
+ * @param federatedConnector - connector to disconnect.
+ */
+ private void disconnectConnector(FederatedConnector federatedConnector)
+ {
+ Connector connector = null;
+
+ if (federatedConnector != null)
+ {
+ connector = federatedConnector.getConnector();
+ }
+
+ if (connector != null)
+ {
+ try
+ {
+ connector.disconnect();
+ }
+ catch (Throwable error)
+ {
+ log.error("Exception from disconnect of connector to metadata collection:" + federatedConnector.getMetadataCollectionId() + " Error message was: " + error.getMessage());
+ }
+ }
+ }
+
+ /**
* FederatedConnector is a private class for storing details of each of the connectors to the repositories
* in the open metadata repository cohort.
*/
http://git-wip-us.apache.org/repos/asf/atlas/blob/a1fd4068/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/OMRSEventListener.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/OMRSEventListener.java b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/OMRSEventListener.java
index 9db6892..c1ed59b 100644
--- a/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/OMRSEventListener.java
+++ b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/OMRSEventListener.java
@@ -562,9 +562,7 @@ public class OMRSEventListener implements OMRSTopicListener
instanceEventOriginator.getServerName(),
instanceEventOriginator.getServerType(),
instanceEventOriginator.getOrganizationName(),
- instanceEvent.getTypeDefGUID(),
- instanceEvent.getTypeDefName(),
- instanceEvent.getInstanceGUID());
+ instanceEvent.getEntity());
break;
case PURGED_ENTITY_EVENT:
@@ -680,9 +678,7 @@ public class OMRSEventListener implements OMRSTopicListener
instanceEventOriginator.getServerName(),
instanceEventOriginator.getServerType(),
instanceEventOriginator.getOrganizationName(),
- instanceEvent.getTypeDefGUID(),
- instanceEvent.getTypeDefName(),
- instanceEvent.getInstanceGUID());
+ instanceEvent.getRelationship());
break;
case PURGED_RELATIONSHIP_EVENT:
http://git-wip-us.apache.org/repos/asf/atlas/blob/a1fd4068/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/OMRSEventPublisher.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/OMRSEventPublisher.java b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/OMRSEventPublisher.java
index 14a8e69..6f482b6 100644
--- a/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/OMRSEventPublisher.java
+++ b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/OMRSEventPublisher.java
@@ -17,7 +17,7 @@
*/
package org.apache.atlas.omrs.eventmanagement;
-import org.apache.atlas.ocf.properties.Connection;
+import org.apache.atlas.ocf.properties.beans.Connection;
import org.apache.atlas.omrs.admin.properties.OpenMetadataEventProtocolVersion;
import org.apache.atlas.omrs.auditlog.*;
import org.apache.atlas.omrs.eventmanagement.events.*;
@@ -37,6 +37,7 @@ import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.Date;
+import java.util.List;
/**
@@ -277,7 +278,7 @@ public class OMRSEventPublisher implements OMRSRegistryEventProcessor, OMRSTypeD
String originatorOrganizationName,
Date registrationTimestamp,
Connection remoteConnection,
- ArrayList<TypeDefSummary> typeDefList)
+ List<TypeDefSummary> typeDefList)
{
OMRSEventOriginator eventOriginator = new OMRSEventOriginator();
@@ -345,7 +346,7 @@ public class OMRSEventPublisher implements OMRSRegistryEventProcessor, OMRSTypeD
String originatorOrganizationName,
Date registrationTimestamp,
Connection remoteConnection,
- ArrayList<TypeDefSummary> typeDefList)
+ List<TypeDefSummary> typeDefList)
{
OMRSEventOriginator eventOriginator = new OMRSEventOriginator();
@@ -1108,18 +1109,14 @@ public class OMRSEventPublisher implements OMRSRegistryEventProcessor, OMRSTypeD
* @param originatorServerName - name of the server that the event came from.
* @param originatorServerType - type of server that the event came from.
* @param originatorOrganizationName - name of the organization that owns the server that sent the event.
- * @param typeDefGUID - unique identifier for this entity's TypeDef
- * @param typeDefName - name of this entity's TypeDef
- * @param instanceGUID - unique identifier for the entity
+ * @param entity - deleted entity
*/
public void processDeletedEntityEvent(String sourceName,
String originatorMetadataCollectionId,
String originatorServerName,
String originatorServerType,
String originatorOrganizationName,
- String typeDefGUID,
- String typeDefName,
- String instanceGUID)
+ EntityDetail entity)
{
OMRSEventOriginator eventOriginator = new OMRSEventOriginator();
@@ -1129,9 +1126,7 @@ public class OMRSEventPublisher implements OMRSRegistryEventProcessor, OMRSTypeD
eventOriginator.setOrganizationName(originatorOrganizationName);
OMRSInstanceEvent instanceEvent = new OMRSInstanceEvent(OMRSInstanceEventType.DELETED_ENTITY_EVENT,
- typeDefGUID,
- typeDefName,
- instanceGUID);
+ entity);
instanceEvent.setEventOriginator(eventOriginator);
@@ -1537,18 +1532,14 @@ public class OMRSEventPublisher implements OMRSRegistryEventProcessor, OMRSTypeD
* @param originatorServerName - name of the server that the event came from.
* @param originatorServerType - type of server that the event came from.
* @param originatorOrganizationName - name of the organization that owns the server that sent the event.
- * @param typeDefGUID - unique identifier for this relationship's TypeDef
- * @param typeDefName - name of this relationship's TypeDef
- * @param instanceGUID - unique identifier for the relationship
+ * @param relationship - deleted relationship
*/
public void processDeletedRelationshipEvent(String sourceName,
String originatorMetadataCollectionId,
String originatorServerName,
String originatorServerType,
String originatorOrganizationName,
- String typeDefGUID,
- String typeDefName,
- String instanceGUID)
+ Relationship relationship)
{
OMRSEventOriginator eventOriginator = new OMRSEventOriginator();
@@ -1558,9 +1549,7 @@ public class OMRSEventPublisher implements OMRSRegistryEventProcessor, OMRSTypeD
eventOriginator.setOrganizationName(originatorOrganizationName);
OMRSInstanceEvent instanceEvent = new OMRSInstanceEvent(OMRSInstanceEventType.DELETED_RELATIONSHIP_EVENT,
- typeDefGUID,
- typeDefName,
- instanceGUID);
+ relationship);
instanceEvent.setEventOriginator(eventOriginator);
http://git-wip-us.apache.org/repos/asf/atlas/blob/a1fd4068/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/OMRSRepositoryEventExchangeRule.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/OMRSRepositoryEventExchangeRule.java b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/OMRSRepositoryEventExchangeRule.java
index 66072ed..3a43fb3 100644
--- a/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/OMRSRepositoryEventExchangeRule.java
+++ b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/OMRSRepositoryEventExchangeRule.java
@@ -18,48 +18,119 @@
package org.apache.atlas.omrs.eventmanagement;
import org.apache.atlas.omrs.admin.properties.OpenMetadataExchangeRule;
-import org.apache.atlas.omrs.metadatacollection.properties.instances.EntityDetail;
-import org.apache.atlas.omrs.metadatacollection.properties.instances.Relationship;
+import org.apache.atlas.omrs.ffdc.OMRSErrorCode;
+import org.apache.atlas.omrs.ffdc.exception.OMRSLogicErrorException;
+import org.apache.atlas.omrs.localrepository.repositorycontentmanager.OMRSRepositoryContentManager;
+import org.apache.atlas.omrs.metadatacollection.properties.instances.InstanceHeader;
+import org.apache.atlas.omrs.metadatacollection.properties.instances.InstanceType;
+import org.apache.atlas.omrs.metadatacollection.properties.typedefs.TypeDef;
import org.apache.atlas.omrs.metadatacollection.properties.typedefs.TypeDefSummary;
-import org.apache.atlas.omrs.localrepository.repositorycontentmanager.OMRSTypeDefValidator;
import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
/**
* OMRSRepositoryEventExchangeRule determines if particular types of events should be exchanged on the OMRS Topic.
*/
public class OMRSRepositoryEventExchangeRule
{
- private String sourceName;
- private OMRSTypeDefValidator typeDefValidator;
- private OpenMetadataExchangeRule exchangeRule;
- private ArrayList<TypeDefSummary> selectedTypesToProcess;
+ private String sourceName;
+ private OMRSRepositoryContentManager repositoryContentManager;
+ private OpenMetadataExchangeRule exchangeRule;
+ private HashMap<String, TypeDefSummary> selectedTypesToProcess = new HashMap<>();
/**
* Constructor provides all of the objects used in the event exchange decision.
*
* @param sourceName - name of the caller
- * @param typeDefValidator - local manager of the type definitions (TypeDefs) used by the local repository.
+ * @param repositoryContentManager - local manager of the type definitions (TypeDefs) used by the local repository.
* @param exchangeRule - enum detailing the types of events to process.
* @param selectedTypesToProcess - supplementary list to support selective processing of events.
*/
- public OMRSRepositoryEventExchangeRule(String sourceName,
- OMRSTypeDefValidator typeDefValidator,
- OpenMetadataExchangeRule exchangeRule,
- ArrayList<TypeDefSummary> selectedTypesToProcess)
+ public OMRSRepositoryEventExchangeRule(String sourceName,
+ OMRSRepositoryContentManager repositoryContentManager,
+ OpenMetadataExchangeRule exchangeRule,
+ List<TypeDefSummary> selectedTypesToProcess)
{
+ final String methodName = "OMRSRepositoryEventExchangeRule constructor";
+
+ /*
+ * Validate the supplied parameters.
+ */
+ if (sourceName == null)
+ {
+ OMRSErrorCode errorCode = OMRSErrorCode.NULL_SOURCE_NAME;
+
+ String errorMessage = errorCode.getErrorMessageId()
+ + errorCode.getFormattedErrorMessage(methodName);
+
+ throw new OMRSLogicErrorException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ methodName,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+ if (repositoryContentManager == null)
+ {
+ OMRSErrorCode errorCode = OMRSErrorCode.NULL_CONTENT_MANAGER;
+ String errorMessage = errorCode.getErrorMessageId()
+ + errorCode.getFormattedErrorMessage(methodName);
+
+ throw new OMRSLogicErrorException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ methodName,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+ if (exchangeRule == null)
+ {
+ OMRSErrorCode errorCode = OMRSErrorCode.NULL_EXCHANGE_RULE;
+
+ String errorMessage = errorCode.getErrorMessageId()
+ + errorCode.getFormattedErrorMessage(methodName);
+
+ throw new OMRSLogicErrorException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ methodName,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+
this.sourceName = sourceName;
- this.typeDefValidator = typeDefValidator;
+ this.repositoryContentManager = repositoryContentManager;
this.exchangeRule = exchangeRule;
- this.selectedTypesToProcess = selectedTypesToProcess;
+
+ /*
+ * The selected types are loaded into a hash map for easy retrieval.
+ */
+ if (selectedTypesToProcess != null)
+ {
+ for (TypeDefSummary typeDefSummary : selectedTypesToProcess)
+ {
+ if (typeDefSummary != null)
+ {
+ String typeDefSummaryGUID = typeDefSummary.getGUID();
+
+ if (typeDefSummaryGUID != null)
+ {
+ this.selectedTypesToProcess.put(typeDefSummaryGUID, typeDefSummary);
+ }
+ }
+ }
+ }
}
/**
- * Determine if TypeDef events should be processed.
+ * Determine if TypeDef events should be processed. TypeDef events are processed unless the rule is set
+ * to registration events only.
*
- * @return boolean flag
+ * @return boolean flag indicating if the event should be processed.
*/
public boolean processTypeDefEvents()
{
@@ -83,13 +154,56 @@ public class OMRSRepositoryEventExchangeRule
*/
public boolean processInstanceEvent(String typeDefGUID, String typeDefName)
{
- if (typeDefValidator == null)
+ if (repositoryContentManager == null)
+ {
+ /*
+ * A set up error
+ */
+ return false;
+ }
+ else if ((exchangeRule == OpenMetadataExchangeRule.REGISTRATION_ONLY) ||
+ (exchangeRule == OpenMetadataExchangeRule.JUST_TYPEDEFS))
{
+ /*
+ * The rule says not to process instances
+ */
+ return false;
+ }
+ else if ((typeDefGUID == null) || (typeDefName == null))
+ {
+ /*
+ * The instance is invalid - this will be logged elsewhere.
+ */
return false;
}
else
{
- return typeDefValidator.isActiveType(sourceName, typeDefGUID, typeDefName);
+ /*
+ * Only active types should be processed.
+ */
+ if (repositoryContentManager.isActiveType(sourceName, typeDefGUID, typeDefName))
+ {
+ if (exchangeRule == OpenMetadataExchangeRule.ALL)
+ {
+ /*
+ * All active types should be processed
+ */
+ return true;
+ }
+ else
+ {
+ /*
+ * The exchange rule is either SELECTED_TYPES or LEARNED_TYPES - for either, the instance
+ * is processed if its type is in the selectedTypesToProcess list.
+ */
+ if (selectedTypesToProcess.get(typeDefGUID) != null)
+ {
+ return true;
+ }
+ }
+ }
+
+ return false;
}
}
@@ -102,7 +216,7 @@ public class OMRSRepositoryEventExchangeRule
*/
public boolean processInstanceEvent(TypeDefSummary typeDefSummary)
{
- if (typeDefValidator == null)
+ if (repositoryContentManager == null)
{
return false;
}
@@ -112,7 +226,7 @@ public class OMRSRepositoryEventExchangeRule
}
else
{
- return typeDefValidator.isActiveType(sourceName, typeDefSummary.getGUID(), typeDefSummary.getName());
+ return this.processInstanceEvent(typeDefSummary.getGUID(), typeDefSummary.getName());
}
}
@@ -120,47 +234,94 @@ public class OMRSRepositoryEventExchangeRule
/**
* Determine from the type of the instance if an instance event should be processed.
*
- * @param entity - details of the instance to test
+ * @param instance - details of the instance to test
* @return boolean flag
*/
- public boolean processInstanceEvent(EntityDetail entity)
+ public boolean processInstanceEvent(InstanceHeader instance)
{
- if (typeDefValidator == null)
+ if (repositoryContentManager == null)
{
return false;
}
- else if (entity == null)
+ else if (instance == null)
{
return false;
}
else
{
- // TODO
- return true;
+ InstanceType type = instance.getType();
+
+ if (type == null)
+ {
+ return false;
+ }
+ else
+ {
+ return this.processInstanceEvent(type.getTypeDefGUID(), type.getTypeDefName());
+ }
}
}
/**
- * Determine from the type of the instance if an instance event should be processed.
+ * If the rule is in learning mode, determine if the type of the instance should be added to the list
+ * of types being processed. For this to happen, the instance header must include a valid type, the type
+ * must be an active type for this server and not already included in the list.
*
- * @param relationship - details of the instance to test
- * @return boolean flag
+ * Any errors discovered in the types, of this rule's set up result in a false result. No diagnostics are
+ * created because this method is called very frequently and the errors will be trapped and logged elsewhere.
+ *
+ * @param instance - details of the instance to test
+ * @return boolean flag - true if the instance should be saved as a learned instance.
*/
- public boolean processInstanceEvent(Relationship relationship)
+ public boolean learnInstanceEvent(InstanceHeader instance)
{
- if (typeDefValidator == null)
+ if (repositoryContentManager == null)
{
+ /*
+ * This is a logic error the cause of which has probably already been logged.
+ */
return false;
}
- else if (relationship == null)
- {
- return false;
- }
- else
+ else if (exchangeRule == OpenMetadataExchangeRule.LEARNED_TYPES)
{
- // TODO
- return true;
+ InstanceType type = instance.getType();
+
+ if (type != null)
+ {
+ if (repositoryContentManager.isActiveType(sourceName, type.getTypeDefGUID(), type.getTypeDefName()))
+ {
+ /*
+ * All active types should be learned and added to the rule so save copies are updated by
+ * incoming events.
+ */
+ if (selectedTypesToProcess.get(type.getTypeDefGUID()) == null)
+ {
+ try
+ {
+ TypeDef typeDef = repositoryContentManager.getTypeDef(sourceName,
+ type.getTypeDefGUID(),
+ type.getTypeDefName());
+
+ if (typeDef != null)
+ {
+ selectedTypesToProcess.put(typeDef.getGUID(), typeDef);
+ }
+ }
+ catch (Throwable error)
+ {
+ return false; /* Problem with type */
+ }
+ }
+
+ /*
+ * The instance should be saved if it is not already known.
+ */
+ return true;
+ }
+ }
}
+
+ return false; /* rule is not set to LEARNED_TYPES (or a problem with the instance) */
}
}
http://git-wip-us.apache.org/repos/asf/atlas/blob/a1fd4068/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/OMRSRepositoryEventManager.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/OMRSRepositoryEventManager.java b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/OMRSRepositoryEventManager.java
index ff06a76..ae2b31c 100644
--- a/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/OMRSRepositoryEventManager.java
+++ b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/OMRSRepositoryEventManager.java
@@ -21,10 +21,11 @@ import org.apache.atlas.omrs.auditlog.OMRSAuditLog;
import org.apache.atlas.omrs.auditlog.OMRSAuditingComponent;
import org.apache.atlas.omrs.eventmanagement.events.OMRSInstanceEventProcessor;
import org.apache.atlas.omrs.eventmanagement.events.OMRSTypeDefEventProcessor;
+import org.apache.atlas.omrs.ffdc.OMRSErrorCode;
+import org.apache.atlas.omrs.ffdc.exception.OMRSLogicErrorException;
import org.apache.atlas.omrs.localrepository.repositorycontentmanager.OMRSRepositoryValidator;
import org.apache.atlas.omrs.metadatacollection.properties.instances.EntityDetail;
import org.apache.atlas.omrs.metadatacollection.properties.instances.InstanceProvenanceType;
-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.slf4j.Logger;
@@ -45,7 +46,7 @@ public class OMRSRepositoryEventManager implements OMRSRepositoryEventProcessor
{
private ArrayList<OMRSTypeDefEventProcessor> typeDefEventConsumers = new ArrayList<>();
private ArrayList<OMRSInstanceEventProcessor> instanceEventConsumers = new ArrayList<>();
- private OMRSRepositoryValidator repositoryValidator = new OMRSRepositoryValidator();
+ private OMRSRepositoryValidator repositoryValidator; /* set in constructor */
private OMRSRepositoryEventExchangeRule exchangeRule; /* set in constructor */
/*
@@ -60,19 +61,53 @@ public class OMRSRepositoryEventManager implements OMRSRepositoryEventProcessor
*
* @param exchangeRule - this is the rule that determines which events are processed.
*/
- public OMRSRepositoryEventManager(OMRSRepositoryEventExchangeRule exchangeRule)
+ public OMRSRepositoryEventManager(OMRSRepositoryEventExchangeRule exchangeRule,
+ OMRSRepositoryValidator repositoryValidator)
{
+ final String methodName = "OMRSRepositoryEventManager";
/*
* If the exchangeRule is null, throw exception
*/
if (exchangeRule == null)
{
- // TODO throw exception
+ OMRSErrorCode errorCode = OMRSErrorCode.NULL_EXCHANGE_RULE;
+ String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage(methodName);
+
+ throw new OMRSLogicErrorException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ methodName,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
}
this.exchangeRule = exchangeRule;
+
+ /*
+ * If the repository validator is null, throw an exception
+ */
+ if (repositoryValidator == null)
+ {
+ OMRSErrorCode errorCode = OMRSErrorCode.NULL_REPOSITORY_VALIDATOR;
+ String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage();
+
+ throw new OMRSLogicErrorException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ methodName,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+
+ this.repositoryValidator = repositoryValidator;
+
+ if (log.isDebugEnabled())
+ {
+ log.debug("New Event Manager");
+ }
}
+
/**
* Adds a new consumer to the list of consumers that the OMRSRepositoryEventManager will notify of
* any TypeDef events it receives.
@@ -720,23 +755,18 @@ public class OMRSRepositoryEventManager implements OMRSRepositoryEventProcessor
* @param originatorServerName - name of the server that the event came from.
* @param originatorServerType - type of server that the event came from.
* @param originatorOrganizationName - name of the organization that owns the server that sent the event.
- * @param typeDefGUID - unique identifier for this entity's TypeDef
- * @param typeDefName - name of this entity's TypeDef
- * @param instanceGUID - unique identifier for the entity
+ * @param entity - deleted entity
*/
public void processDeletedEntityEvent(String sourceName,
String originatorMetadataCollectionId,
String originatorServerName,
String originatorServerType,
String originatorOrganizationName,
- String typeDefGUID,
- String typeDefName,
- String instanceGUID)
+ EntityDetail entity)
{
- if (repositoryValidator.validInstanceId(sourceName, typeDefGUID, typeDefName, TypeDefCategory.ENTITY_DEF, instanceGUID))
+ if (repositoryValidator.validEntity(sourceName, entity))
{
- if (exchangeRule.processInstanceEvent(typeDefGUID,
- typeDefName))
+ if (exchangeRule.processInstanceEvent(entity))
{
for (OMRSInstanceEventProcessor consumer : instanceEventConsumers)
{
@@ -745,9 +775,7 @@ public class OMRSRepositoryEventManager implements OMRSRepositoryEventProcessor
originatorServerName,
originatorServerType,
originatorOrganizationName,
- typeDefGUID,
- typeDefName,
- instanceGUID);
+ entity);
}
}
}
@@ -1171,22 +1199,18 @@ public class OMRSRepositoryEventManager implements OMRSRepositoryEventProcessor
* @param originatorServerName - name of the server that the event came from.
* @param originatorServerType - type of server that the event came from.
* @param originatorOrganizationName - name of the organization that owns the server that sent the event.
- * @param typeDefGUID - unique identifier for this relationship's TypeDef
- * @param typeDefName - name of this relationship's TypeDef
- * @param instanceGUID - unique identifier for the relationship
+ * @param relationship - deleted relationship
*/
public void processDeletedRelationshipEvent(String sourceName,
String originatorMetadataCollectionId,
String originatorServerName,
String originatorServerType,
String originatorOrganizationName,
- String typeDefGUID,
- String typeDefName,
- String instanceGUID)
+ Relationship relationship)
{
- if (repositoryValidator.validInstanceId(sourceName, typeDefGUID, typeDefName, TypeDefCategory.RELATIONSHIP_DEF, instanceGUID))
+ if (repositoryValidator.validRelationship(sourceName, relationship))
{
- if (exchangeRule.processInstanceEvent(typeDefGUID, typeDefName))
+ if (exchangeRule.processInstanceEvent(relationship))
{
for (OMRSInstanceEventProcessor consumer: instanceEventConsumers)
{
@@ -1195,9 +1219,7 @@ public class OMRSRepositoryEventManager implements OMRSRepositoryEventProcessor
originatorServerName,
originatorServerType,
originatorOrganizationName,
- typeDefGUID,
- typeDefName,
- instanceGUID);
+ relationship);
}
}
}
http://git-wip-us.apache.org/repos/asf/atlas/blob/a1fd4068/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSEvent.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSEvent.java b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSEvent.java
index 21cce9e..9a591e2 100644
--- a/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSEvent.java
+++ b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSEvent.java
@@ -18,13 +18,12 @@
package org.apache.atlas.omrs.eventmanagement.events;
-import org.apache.atlas.ocf.properties.Connection;
+import org.apache.atlas.ocf.properties.beans.Connection;
import org.apache.atlas.omrs.eventmanagement.events.v1.OMRSEventV1;
import org.apache.atlas.omrs.eventmanagement.events.v1.OMRSEventV1ErrorSection;
import org.apache.atlas.omrs.metadatacollection.properties.instances.InstanceProvenanceType;
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.TypeDefCategory;
import org.apache.atlas.omrs.metadatacollection.properties.typedefs.TypeDefSummary;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
http://git-wip-us.apache.org/repos/asf/atlas/blob/a1fd4068/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSInstanceEventProcessor.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSInstanceEventProcessor.java b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSInstanceEventProcessor.java
index b2f0ceb..fea400b 100644
--- a/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSInstanceEventProcessor.java
+++ b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSInstanceEventProcessor.java
@@ -166,18 +166,14 @@ public interface OMRSInstanceEventProcessor
* @param originatorServerName - name of the server that the event came from.
* @param originatorServerType - type of server that the event came from.
* @param originatorOrganizationName - name of the organization that owns the server that sent the event.
- * @param typeDefGUID - unique identifier for this entity's TypeDef
- * @param typeDefName - name of this entity's TypeDef
- * @param instanceGUID - unique identifier for the entity
+ * @param entity - deleted entity
*/
void processDeletedEntityEvent(String sourceName,
String originatorMetadataCollectionId,
String originatorServerName,
String originatorServerType,
String originatorOrganizationName,
- String typeDefGUID,
- String typeDefName,
- String instanceGUID);
+ EntityDetail entity);
/**
@@ -418,18 +414,14 @@ public interface OMRSInstanceEventProcessor
* @param originatorServerName - name of the server that the event came from.
* @param originatorServerType - type of server that the event came from.
* @param originatorOrganizationName - name of the organization that owns the server that sent the event.
- * @param typeDefGUID - unique identifier for this relationship's TypeDef
- * @param typeDefName - name of this relationship's TypeDef
- * @param instanceGUID - unique identifier for the relationship
+ * @param relationship - deleted relationship
*/
void processDeletedRelationshipEvent(String sourceName,
String originatorMetadataCollectionId,
String originatorServerName,
String originatorServerType,
String originatorOrganizationName,
- String typeDefGUID,
- String typeDefName,
- String instanceGUID);
+ Relationship relationship);
/**
http://git-wip-us.apache.org/repos/asf/atlas/blob/a1fd4068/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSRegistryEvent.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSRegistryEvent.java b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSRegistryEvent.java
index 6db78a0..0f9b515 100644
--- a/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSRegistryEvent.java
+++ b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSRegistryEvent.java
@@ -17,7 +17,7 @@
*/
package org.apache.atlas.omrs.eventmanagement.events;
-import org.apache.atlas.ocf.properties.Connection;
+import org.apache.atlas.ocf.properties.beans.Connection;
import org.apache.atlas.omrs.eventmanagement.events.v1.OMRSEventV1;
import org.apache.atlas.omrs.eventmanagement.events.v1.OMRSEventV1RegistrySection;
import org.apache.atlas.omrs.metadatacollection.properties.typedefs.TypeDefSummary;
@@ -27,6 +27,7 @@ import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.Date;
+import java.util.List;
/**
@@ -59,7 +60,7 @@ public class OMRSRegistryEvent extends OMRSEvent
/*
* Used in the registration process to enable the repositories to detect incompatible TypeDefs.
*/
- private ArrayList<TypeDefSummary> typeDefSummaries = null;
+ private List<TypeDefSummary> typeDefSummaries = null;
/*
* Specific variables only used in error reporting. It defines the subset of error codes from OMRSEvent
@@ -122,7 +123,7 @@ public class OMRSRegistryEvent extends OMRSEvent
public OMRSRegistryEvent(OMRSRegistryEventType registryEventType,
Date registrationTimestamp,
Connection remoteConnection,
- ArrayList<TypeDefSummary> typeDefSummaries)
+ List<TypeDefSummary> typeDefSummaries)
{
super(OMRSEventCategory.REGISTRY);
@@ -214,7 +215,7 @@ public class OMRSRegistryEvent extends OMRSEvent
*
* @return TypeDefSummaries object
*/
- public ArrayList<TypeDefSummary> getTypeDefSummaries()
+ public List<TypeDefSummary> getTypeDefSummaries()
{
return typeDefSummaries;
}
http://git-wip-us.apache.org/repos/asf/atlas/blob/a1fd4068/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSRegistryEventErrorCode.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSRegistryEventErrorCode.java b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSRegistryEventErrorCode.java
index 95022cd..19a77eb 100644
--- a/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSRegistryEventErrorCode.java
+++ b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSRegistryEventErrorCode.java
@@ -17,7 +17,6 @@
*/
package org.apache.atlas.omrs.eventmanagement.events;
-import org.apache.atlas.omrs.eventmanagement.events.OMRSEventErrorCode;
/**
* OMRSRegistryEventErrorCode defines the list of error codes that are used to record errors in the registration
http://git-wip-us.apache.org/repos/asf/atlas/blob/a1fd4068/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSRegistryEventProcessor.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSRegistryEventProcessor.java b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSRegistryEventProcessor.java
index 91ae433..620c6b3 100644
--- a/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSRegistryEventProcessor.java
+++ b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSRegistryEventProcessor.java
@@ -18,11 +18,12 @@
package org.apache.atlas.omrs.eventmanagement.events;
-import org.apache.atlas.ocf.properties.Connection;
+import org.apache.atlas.ocf.properties.beans.Connection;
import org.apache.atlas.omrs.metadatacollection.properties.typedefs.TypeDefSummary;
import java.util.ArrayList;
import java.util.Date;
+import java.util.List;
/**
* OMRSRegistryEventProcessor is an interface implemented by a component that is able to process
@@ -51,7 +52,7 @@ public interface OMRSRegistryEventProcessor
String originatorOrganizationName,
Date registrationTimestamp,
Connection remoteConnection,
- ArrayList<TypeDefSummary> typeDefList);
+ List<TypeDefSummary> typeDefList);
/**
@@ -91,7 +92,7 @@ public interface OMRSRegistryEventProcessor
String originatorOrganizationName,
Date registrationTimestamp,
Connection remoteConnection,
- ArrayList<TypeDefSummary> typeDefList);
+ List<TypeDefSummary> typeDefList);
/**
http://git-wip-us.apache.org/repos/asf/atlas/blob/a1fd4068/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/v1/OMRSEventV1ErrorSection.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/v1/OMRSEventV1ErrorSection.java b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/v1/OMRSEventV1ErrorSection.java
index 8926491..2e74bb7 100644
--- a/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/v1/OMRSEventV1ErrorSection.java
+++ b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/v1/OMRSEventV1ErrorSection.java
@@ -17,20 +17,28 @@
*/
package org.apache.atlas.omrs.eventmanagement.events.v1;
-import org.apache.atlas.ocf.properties.Connection;
+import com.fasterxml.jackson.annotation.JsonAutoDetect;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import org.apache.atlas.ocf.properties.beans.Connection;
import org.apache.atlas.omrs.eventmanagement.events.OMRSEventErrorCode;
import org.apache.atlas.omrs.metadatacollection.properties.instances.InstanceProvenanceType;
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.TypeDefCategory;
import org.apache.atlas.omrs.metadatacollection.properties.typedefs.TypeDefSummary;
import java.io.Serializable;
+import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE;
+import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY;
+
/**
* OMRSEventV1ErrorSection describes the properties used to record errors detected by one of the members of the
* open metadata repository cohort.
*/
+@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown=true)
public class OMRSEventV1ErrorSection implements Serializable
{
private static final long serialVersionUID = 1L;
http://git-wip-us.apache.org/repos/asf/atlas/blob/a1fd4068/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/v1/OMRSEventV1InstanceSection.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/v1/OMRSEventV1InstanceSection.java b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/v1/OMRSEventV1InstanceSection.java
index f5d55fa..f31c302 100644
--- a/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/v1/OMRSEventV1InstanceSection.java
+++ b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/v1/OMRSEventV1InstanceSection.java
@@ -17,6 +17,9 @@
*/
package org.apache.atlas.omrs.eventmanagement.events.v1;
+import com.fasterxml.jackson.annotation.JsonAutoDetect;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
import org.apache.atlas.omrs.eventmanagement.events.OMRSInstanceEventType;
import org.apache.atlas.omrs.metadatacollection.properties.instances.EntityDetail;
import org.apache.atlas.omrs.metadatacollection.properties.instances.Relationship;
@@ -24,9 +27,15 @@ import org.apache.atlas.omrs.metadatacollection.properties.typedefs.TypeDefSumma
import java.io.Serializable;
+import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE;
+import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY;
+
/**
* OMRSEventV1InstanceSection describes the properties specific to instance events
*/
+@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown=true)
public class OMRSEventV1InstanceSection implements Serializable
{
private static final long serialVersionUID = 1L;
http://git-wip-us.apache.org/repos/asf/atlas/blob/a1fd4068/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/v1/OMRSEventV1RegistrySection.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/v1/OMRSEventV1RegistrySection.java b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/v1/OMRSEventV1RegistrySection.java
index 0fb5f6c..91da30c 100644
--- a/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/v1/OMRSEventV1RegistrySection.java
+++ b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/v1/OMRSEventV1RegistrySection.java
@@ -17,17 +17,27 @@
*/
package org.apache.atlas.omrs.eventmanagement.events.v1;
-import org.apache.atlas.ocf.properties.Connection;
+import com.fasterxml.jackson.annotation.JsonAutoDetect;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import org.apache.atlas.ocf.properties.beans.Connection;
import org.apache.atlas.omrs.eventmanagement.events.OMRSRegistryEventType;
import org.apache.atlas.omrs.metadatacollection.properties.typedefs.TypeDefSummary;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
+import java.util.List;
+
+import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE;
+import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY;
/**
* OMRSEventV1RegistrySection describes properties that are used exclusively for registry events.
*/
+@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown=true)
public class OMRSEventV1RegistrySection implements Serializable
{
private static final long serialVersionUID = 1L;
@@ -35,7 +45,7 @@ public class OMRSEventV1RegistrySection implements Serializable
private OMRSRegistryEventType registryEventType = null;
private Date registrationTimestamp = null;
private Connection remoteConnection = null;
- private ArrayList<TypeDefSummary> TypeDefList = null;
+ private ArrayList<TypeDefSummary> typeDefList = null;
public OMRSEventV1RegistrySection()
{
@@ -71,13 +81,27 @@ public class OMRSEventV1RegistrySection implements Serializable
this.remoteConnection = remoteConnection;
}
- public ArrayList<TypeDefSummary> getTypeDefList()
+ public List<TypeDefSummary> getTypeDefList()
{
- return TypeDefList;
+ if (typeDefList == null)
+ {
+ return null;
+ }
+ else
+ {
+ return new ArrayList<>(typeDefList);
+ }
}
- public void setTypeDefList(ArrayList<TypeDefSummary> typeDefList)
+ public void setTypeDefList(List<TypeDefSummary> typeDefList)
{
- TypeDefList = typeDefList;
+ if (typeDefList == null)
+ {
+ this.typeDefList = null;
+ }
+ else
+ {
+ this.typeDefList = new ArrayList<>(typeDefList);
+ }
}
}
http://git-wip-us.apache.org/repos/asf/atlas/blob/a1fd4068/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/v1/OMRSEventV1TypeDefSection.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/v1/OMRSEventV1TypeDefSection.java b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/v1/OMRSEventV1TypeDefSection.java
index fc75df5..d035f75 100644
--- a/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/v1/OMRSEventV1TypeDefSection.java
+++ b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/v1/OMRSEventV1TypeDefSection.java
@@ -17,6 +17,9 @@
*/
package org.apache.atlas.omrs.eventmanagement.events.v1;
+import com.fasterxml.jackson.annotation.JsonAutoDetect;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
import org.apache.atlas.omrs.eventmanagement.events.OMRSTypeDefEventType;
import org.apache.atlas.omrs.metadatacollection.properties.typedefs.AttributeTypeDef;
import org.apache.atlas.omrs.metadatacollection.properties.typedefs.TypeDef;
@@ -25,9 +28,15 @@ import org.apache.atlas.omrs.metadatacollection.properties.typedefs.TypeDefSumma
import java.io.Serializable;
+import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE;
+import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY;
+
/**
* OMRSEventV1TypeDefSection describes the properties specific to TypeDef related events
*/
+@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown=true)
public class OMRSEventV1TypeDefSection implements Serializable
{
private static final long serialVersionUID = 1L;
http://git-wip-us.apache.org/repos/asf/atlas/blob/a1fd4068/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/repositoryeventmapper/OMRSRepositoryEventMapper.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/repositoryeventmapper/OMRSRepositoryEventMapper.java b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/repositoryeventmapper/OMRSRepositoryEventMapper.java
index 99a8569..3d3ae70 100644
--- a/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/repositoryeventmapper/OMRSRepositoryEventMapper.java
+++ b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/repositoryeventmapper/OMRSRepositoryEventMapper.java
@@ -19,6 +19,7 @@ package org.apache.atlas.omrs.eventmanagement.repositoryeventmapper;
import org.apache.atlas.omrs.eventmanagement.OMRSRepositoryEventProcessor;
import org.apache.atlas.omrs.localrepository.repositorycontentmanager.OMRSRepositoryHelper;
+import org.apache.atlas.omrs.localrepository.repositorycontentmanager.OMRSRepositoryValidator;
import org.apache.atlas.omrs.metadatacollection.repositoryconnector.OMRSRepositoryConnector;
/**
@@ -36,20 +37,58 @@ public interface OMRSRepositoryEventMapper
* @param repositoryConnector - this is the connector to the local repository that the event mapper is processing
* events from. The repository connector is used to retrieve additional information
* necessary to fill out the OMRS Events.
- * @param repositoryHelper - provides helper methods for building TypeDefs and metadata instances such as
- * entities and relationships.
- * @param localMetadataCollectionId - unique identifier for the local repository's metadata collection.
- * @param localServerName - name of the local server.
- * @param localServerType - type of local repository/server.
- * @param localOrganizationName - name of the organization that owns the local metadata repository.
*/
void initialize(String repositoryEventMapperName,
- OMRSRepositoryConnector repositoryConnector,
- OMRSRepositoryHelper repositoryHelper,
- String localMetadataCollectionId,
- String localServerName,
- String localServerType,
- String localOrganizationName);
+ OMRSRepositoryConnector repositoryConnector);
+
+
+ /**
+ * Set up a repository helper object for the repository connector to use.
+ *
+ * @param repositoryHelper - helper object for building TypeDefs and metadata instances.
+ */
+ void setRepositoryHelper(OMRSRepositoryHelper repositoryHelper);
+
+
+ /**
+ * Set up a repository validator for the repository connector to use.
+ *
+ * @param repositoryValidator - validator object to check the validity of TypeDefs and metadata instances.
+ */
+ void setRepositoryValidator(OMRSRepositoryValidator repositoryValidator);
+
+
+ /**
+ * Set up the name of the server where the metadata collection resides.
+ *
+ * @param serverName - String name
+ */
+ void setServerName(String serverName);
+
+
+ /**
+ * Set up the descriptive string describing the type of the server. This might be the
+ * name of the product, or similar identifier.
+ *
+ * @param serverType - String server type
+ */
+ void setServerType(String serverType);
+
+
+ /**
+ * Set up the name of the organization that runs/owns the server.
+ *
+ * @param organizationName - String organization name
+ */
+ void setOrganizationName(String organizationName);
+
+
+ /**
+ * Set up the unique Id for this metadata collection.
+ *
+ * @param metadataCollectionId - String unique Id
+ */
+ void setMetadataCollectionId(String metadataCollectionId);
/**
@@ -62,4 +101,7 @@ public interface OMRSRepositoryEventMapper
* open metadata repository cohort.
*/
void setRepositoryEventProcessor(OMRSRepositoryEventProcessor repositoryEventProcessor);
+
+
+
}
http://git-wip-us.apache.org/repos/asf/atlas/blob/a1fd4068/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/repositoryeventmapper/OMRSRepositoryEventMapperBase.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/repositoryeventmapper/OMRSRepositoryEventMapperBase.java b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/repositoryeventmapper/OMRSRepositoryEventMapperBase.java
index 4d9db96..e84735c 100644
--- a/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/repositoryeventmapper/OMRSRepositoryEventMapperBase.java
+++ b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/repositoryeventmapper/OMRSRepositoryEventMapperBase.java
@@ -17,25 +17,12 @@
*/
package org.apache.atlas.omrs.eventmanagement.repositoryeventmapper;
-import org.apache.atlas.ocf.ConnectorBase;
-import org.apache.atlas.omrs.eventmanagement.OMRSRepositoryEventProcessor;
-import org.apache.atlas.omrs.localrepository.repositorycontentmanager.OMRSRepositoryHelper;
-import org.apache.atlas.omrs.metadatacollection.repositoryconnector.OMRSRepositoryConnector;
/**
* OMRSRepositoryEventMapperBase provides a base class for implementors of OMRSRepositoryEventMapper.
*/
-public abstract class OMRSRepositoryEventMapperBase extends ConnectorBase implements OMRSRepositoryEventMapper
+public abstract class OMRSRepositoryEventMapperBase extends OMRSRepositoryEventMapperConnector
{
- protected OMRSRepositoryEventProcessor repositoryEventProcessor = null;
- protected String repositoryEventMapperName = null;
- protected OMRSRepositoryConnector repositoryConnector = null;
- protected OMRSRepositoryHelper repositoryHelper = null;
- protected String localMetadataCollectionId = null;
- protected String localServerName = null;
- protected String localServerType = null;
- protected String localOrganizationName = null;
-
/**
* Default constructor for OCF ConnectorBase.
*/
@@ -43,50 +30,4 @@ public abstract class OMRSRepositoryEventMapperBase extends ConnectorBase implem
{
super();
}
-
-
- /**
- * Set up the repository event listener for this connector to use. The connector should pass
- * each type or instance metadata change reported by its metadata repository's metadata on to the
- * repository event listener.
- *
- * @param repositoryEventProcessor - listener responsible for distributing notifications of local
- * changes to metadata types and instances to the rest of the
- * open metadata repository cluster.
- */
- public void setRepositoryEventProcessor(OMRSRepositoryEventProcessor repositoryEventProcessor)
- {
- this.repositoryEventProcessor = repositoryEventProcessor;
- }
-
-
- /**
- * Pass additional information to the connector needed to process events.
- *
- * @param repositoryEventMapperName - repository event mapper name used for the source of the OMRS events.
- * @param repositoryConnector - ths is the connector to the local repository that the event mapper is processing
- * events from. The repository connector is used to retrieve additional information
- * necessary to fill out the OMRS Events.
- * @param repositoryHelper - the TypeDef helper is used to create metadata instances that are
- * @param localMetadataCollectionId - unique identifier for the local repository's metadata collection.
- * @param localServerName - name of the local server.
- * @param localServerType - type of local repository/server.
- * @param localOrganizationName - name of the organization that owns the local metadata repository.
- */
- public void initialize(String repositoryEventMapperName,
- OMRSRepositoryConnector repositoryConnector,
- OMRSRepositoryHelper repositoryHelper,
- String localMetadataCollectionId,
- String localServerName,
- String localServerType,
- String localOrganizationName)
- {
- this.repositoryEventMapperName = repositoryEventMapperName;
- this.repositoryConnector = repositoryConnector;
- this.repositoryHelper = repositoryHelper;
- this.localMetadataCollectionId = localMetadataCollectionId;
- this.localServerName = localServerName;
- this.localServerType = localServerType;
- this.localOrganizationName = localOrganizationName;
- }
}
http://git-wip-us.apache.org/repos/asf/atlas/blob/a1fd4068/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/repositoryeventmapper/OMRSRepositoryEventMapperConnector.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/repositoryeventmapper/OMRSRepositoryEventMapperConnector.java b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/repositoryeventmapper/OMRSRepositoryEventMapperConnector.java
new file mode 100644
index 0000000..0db06e4
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/repositoryeventmapper/OMRSRepositoryEventMapperConnector.java
@@ -0,0 +1,169 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.atlas.omrs.eventmanagement.repositoryeventmapper;
+
+import org.apache.atlas.ocf.ConnectorBase;
+import org.apache.atlas.ocf.ffdc.ConnectorCheckedException;
+import org.apache.atlas.omrs.eventmanagement.OMRSRepositoryEventProcessor;
+import org.apache.atlas.omrs.localrepository.repositorycontentmanager.OMRSRepositoryHelper;
+import org.apache.atlas.omrs.localrepository.repositorycontentmanager.OMRSRepositoryValidator;
+import org.apache.atlas.omrs.metadatacollection.repositoryconnector.OMRSRepositoryConnector;
+
+/**
+ * OMRSRepositoryEventMapperBase provides a base class for implementors of OMRSRepositoryEventMapper.
+ */
+public abstract class OMRSRepositoryEventMapperConnector extends ConnectorBase implements OMRSRepositoryEventMapper
+{
+ protected OMRSRepositoryEventProcessor repositoryEventProcessor = null;
+ protected String repositoryEventMapperName = null;
+ protected OMRSRepositoryConnector repositoryConnector = null;
+ protected OMRSRepositoryHelper repositoryHelper = null;
+ protected OMRSRepositoryValidator repositoryValidator = null;
+ protected String localMetadataCollectionId = null;
+ protected String localServerName = null;
+ protected String localServerType = null;
+ protected String localOrganizationName = null;
+
+ /**
+ * Default constructor for OCF ConnectorBase.
+ */
+ public OMRSRepositoryEventMapperConnector()
+ {
+ super();
+ }
+
+
+ /**
+ * Pass additional information to the connector needed to process events.
+ *
+ * @param repositoryEventMapperName - repository event mapper name used for the source of the OMRS events.
+ * @param repositoryConnector - ths is the connector to the local repository that the event mapper is processing
+ * events from. The repository connector is used to retrieve additional information
+ * necessary to fill out the OMRS Events.
+ */
+ public void initialize(String repositoryEventMapperName,
+ OMRSRepositoryConnector repositoryConnector)
+ {
+ this.repositoryEventMapperName = repositoryEventMapperName;
+ this.repositoryConnector = repositoryConnector;
+ }
+
+
+ /**
+ * Set up a repository helper object for the repository connector to use.
+ *
+ * @param repositoryHelper - helper object for building TypeDefs and metadata instances.
+ */
+ public void setRepositoryHelper(OMRSRepositoryHelper repositoryHelper)
+ {
+ this.repositoryHelper = repositoryHelper;
+ }
+
+
+ /**
+ * Set up a repository validator for the repository connector to use.
+ *
+ * @param repositoryValidator - validator object to check the validity of TypeDefs and metadata instances.
+ */
+ public void setRepositoryValidator(OMRSRepositoryValidator repositoryValidator)
+ {
+ this.repositoryValidator = repositoryValidator;
+ }
+
+
+ /**
+ * Set up the name of the server where the metadata collection resides.
+ *
+ * @param serverName - String name
+ */
+ public void setServerName(String serverName)
+ {
+ this.localServerName = serverName;
+ }
+
+
+ /**
+ * Set up the descriptive string describing the type of the server. This might be the
+ * name of the product, or similar identifier.
+ *
+ * @param serverType - String server type
+ */
+ public void setServerType(String serverType)
+ {
+ this.localServerType = serverType;
+ }
+
+
+ /**
+ * Set up the name of the organization that runs/owns the server.
+ *
+ * @param organizationName - String organization name
+ */
+ public void setOrganizationName(String organizationName)
+ {
+ this.localOrganizationName = organizationName;
+ }
+
+
+ /**
+ * Set up the unique Id for this metadata collection.
+ *
+ * @param metadataCollectionId - String unique Id
+ */
+ public void setMetadataCollectionId(String metadataCollectionId)
+ {
+ this.localMetadataCollectionId = metadataCollectionId;
+ }
+
+
+ /**
+ * Set up the repository event listener for this connector to use. The connector should pass
+ * each type or instance metadata change reported by its metadata repository's metadata on to the
+ * repository event listener.
+ *
+ * @param repositoryEventProcessor - listener responsible for distributing notifications of local
+ * changes to metadata types and instances to the rest of the
+ * open metadata repository cluster.
+ */
+ public void setRepositoryEventProcessor(OMRSRepositoryEventProcessor repositoryEventProcessor)
+ {
+ this.repositoryEventProcessor = repositoryEventProcessor;
+ }
+
+
+ /**
+ * Indicates that the connector is completely configured and can begin processing.
+ *
+ * @throws ConnectorCheckedException - there is a problem within the connector.
+ */
+ public void start() throws ConnectorCheckedException
+ {
+ super.start();
+ }
+
+
+ /**
+ * Free up any resources held since the connector is no longer needed.
+ *
+ * @throws ConnectorCheckedException - there is a problem within the connector.
+ */
+ public void disconnect() throws ConnectorCheckedException
+ {
+ super.disconnect();
+ }
+}