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/02/16 09:52:34 UTC

[18/30] atlas git commit: ATLAS-2246: OMRS Connector API plus REST and IGC Connector skeleton - 15th February 2018

http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/OMRSRepositoryEventProcessor.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/OMRSRepositoryEventProcessor.java b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/OMRSRepositoryEventProcessor.java
new file mode 100644
index 0000000..126f137
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/OMRSRepositoryEventProcessor.java
@@ -0,0 +1,30 @@
+/*
+ * 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;
+
+
+import org.apache.atlas.omrs.eventmanagement.events.OMRSInstanceEventProcessor;
+import org.apache.atlas.omrs.eventmanagement.events.OMRSTypeDefEventProcessor;
+
+/**
+ * OMRSRepositoryEventProcessor describes the interface of a component that can process both TypeDef and Instance
+ * events from an open metadata repository.
+ */
+public interface OMRSRepositoryEventProcessor extends OMRSTypeDefEventProcessor, OMRSInstanceEventProcessor
+{
+}

http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/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
new file mode 100644
index 0000000..21cce9e
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSEvent.java
@@ -0,0 +1,582 @@
+/*
+ * 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.events;
+
+
+import org.apache.atlas.ocf.properties.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;
+
+import java.util.Date;
+
+/**
+ * OMRSEvent defines the common content of a message that is sent through the OMRSTopicConnector to all metadata
+ * repositories registered in the open metadata repository cohort.  It supports a category enum for the three
+ * main categories of event and provides specialized structures for processing each category of event.
+ */
+public abstract class OMRSEvent
+{
+    /*
+     * Basic event header information.
+     */
+    protected Date                         eventTimestamp       = null;
+    protected OMRSEventDirection           eventDirection       = null;
+
+    /*
+     * The category of the event.
+     */
+    protected  OMRSEventCategory           eventCategory        = OMRSEventCategory.UNKNOWN;
+
+    /*
+     * Information about the originator of the event.
+     */
+    protected OMRSEventOriginator          eventOriginator      = null;
+
+    /*
+     * Specific variables only used in error reporting
+     */
+    protected OMRSEventErrorCode     genericErrorCode           = null;
+    protected String                 errorMessage               = null;
+    protected String                 targetMetadataCollectionId = null;
+    protected Connection             targetRemoteConnection     = null;
+    protected TypeDefSummary         targetTypeDefSummary       = null;
+    protected AttributeTypeDef       targetAttributeTypeDef     = null;
+    protected String                 targetInstanceGUID         = null;
+    protected InstanceProvenanceType otherOrigin                = null;
+    protected String                 otherMetadataCollectionId  = null;
+    protected TypeDefSummary         otherTypeDefSummary        = null;
+    protected TypeDef                otherTypeDef               = null;
+    protected AttributeTypeDef       otherAttributeTypeDef      = null;
+    protected String                 otherInstanceGUID          = null;
+
+    private static final Logger log = LoggerFactory.getLogger(OMRSEvent.class);
+
+
+    /**
+     * Inbound event constructor that takes the object created by the Jackson JSON mapper and unpacks the
+     * properties into the internal OMRSEvent object.
+     *
+     * @param inboundEvent - incoming Event.
+     */
+    public OMRSEvent(OMRSEventV1 inboundEvent)
+    {
+        this.eventDirection = OMRSEventDirection.INBOUND;
+
+        if (inboundEvent != null)
+        {
+            this.eventTimestamp = inboundEvent.getTimestamp();
+            this.eventOriginator = inboundEvent.getOriginator();
+            this.eventCategory = inboundEvent.getEventCategory();
+
+            OMRSEventV1ErrorSection errorSection = inboundEvent.getErrorSection();
+
+            if (errorSection != null)
+            {
+                genericErrorCode = errorSection.getErrorCode();
+                errorMessage = errorSection.getErrorMessage();
+                targetMetadataCollectionId = errorSection.getTargetMetadataCollectionId();
+                targetRemoteConnection = errorSection.getTargetRemoteConnection();
+                targetTypeDefSummary = errorSection.getTargetTypeDefSummary();
+                targetAttributeTypeDef = errorSection.getTargetAttributeTypeDef();
+                targetInstanceGUID = errorSection.getTargetInstanceGUID();
+                otherOrigin = errorSection.getOtherOrigin();
+                otherMetadataCollectionId = errorSection.getOtherMetadataCollectionId();
+                otherTypeDefSummary = errorSection.getOtherTypeDefSummary();
+                otherTypeDef = errorSection.getOtherTypeDef();
+                otherAttributeTypeDef = errorSection.getOtherAttributeTypeDef();
+                otherInstanceGUID = errorSection.getOtherInstanceGUID();
+            }
+        }
+    }
+
+
+    /**
+     * Outbound event constructor used when there is no error.
+     *
+     * @param eventCategory - category of event.
+     */
+    public OMRSEvent(OMRSEventCategory    eventCategory)
+    {
+        this.eventDirection = OMRSEventDirection.OUTBOUND;
+        this.eventTimestamp = new Date();
+        this.eventCategory = eventCategory;
+    }
+
+
+    /**
+     * Outbound event constructor used for registry error events.
+     *
+     * @param eventCategory - category of event.
+     * @param genericErrorCode - code for the error
+     * @param errorMessage - detailed error message for remote audit log
+     * @param targetMetadataCollectionId - identifier of the metadata collection in error.
+     * @param targetRemoteConnection - connection used to create the connector to access metadata in the
+     *                               remote repository.
+     */
+    public OMRSEvent(OMRSEventCategory  eventCategory,
+                     OMRSEventErrorCode genericErrorCode,
+                     String             errorMessage,
+                     String             targetMetadataCollectionId,
+                     Connection         targetRemoteConnection)
+    {
+        this.eventDirection = OMRSEventDirection.OUTBOUND;
+        this.eventTimestamp = new Date();
+        this.eventCategory = eventCategory;
+
+        this.genericErrorCode = genericErrorCode;
+        this.errorMessage = errorMessage;
+        this.targetMetadataCollectionId = targetMetadataCollectionId;
+        this.targetRemoteConnection = targetRemoteConnection;
+    }
+
+
+    /**
+     * Outbound constructor used for TypeDef conflict events.
+     *
+     * @param eventCategory - category of event.
+     * @param genericErrorCode - code for the error
+     * @param errorMessage - detailed error message for remote audit log
+     * @param targetMetadataCollectionId - identifier of the metadata collection required to change TypeDef.
+     * @param targetTypeDefSummary - details of TypeDef to change.
+     * @param otherTypeDefSummary - description of conflicting TypeDef that will not change.
+     */
+    public OMRSEvent(OMRSEventCategory  eventCategory,
+                     OMRSEventErrorCode genericErrorCode,
+                     String             errorMessage,
+                     String             targetMetadataCollectionId,
+                     TypeDefSummary     targetTypeDefSummary,
+                     TypeDefSummary     otherTypeDefSummary)
+    {
+        this.eventDirection = OMRSEventDirection.OUTBOUND;
+        this.eventTimestamp = new Date();
+        this.eventCategory = eventCategory;
+
+        this.genericErrorCode = genericErrorCode;
+        this.errorMessage = errorMessage;
+        this.targetMetadataCollectionId = targetMetadataCollectionId;
+        this.targetTypeDefSummary = targetTypeDefSummary;
+        this.otherTypeDefSummary = otherTypeDefSummary;
+    }
+
+
+    /**
+     * Outbound constructor used for AttributeTypeDef conflict events.
+     *
+     * @param eventCategory - category of event.
+     * @param genericErrorCode - code for the error
+     * @param errorMessage - detailed error message for remote audit log
+     * @param targetMetadataCollectionId - identifier of the metadata collection required to change TypeDef.
+     * @param targetAttributeTypeDef - details of AttrbuteTypeDef to change.
+     * @param otherAttributeTypeDef - description of conflicting AttributeTypeDef that will not change.
+     */
+    public OMRSEvent(OMRSEventCategory  eventCategory,
+                     OMRSEventErrorCode genericErrorCode,
+                     String             errorMessage,
+                     String             targetMetadataCollectionId,
+                     AttributeTypeDef   targetAttributeTypeDef,
+                     AttributeTypeDef   otherAttributeTypeDef)
+    {
+        this.eventDirection = OMRSEventDirection.OUTBOUND;
+        this.eventTimestamp = new Date();
+        this.eventCategory = eventCategory;
+
+        this.genericErrorCode = genericErrorCode;
+        this.errorMessage = errorMessage;
+        this.targetMetadataCollectionId = targetMetadataCollectionId;
+        this.targetAttributeTypeDef = targetAttributeTypeDef;
+        this.otherAttributeTypeDef = otherAttributeTypeDef;
+    }
+
+
+    /**
+     * Outbound event constructor for a TypeDef patch mismatch warning.
+     *
+     * @param eventCategory - category of event.
+     * @param genericErrorCode - code for the error.
+     * @param errorMessage - detailed error message for remote audit log
+     * @param targetMetadataCollectionId - identifier of the remote metadata collection with mismatched TypeDef.
+     * @param targetTypeDefSummary - description of TypeDef.
+     * @param otherTypeDef - details of local TypeDef
+     */
+    public OMRSEvent(OMRSEventCategory  eventCategory,
+                     OMRSEventErrorCode genericErrorCode,
+                     String             errorMessage,
+                     String             targetMetadataCollectionId,
+                     TypeDefSummary     targetTypeDefSummary,
+                     TypeDef            otherTypeDef)
+    {
+        this.eventDirection = OMRSEventDirection.OUTBOUND;
+        this.eventTimestamp = new Date();
+        this.eventCategory = eventCategory;
+
+        this.genericErrorCode = genericErrorCode;
+        this.errorMessage = errorMessage;
+        this.targetMetadataCollectionId = targetMetadataCollectionId;
+        this.targetTypeDefSummary = targetTypeDefSummary;
+        this.otherTypeDef = otherTypeDef;
+    }
+
+    /**
+     * Outbound constructor used for metadata instance conflict events.
+     *
+     * @param eventCategory - category of event.
+     * @param genericErrorCode - code for the error
+     * @param errorMessage - detailed error message for remote audit log
+     * @param targetMetadataCollectionId - metadata collection id of other repository with the conflicting instance
+     * @param targetTypeDefSummary - description of the target instance's TypeDef
+     * @param targetInstanceGUID - unique identifier for the source instance
+     * @param otherOrigin - origin of the other (older) metadata instance
+     * @param otherMetadataCollectionId - metadata collection of the other (older) metadata instance
+     * @param otherTypeDefSummary - details of the other (older) instance's TypeDef
+     * @param otherInstanceGUID - unique identifier for the other (older) instance
+     */
+    public OMRSEvent(OMRSEventCategory      eventCategory,
+                     OMRSEventErrorCode     genericErrorCode,
+                     String                 errorMessage,
+                     String                 targetMetadataCollectionId,
+                     TypeDefSummary         targetTypeDefSummary,
+                     String                 targetInstanceGUID,
+                     String                 otherMetadataCollectionId,
+                     InstanceProvenanceType otherOrigin,
+                     TypeDefSummary         otherTypeDefSummary,
+                     String                 otherInstanceGUID)
+    {
+        this.eventDirection = OMRSEventDirection.OUTBOUND;
+        this.eventTimestamp = new Date();
+        this.eventCategory = eventCategory;
+
+        this.genericErrorCode = genericErrorCode;
+        this.errorMessage = errorMessage;
+        this.targetMetadataCollectionId = targetMetadataCollectionId;
+        this.targetTypeDefSummary = targetTypeDefSummary;
+        this.targetInstanceGUID = targetInstanceGUID;
+        this.otherMetadataCollectionId = otherMetadataCollectionId;
+        this.otherOrigin = otherOrigin;
+        this.otherTypeDefSummary = otherTypeDefSummary;
+        this.otherInstanceGUID = otherInstanceGUID;
+    }
+
+    /**
+     * Outbound constructor used for metadata instance type conflict events.
+     *
+     * @param eventCategory - category of event.
+     * @param genericErrorCode - code for the error
+     * @param errorMessage - detailed error message for remote audit log
+     * @param targetMetadataCollectionId - metadata collection id of other repository with the conflicting instance
+     * @param targetTypeDefSummary - details of the target instance's TypeDef
+     * @param targetInstanceGUID - unique identifier for the source instance
+     * @param otherTypeDefSummary - details of the local TypeDef
+     */
+    public OMRSEvent(OMRSEventCategory      eventCategory,
+                     OMRSEventErrorCode     genericErrorCode,
+                     String                 errorMessage,
+                     String                 targetMetadataCollectionId,
+                     TypeDefSummary         targetTypeDefSummary,
+                     String                 targetInstanceGUID,
+                     TypeDefSummary         otherTypeDefSummary)
+    {
+        this.eventDirection = OMRSEventDirection.OUTBOUND;
+        this.eventTimestamp = new Date();
+        this.eventCategory = eventCategory;
+
+        this.genericErrorCode = genericErrorCode;
+        this.errorMessage = errorMessage;
+        this.targetMetadataCollectionId = targetMetadataCollectionId;
+        this.targetTypeDefSummary = targetTypeDefSummary;
+        this.targetInstanceGUID = targetInstanceGUID;
+        this.otherTypeDefSummary = otherTypeDefSummary;
+    }
+
+
+    /**
+     * Set up details of the event originator - used by the event publisher for outbound events.
+     *
+     * @param eventOriginator  - details of the originator of the event including the id of the local
+     *                         metadata collection.
+     */
+    public void setEventOriginator(OMRSEventOriginator eventOriginator)
+    {
+        this.eventOriginator = eventOriginator;
+    }
+
+
+    /**
+     * Return whether this is an inbound or outbound event.  This is used for messages.
+     *
+     * @return OMRSEventDirection enum
+     */
+    public OMRSEventDirection getEventDirection()
+    {
+        return eventDirection;
+    }
+
+
+    /**
+     * Return the timestamp for the event.
+     *
+     * @return Date object
+     */
+    public Date getEventTimestamp()
+    {
+        return eventTimestamp;
+    }
+
+
+    /**
+     * Return the category of the event. If the event category is null then the event was unreadable
+     * in some form (or there is a logic error).
+     *
+     * @return event category enum
+     */
+    public OMRSEventCategory getEventCategory()
+    {
+        return eventCategory;
+    }
+
+
+    /**
+     * Return details of the originator of the event including the id of their metadata collection.
+     * If the originator is null then the event was unreadable in some form (or there is a logic error).
+     *
+     * @return event originator object
+     */
+    public OMRSEventOriginator getEventOriginator()
+    {
+        return eventOriginator;
+    }
+
+
+    /**
+     * Return the error code for the event.  This is set to null if there is no error.
+     *
+     * @return error code enum or null
+     */
+    protected OMRSEventErrorCode getGenericErrorCode()
+    {
+        return genericErrorCode;
+    }
+
+
+    /**
+     * Return any error message for the event.  This is null if there is no error.  If there is an error, this
+     * error message is suitable for the local OMRS audit log.
+     *
+     * @return String errorMessage
+     */
+    public String getErrorMessage()
+    {
+        return errorMessage;
+    }
+
+
+    /**
+     * This is the identifier of the metadata collection that needs to take action.
+     * It is null if there is no error condition.
+     *
+     * @return String metadata collection id
+     */
+    public String getTargetMetadataCollectionId()
+    {
+        return targetMetadataCollectionId;
+    }
+
+
+    /**
+     * This is the target's connection that is causing errors in the originator's server.
+     *
+     * @return OCF connection
+     */
+    public Connection getTargetRemoteConnection()
+    {
+        return targetRemoteConnection;
+    }
+
+
+    /**
+     * Return the target's TypeDef summary.
+     *
+     * @return TypeDefSummary containing identifiers, category and version
+     */
+    public TypeDefSummary getTargetTypeDefSummary()
+    {
+        return targetTypeDefSummary;
+    }
+
+
+    /**
+     * Return the target AttributeTypeDef.
+     *
+     * @return AttributeTypeDef object
+     */
+    public AttributeTypeDef getTargetAttributeTypeDef()
+    {
+        return targetAttributeTypeDef;
+    }
+
+
+    /**
+     * Return the target's instance's unique identifier.
+     *
+     * @return String guid
+     */
+    public String getTargetInstanceGUID()
+    {
+        return targetInstanceGUID;
+    }
+
+
+    /**
+     * Return the provenance (origin) information for the other instance.
+     *
+     * @return InstanceProvenanceType enum
+     */
+    public InstanceProvenanceType getOtherOrigin()
+    {
+        return otherOrigin;
+    }
+
+
+    /**
+     * Return the unique identifier for the metadata collection containing the other instance.
+     *
+     * @return String guid
+     */
+    public String getOtherMetadataCollectionId()
+    {
+        return otherMetadataCollectionId;
+    }
+
+
+    /**
+     * Return the version of the TypeDef from the other repository.
+     *
+     * @return TypeDefSummary containing identifiers, category and version
+     */
+    public TypeDefSummary getOtherTypeDefSummary()
+    {
+        return otherTypeDefSummary;
+    }
+
+
+    /**
+     * Return the TypeDef from the other repository.
+     *
+     * @return TypeDef object
+     */
+    public TypeDef getOtherTypeDef()
+    {
+        return otherTypeDef;
+    }
+
+
+    /**
+     * Return the AttributeTypeDef from the other repository.
+     *
+     * @return AttributeTypeDef object
+     */
+    public AttributeTypeDef getOtherAttributeTypeDef()
+    {
+        return otherAttributeTypeDef;
+    }
+
+    /**
+     * Return the unique identifier for the other instance.
+     *
+     * @return String guid
+     */
+    public String getOtherInstanceGUID()
+    {
+        return otherInstanceGUID;
+    }
+
+
+    /**
+     * Returns an OMRSEvent populated with details about a generic event.  Specific subtypes override this method
+     * to create messages with specific subsections.
+     *
+     * @return OMRSEvent (Version 1) object
+     */
+    public OMRSEventV1  getOMRSEventV1()
+    {
+        OMRSEventV1     omrsEvent = new OMRSEventV1();
+
+        omrsEvent.setTimestamp(this.eventTimestamp);
+        omrsEvent.setOriginator(this.eventOriginator);
+        omrsEvent.setEventCategory(this.eventCategory);
+
+        if (this.genericErrorCode != null)
+        {
+            OMRSEventV1ErrorSection errorSection = new OMRSEventV1ErrorSection();
+
+            errorSection.setErrorCode(this.genericErrorCode);
+            errorSection.setErrorMessage(this.errorMessage);
+            errorSection.setTargetMetadataCollectionId(this.targetMetadataCollectionId);
+            errorSection.setTargetRemoteConnection(this.targetRemoteConnection);
+            errorSection.setTargetTypeDefSummary(this.targetTypeDefSummary);
+            errorSection.setTargetAttributeTypeDef(this.targetAttributeTypeDef);
+            errorSection.setTargetInstanceGUID(this.targetInstanceGUID);
+            errorSection.setOtherMetadataCollectionId(this.otherMetadataCollectionId);
+            errorSection.setOtherOrigin(this.otherOrigin);
+            errorSection.setOtherTypeDefSummary(this.otherTypeDefSummary);
+            errorSection.setOtherTypeDef(this.otherTypeDef);
+            errorSection.setOtherAttributeTypeDef(this.otherAttributeTypeDef);
+            errorSection.setOtherInstanceGUID(this.otherInstanceGUID);
+
+            omrsEvent.setErrorSection(errorSection);
+        }
+
+        return omrsEvent;
+    }
+
+
+    /**
+     * Standard toString method.
+     *
+     * @return JSON style description of variables.
+     */
+    @Override
+    public String toString()
+    {
+        return "OMRSEvent{" +
+                "eventTimestamp=" + eventTimestamp +
+                ", eventDirection=" + eventDirection +
+                ", eventCategory=" + eventCategory +
+                ", eventOriginator=" + eventOriginator +
+                ", genericErrorCode=" + genericErrorCode +
+                ", errorMessage='" + errorMessage + '\'' +
+                ", targetMetadataCollectionId='" + targetMetadataCollectionId + '\'' +
+                ", targetRemoteConnection=" + targetRemoteConnection +
+                ", targetTypeDefSummary=" + targetTypeDefSummary +
+                ", targetAttributeTypeDef=" + targetAttributeTypeDef +
+                ", targetInstanceGUID='" + targetInstanceGUID + '\'' +
+                ", otherOrigin=" + otherOrigin +
+                ", otherMetadataCollectionId='" + otherMetadataCollectionId + '\'' +
+                ", otherTypeDefSummary=" + otherTypeDefSummary +
+                ", otherTypeDef=" + otherTypeDef +
+                ", otherAttributeTypeDef=" + otherAttributeTypeDef +
+                ", otherInstanceGUID='" + otherInstanceGUID + '\'' +
+                '}';
+    }
+}

http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSEventCategory.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSEventCategory.java b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSEventCategory.java
new file mode 100644
index 0000000..a087bfc
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSEventCategory.java
@@ -0,0 +1,101 @@
+/*
+ * 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.events;
+
+
+/**
+ * OMRSEventCategory defines the different categories of events that pass through the OMRS Topic.
+ * <ul>
+ *     <li>
+ *         UNKNOWN - this is either an uninitialized event, or the incoming event is not supported by the
+ *         local server.
+ *     </li>
+ *     <li>
+ *         REGISTRY - this is an event used by the cohort registries to manage the membership
+ *         of the cohort.
+ *     </li>
+ *     <li>
+ *         TYPEDEF - this is an event used by the metadata repository connectors to synchronize the metadata types
+ *         (stored in TypeDefs) across the metadata repository cohort.
+ *     </li>
+ * </ul>
+ */
+public enum OMRSEventCategory
+{
+    UNKNOWN (0, "Unknown Event",  "Unknown event category"),
+    REGISTRY(1, "Registry Event", "Event used to manage the membership of the metadata repository cohort"),
+    TYPEDEF (2, "TypeDef Event",  "Event used to manage the synchronization of TypeDefs within the metadata repository cohort"),
+    INSTANCE(3, "Instance Event", "Event used to manage the replication of metadata instances within the metadata repository cohort"),
+    GENERIC (99, "Generic Event", "Event used for sending generic messages - typically error messages.");
+
+
+    private int    categoryCode;
+    private String categoryName;
+    private String categoryDescription;
+
+
+    /**
+     * Default constructor.
+     *
+     * @param categoryCode - int category code number
+     * @param categoryName - String category name
+     * @param categoryDescription - String category description
+     */
+    OMRSEventCategory(int      categoryCode,
+                      String   categoryName,
+                      String   categoryDescription)
+    {
+        this.categoryCode = categoryCode;
+        this.categoryName = categoryName;
+        this.categoryDescription = categoryDescription;
+    }
+
+
+    /**
+     * Return the code number for the event category.
+     *
+     * @return int code number
+     */
+    public int getEventCategoryCode()
+    {
+        return categoryCode;
+    }
+
+
+    /**
+     * Return the name of the event category.
+     *
+     * @return String name
+     */
+    public String getEventCategoryName()
+    {
+        return categoryName;
+    }
+
+
+    /**
+     * Return the default description of the event category.  This description is in English and is a default
+     * value for the situation when the natural language resource bundle for Event Category is not available.
+     *
+     * @return String default description
+     */
+    public String getEventCategoryDescription()
+    {
+        return categoryDescription;
+    }
+}

http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSEventDirection.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSEventDirection.java b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSEventDirection.java
new file mode 100644
index 0000000..6ec049e
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSEventDirection.java
@@ -0,0 +1,84 @@
+/*
+ * 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.events;
+
+
+/**
+ * OMRSEventDirection defines the origin of an OMRSEvent.  It is used primarily for logging and debug.
+ */
+public enum OMRSEventDirection
+{
+    UNKNOWN  (0, "<Unknown>     ", "Uninitialized event direction"),
+    INBOUND  (1, "Inbound Event ", "Event from a remote member of the open metadata repository cluster."),
+    OUTBOUND (2, "Outbound Event", "Event from local server to other members of the open metadata repository cluster.");
+
+
+    private  int    eventDirectionCode;
+    private  String eventDirectionName;
+    private  String eventDirectionDescription;
+
+
+    /**
+     * Default constructor - sets up the specific values for this enum instance.
+     *
+     * @param eventDirectionCode - int identifier for the enum, used for indexing arrays etc with the enum.
+     * @param eventDirectionName - String name for the enum, used for message content.
+     * @param eventDirectionDescription - String default description for the enum, used when there is not natural
+     *                             language resource bundle available.
+     */
+    OMRSEventDirection(int eventDirectionCode, String eventDirectionName, String eventDirectionDescription)
+    {
+        this.eventDirectionCode = eventDirectionCode;
+        this.eventDirectionName = eventDirectionName;
+        this.eventDirectionDescription = eventDirectionDescription;
+    }
+
+
+    /**
+     * Return the identifier for the enum, used for indexing arrays etc with the enum.
+     *
+     * @return int identifier
+     */
+    public int getEventDirectionCode()
+    {
+        return eventDirectionCode;
+    }
+
+
+    /**
+     * Return the name for the enum, used for message content.
+     *
+     * @return String name
+     */
+    public String getEventDirectionName()
+    {
+        return eventDirectionName;
+    }
+
+
+    /**
+     * Return the default description for the enum, used when there is not natural
+     * language resource bundle available.
+     *
+     * @return String default description
+     */
+    public String getEventDirectionDescription()
+    {
+        return eventDirectionDescription;
+    }
+}

http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSEventErrorCode.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSEventErrorCode.java b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSEventErrorCode.java
new file mode 100644
index 0000000..2383f3b
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSEventErrorCode.java
@@ -0,0 +1,39 @@
+/*
+ * 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.events;
+
+
+/**
+ * OMRSEventErrorCode is a merging of the OMRSRegistryEventErrorCode, OMRSTypeDefEventErrorCode and
+ * OMRSInstanceEventErrorCode that is used in OMRSEvent.  Detailed description of the values can be found
+ * in the source enums.
+ */
+public enum OMRSEventErrorCode
+{
+    CONFLICTING_COLLECTION_ID,
+    CONFLICTING_TYPEDEFS,
+    CONFLICTING_ATTRIBUTE_TYPEDEFS,
+    CONFLICTING_INSTANCES,
+    CONFLICTING_TYPE,
+    BAD_REMOTE_CONNECTION,
+    TYPEDEF_PATCH_MISMATCH,
+    INVALID_EVENT_FORMAT,
+    INVALID_REGISTRY_EVENT,
+    INVALID_TYPEDEF_EVENT,
+    INVALID_INSTANCE_EVENT
+}

http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSEventOriginator.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSEventOriginator.java b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSEventOriginator.java
new file mode 100644
index 0000000..a4c8193
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSEventOriginator.java
@@ -0,0 +1,171 @@
+/*
+ * 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.events;
+
+
+/**
+ * OMRSEventOriginator is part of an OMRSEvent's header.  It defines the properties of the server/repository
+ * that originated the event.  These properties are as follows:
+ * <ul>
+ *     <li>
+ *         metadataCollectionId - the unique identifier of the metadata collection in the
+ *         originating server. This is a mandatory property.
+ *     </li>
+ *     <li>
+ *         ServerName - this is a display name for the server that is used in events, messages and UIs to
+ *         make it easier for people to understand the origin of metadata.  It is optional.
+ *     </li>
+ *     <li>
+ *         ServerType - this is a descriptive string describing the type of the server.  This might be the
+ *         name of the product, or similar identifier. This is an optional property.
+ *     </li>
+ *     <li>
+ *         OrganizationName - this is a descriptive name for the organization that runs/owns the server.  For
+ *         an enterprise, it may be the name of a department, geography or division.  If the cluster covers a group
+ *         of business partners then it may be their respective company names.  This is an optional field.
+ *     </li>
+ *     <li>
+ *         ProtocolVersion - this is an enumeration that identifies which versionName of the OMRS event structure
+ *         should be used.  In general it should be set to the highest level that all servers in the cohort
+ *         can support.
+ *     </li>
+ * </ul>
+ */
+public class OMRSEventOriginator
+{
+    private String                   metadataCollectionId = null;
+    private String                   serverName           = null;
+    private String                   serverType           = null;
+    private String                   organizationName     = null;
+
+    /**
+     * Default constructor used by parsing engines and other consumers.
+     */
+    public OMRSEventOriginator()
+    {
+    }
+
+
+    /**
+     * Returns the unique identifier (guid) of the originating repository's metadata collection.
+     *
+     * @return String guid
+     */
+    public String getMetadataCollectionId()
+    {
+        return metadataCollectionId;
+    }
+
+
+    /**
+     * Sets up the unique identifier (guid) of the originating repository.
+     *
+     * @param metadataCollectionId - String guid
+     */
+    public void setMetadataCollectionId(String metadataCollectionId)
+    {
+        this.metadataCollectionId = metadataCollectionId;
+    }
+
+
+    /**
+     * Return the display name for the server that is used in events, messages and UIs to
+     * make it easier for people to understand the origin of metadata.
+     *
+     * @return String server name
+     */
+    public String getServerName()
+    {
+        return serverName;
+    }
+
+
+    /**
+     * Set up the display name for the server that is used in events, messages and UIs to
+     * make it easier for people to understand the origin of metadata.
+     *
+     * @param serverName - String server name
+     */
+    public void setServerName(String serverName)
+    {
+        this.serverName = serverName;
+    }
+
+
+    /**
+     * Return the descriptive string describing the type of the server.  This might be the
+     * name of the product, or similar identifier.
+     *
+     * @return String server type
+     */
+    public String getServerType()
+    {
+        return serverType;
+    }
+
+
+    /**
+     * 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.serverType = serverType;
+    }
+
+
+    /**
+     * Return the name of the organization that runs/owns the server.
+     *
+     * @return String organization name
+     */
+    public String getOrganizationName()
+    {
+        return organizationName;
+    }
+
+
+    /**
+     * Set up the name of the organization that runs/owns the server.
+     *
+     * @param organizationName - String organization name
+     */
+    public void setOrganizationName(String organizationName)
+    {
+        this.organizationName = organizationName;
+    }
+
+
+    /**
+     * Standard toString method.
+     *
+     * @return JSON style description of variables.
+     */
+    @Override
+    public String toString()
+    {
+        return "OMRSEventOriginator{" +
+                "metadataCollectionId='" + metadataCollectionId + '\'' +
+                ", serverName='" + serverName + '\'' +
+                ", serverType='" + serverType + '\'' +
+                ", organizationName='" + organizationName + '\'' +
+                '}';
+    }
+}

http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSInstanceEvent.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSInstanceEvent.java b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSInstanceEvent.java
new file mode 100644
index 0000000..8ed3e61
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSInstanceEvent.java
@@ -0,0 +1,477 @@
+/*
+ * 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.events;
+
+
+import org.apache.atlas.omrs.eventmanagement.events.v1.OMRSEventV1;
+import org.apache.atlas.omrs.eventmanagement.events.v1.OMRSEventV1InstanceSection;
+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.Relationship;
+
+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;
+
+
+public class OMRSInstanceEvent extends OMRSEvent
+{
+    /*
+     * The type of the registry event that defines how the rest of the values should be interpreted.
+     */
+    private  OMRSInstanceEventType       instanceEventType = OMRSInstanceEventType.UNKNOWN_INSTANCE_EVENT;
+
+    /*
+     * Instance specific properties for typical instance events
+     */
+    private String       typeDefGUID    = null;
+    private String       typeDefName    = null;
+    private String       instanceGUID   = null;
+    private EntityDetail entity         = null;
+    private Relationship relationship   = null;
+
+    /*
+     * Home repository Id for refresh requests.
+     */
+    private String homeMetadataCollectionId = null;
+
+    /*
+     * Instance specific properties for events related to correcting conflicts in the open metadata repository
+     * cohort.
+     */
+    private String         originalHomeMetadataCollectionId = null;
+    private TypeDefSummary originalTypeDefSummary           = null;
+    private String         originalInstanceGUID             = null;
+
+    /*
+     * Specific variables only used in error reporting.  It defines the subset of error codes from OMRSEvent
+     * that are specific to instance events.
+     */
+    private  OMRSInstanceEventErrorCode  errorCode  = OMRSInstanceEventErrorCode.NOT_IN_USE;
+
+
+    private static final Logger log = LoggerFactory.getLogger(OMRSInstanceEvent.class);
+
+    /**
+     * Inbound event constructor that takes the object created by the Jackson JSON mapper and unpacks the
+     * properties into the instance event.
+     *
+     * @param inboundEvent - incoming event to parse.
+     */
+    public OMRSInstanceEvent(OMRSEventV1 inboundEvent)
+    {
+        super(inboundEvent);
+
+        OMRSEventV1InstanceSection instanceSection = inboundEvent.getInstanceEventSection();
+
+        if (instanceSection != null)
+        {
+            this.instanceEventType = instanceSection.getEventType();
+
+            this.typeDefGUID = instanceSection.getTypeDefGUID();
+            this.typeDefName = instanceSection.getTypeDefName();
+            this.instanceGUID = instanceSection.getInstanceGUID();
+            this.entity = instanceSection.getEntity();
+            this.relationship = instanceSection.getRelationship();
+            this.homeMetadataCollectionId = instanceSection.getHomeMetadataCollectionId();
+
+            this.originalHomeMetadataCollectionId = instanceSection.getOriginalHomeMetadataCollectionId();
+            this.originalTypeDefSummary = instanceSection.getOriginalTypeDefSummary();
+            this.originalInstanceGUID = instanceSection.getOriginalInstanceGUID();
+        }
+
+        if (super.genericErrorCode != null)
+        {
+            switch(genericErrorCode)
+            {
+                case CONFLICTING_INSTANCES:
+                    errorCode = OMRSInstanceEventErrorCode.CONFLICTING_INSTANCES;
+                    break;
+
+                case CONFLICTING_TYPE:
+                    errorCode = OMRSInstanceEventErrorCode.CONFLICTING_TYPE;
+                    break;
+
+                default:
+                    errorCode = OMRSInstanceEventErrorCode.UNKNOWN_ERROR_CODE;
+                    break;
+            }
+        }
+    }
+
+
+    /**
+     * Constructor for instance events related to a change to an entity.
+     *
+     * @param instanceEventType - type of event
+     * @param entity - entity that changed
+     */
+    public OMRSInstanceEvent(OMRSInstanceEventType instanceEventType, EntityDetail entity)
+    {
+        super(OMRSEventCategory.INSTANCE);
+
+        this.instanceEventType = instanceEventType;
+        this.entity = entity;
+    }
+
+
+    /**
+     * Constructor for instance events related to a change to a relationship.
+     *
+     * @param instanceEventType - type of event
+     * @param relationship - relationship that changed
+     */
+    public OMRSInstanceEvent(OMRSInstanceEventType instanceEventType, Relationship relationship)
+    {
+        super(OMRSEventCategory.INSTANCE);
+
+        this.instanceEventType = instanceEventType;
+        this.relationship = relationship;
+    }
+
+
+    /**
+     * Constructor for instance events related to a delete or purge of an instance - or a request to refresh
+     * an instance.
+     *
+     * @param instanceEventType - type of 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
+     */
+    public OMRSInstanceEvent(OMRSInstanceEventType instanceEventType,
+                             String                typeDefGUID,
+                             String                typeDefName,
+                             String                instanceGUID)
+    {
+        super(OMRSEventCategory.INSTANCE);
+
+        this.instanceEventType = instanceEventType;
+        this.typeDefGUID = typeDefGUID;
+        this.typeDefName = typeDefName;
+        this.instanceGUID = instanceGUID;
+    }
+
+
+    /**
+     * Constructor for instance conflict events.
+     *
+     * @param errorCode - error code
+     * @param errorMessage - description of the error
+     * @param targetMetadataCollectionId - metadata collection id of other repository with the conflicting instance
+     * @param targetTypeDefSummary - details of the target instance's TypeDef
+     * @param targetInstanceGUID - unique identifier for the source instance
+     * @param otherMetadataCollectionId - local metadata collection id
+     * @param otherOrigin - provenance information of the local instance
+     * @param otherTypeDefSummary - TypeDef details of the local instance
+     * @param otherInstanceGUID - GUID of the local instance
+     */
+    public OMRSInstanceEvent(OMRSInstanceEventErrorCode errorCode,
+                             String                     errorMessage,
+                             String                     targetMetadataCollectionId,
+                             TypeDefSummary             targetTypeDefSummary,
+                             String                     targetInstanceGUID,
+                             String                     otherMetadataCollectionId,
+                             InstanceProvenanceType     otherOrigin,
+                             TypeDefSummary             otherTypeDefSummary,
+                             String                     otherInstanceGUID)
+    {
+        super(OMRSEventCategory.INSTANCE,
+              errorCode.getErrorCodeEncoding(),
+              errorMessage,
+              targetMetadataCollectionId,
+              targetTypeDefSummary,
+              targetInstanceGUID,
+              otherMetadataCollectionId,
+              otherOrigin,
+              otherTypeDefSummary,
+              otherInstanceGUID);
+
+        this.errorCode = errorCode;
+    }
+
+
+    /**
+     * Instance type conflict event.
+     *
+     * @param errorCode - error code
+     * @param errorMessage - description of the error
+     * @param targetMetadataCollectionId - metadata collection id of other repository with the conflicting instance
+     * @param targetTypeDefSummary - details of the target instance's TypeDef
+     * @param targetInstanceGUID - unique identifier for the source instance
+     *
+     */
+    public OMRSInstanceEvent(OMRSInstanceEventErrorCode errorCode,
+                             String                     errorMessage,
+                             String                     targetMetadataCollectionId,
+                             TypeDefSummary             targetTypeDefSummary,
+                             String                     targetInstanceGUID,
+                             TypeDefSummary             otherTypeDefSummary)
+    {
+        super(OMRSEventCategory.INSTANCE,
+              errorCode.getErrorCodeEncoding(),
+              errorMessage,
+              targetMetadataCollectionId,
+              targetTypeDefSummary,
+              targetInstanceGUID,
+              otherTypeDefSummary);
+
+        this.errorCode = errorCode;
+    }
+
+    /**
+     * Set up the home metadata collection Id - used for when a repository is requesting a refresh of an instance's
+     * details.
+     *
+     * @param homeMetadataCollectionId - unique id of the metadata collection where this instance comes from.
+     */
+    public void setHomeMetadataCollectionId(String homeMetadataCollectionId)
+    {
+        this.homeMetadataCollectionId = homeMetadataCollectionId;
+    }
+
+
+    /**
+     * Set up the unique id of the metadata collection that was the original home of a metadata instance that
+     * has just been rehomed.
+     *
+     * @param originalHomeMetadataCollectionId unique id of original metadata collection
+     */
+    public void setOriginalHomeMetadataCollectionId(String originalHomeMetadataCollectionId)
+    {
+        this.originalHomeMetadataCollectionId = originalHomeMetadataCollectionId;
+    }
+
+
+    /**
+     * Set up the details of the original TypeDef of a metadata instance that has just been reTyped.
+     *
+     * @param originalTypeDefSummary - details of original TypeDef
+     */
+    public void setOriginalTypeDefSummary(TypeDefSummary originalTypeDefSummary)
+    {
+        this.originalTypeDefSummary = originalTypeDefSummary;
+    }
+
+
+    /**
+     * Set up the original unique id (guid) of an instance that has just been re-identified (ie it has
+     * had a new guid assigned.
+     *
+     * @param originalInstanceGUID - original guid of an instance
+     */
+    public void setOriginalInstanceGUID(String originalInstanceGUID)
+    {
+        this.originalInstanceGUID = originalInstanceGUID;
+    }
+
+
+    /**
+     * Return the code for this event's type.
+     *
+     * @return OMRSInstanceEventType enum
+     */
+    public OMRSInstanceEventType getInstanceEventType()
+    {
+        return instanceEventType;
+    }
+
+
+    /**
+     * Return the unique identifier for the instance's TypeDef.
+     *
+     * @return String identifier (guid)
+     */
+    public String getTypeDefGUID()
+    {
+        return typeDefGUID;
+    }
+
+
+    /**
+     * Return the unique name for the instance's TypeDef.
+     *
+     * @return String name
+     */
+    public String getTypeDefName()
+    {
+        return typeDefName;
+    }
+
+
+    /**
+     * Return the unique identifier for the instance itself.
+     *
+     * @return String identifier (guid)
+     */
+    public String getInstanceGUID()
+    {
+        return instanceGUID;
+    }
+
+
+    /**
+     * Return the entity instance (if applicable) or null.
+     *
+     * @return EntityDetail object
+     */
+    public EntityDetail getEntity()
+    {
+        return entity;
+    }
+
+
+    /**
+     * Return the relationship instance (if applicable) or null.
+     *
+     * @return Relationship object
+     */
+    public Relationship getRelationship()
+    {
+        return relationship;
+    }
+
+
+    /**
+     * Return the identifier of the instance's home metadata collection.  This is used on refresh requests.
+     *
+     * @return String unique identifier (guid)
+     */
+    public String getHomeMetadataCollectionId()
+    {
+        return homeMetadataCollectionId;
+    }
+
+    /**
+     * Return the identifier of the original metadata collection for this instance.  This is used when an
+     * instance is being re-homed.
+     *
+     * @return String unique identifier (guid)
+     */
+    public String getOriginalHomeMetadataCollectionId()
+    {
+        return originalHomeMetadataCollectionId;
+    }
+
+
+    /**
+     * Return the original versionName for this instance's TypeDef.  This is used if the type for the
+     * instance has been changed to resolve a conflict or to allow a change in the TypeDef Gallery.
+     *
+     * @return details of the original TypeDef
+     */
+    public TypeDefSummary getOriginalTypeDefSummary()
+    {
+        return originalTypeDefSummary;
+    }
+
+
+    /**
+     * Return the original unique identifier (guid) for this instance.  This is used if the guid for the instance
+     * has been changed to resolve a conflict.
+     *
+     * @return String unique identifier (guid)
+     */
+    public String getOriginalInstanceGUID()
+    {
+        return originalInstanceGUID;
+    }
+
+
+    /**
+     * Return the error code for this instance event.  If there is no error it is set to NOT_IN_USE.
+     *
+     * @return OMRSInstanceEventErrorCode enum
+     */
+    public OMRSInstanceEventErrorCode getErrorCode()
+    {
+        return errorCode;
+    }
+
+
+    /**
+     * Returns an OMRSEvent populated with details from this InstanceEvent
+     *
+     * @return OMRSEvent (Version 1) object
+     */
+    public OMRSEventV1  getOMRSEventV1()
+    {
+        OMRSEventV1     omrsEvent = super.getOMRSEventV1();
+
+        OMRSEventV1InstanceSection instanceSection  = new OMRSEventV1InstanceSection();
+
+        instanceSection.setEventType(this.instanceEventType);
+
+        instanceSection.setTypeDefGUID(this.typeDefGUID);
+        instanceSection.setTypeDefName(this.typeDefName);
+        instanceSection.setInstanceGUID(this.instanceGUID);
+        instanceSection.setEntity(this.entity);
+        instanceSection.setRelationship(this.relationship);
+        instanceSection.setHomeMetadataCollectionId(this.homeMetadataCollectionId);
+
+        instanceSection.setOriginalHomeMetadataCollectionId(this.originalHomeMetadataCollectionId);
+        instanceSection.setOriginalTypeDefSummary(this.originalTypeDefSummary);
+        instanceSection.setOriginalInstanceGUID(this.originalInstanceGUID);
+
+        omrsEvent.setInstanceEventSection(instanceSection);
+
+        return omrsEvent;
+    }
+
+
+    /**
+     * Standard toString method.
+     *
+     * @return JSON style description of variables.
+     */
+    @Override
+    public String toString()
+    {
+        return "OMRSInstanceEvent{" +
+                "instanceEventType=" + instanceEventType +
+                ", typeDefGUID='" + typeDefGUID + '\'' +
+                ", typeDefName='" + typeDefName + '\'' +
+                ", instanceGUID='" + instanceGUID + '\'' +
+                ", entity=" + entity +
+                ", relationship=" + relationship +
+                ", homeMetadataCollectionId='" + homeMetadataCollectionId + '\'' +
+                ", originalHomeMetadataCollectionId='" + originalHomeMetadataCollectionId + '\'' +
+                ", originalTypeDefSummary=" + originalTypeDefSummary +
+                ", originalInstanceGUID='" + originalInstanceGUID + '\'' +
+                ", errorCode=" + errorCode +
+                ", eventTimestamp=" + eventTimestamp +
+                ", eventDirection=" + eventDirection +
+                ", eventCategory=" + eventCategory +
+                ", eventOriginator=" + eventOriginator +
+                ", genericErrorCode=" + genericErrorCode +
+                ", errorMessage='" + errorMessage + '\'' +
+                ", targetMetadataCollectionId='" + targetMetadataCollectionId + '\'' +
+                ", targetRemoteConnection=" + targetRemoteConnection +
+                ", targetTypeDefSummary=" + targetTypeDefSummary +
+                ", targetAttributeTypeDef=" + targetAttributeTypeDef +
+                ", targetInstanceGUID='" + targetInstanceGUID + '\'' +
+                ", otherOrigin=" + otherOrigin +
+                ", otherMetadataCollectionId='" + otherMetadataCollectionId + '\'' +
+                ", otherTypeDefSummary=" + otherTypeDefSummary +
+                ", otherTypeDef=" + otherTypeDef +
+                ", otherAttributeTypeDef=" + otherAttributeTypeDef +
+                ", otherInstanceGUID='" + otherInstanceGUID + '\'' +
+                '}';
+    }
+}

http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSInstanceEventErrorCode.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSInstanceEventErrorCode.java b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSInstanceEventErrorCode.java
new file mode 100644
index 0000000..7691839
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSInstanceEventErrorCode.java
@@ -0,0 +1,118 @@
+/*
+ * 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.events;
+
+import org.apache.atlas.omrs.eventmanagement.events.OMRSEventErrorCode;
+
+/**
+ * OMRSInstanceEventErrorCode defines the list of error codes that are used to record errors in the metadata
+ * instance replication process that is used by the repository connectors within the open metadata repository cluster.
+ * <ul>
+ *     <li>
+ *         NOT_IN_USE - There has been no error detected and so the error code is not in use.
+ *     </li>
+ * </ul>
+ */
+public enum OMRSInstanceEventErrorCode
+{
+    NOT_IN_USE                (0, "No Error",
+                                  "There has been no error detected and so the error code is not in use.",
+                               null),
+    CONFLICTING_INSTANCES     (1, "Conflicting Instances",
+                               "There are two metadata instances that have the same unique identifier (guid) but" +
+                                           " have different types.",
+                               OMRSEventErrorCode.CONFLICTING_INSTANCES),
+    CONFLICTING_TYPE         (2, "Conflicting Type Version",
+                               "An instance can not be processed because there is a mismatch in the type definition (TypeDef) versionName.",
+                               OMRSEventErrorCode.CONFLICTING_TYPE),
+    UNKNOWN_ERROR_CODE        (99, "Unknown Error Code",
+                               "Unrecognized error code from incoming event.",
+                               null);
+
+
+    private int                errorCodeId;
+    private String             errorCodeName;
+    private String             errorCodeDescription;
+    private OMRSEventErrorCode errorCodeEncoding;
+
+
+    /**
+     * Default constructor sets up the values for this enum instance.
+     *
+     * @param errorCodeId - int identifier for the enum, used for indexing arrays etc with the enum.
+     * @param errorCodeName - String name for the enum, used for message content.
+     * @param errorCodeDescription - String default description for the enum, used when there is not natural
+     *                             language resource bundle available.
+     * @param errorCodeEncoding - code value to use in OMRSEvents
+     */
+    OMRSInstanceEventErrorCode(int                errorCodeId,
+                               String             errorCodeName,
+                               String             errorCodeDescription,
+                               OMRSEventErrorCode errorCodeEncoding)
+    {
+        this.errorCodeId = errorCodeId;
+        this.errorCodeName = errorCodeName;
+        this.errorCodeDescription = errorCodeDescription;
+        this.errorCodeEncoding = errorCodeEncoding;
+    }
+
+
+    /**
+     * Return the identifier for the enum, used for indexing arrays etc with the enum.
+     *
+     * @return int identifier
+     */
+    public int getErrorCodeId()
+    {
+        return errorCodeId;
+    }
+
+
+    /**
+     * Return the name for the enum, used for message content.
+     *
+     * @return String name
+     */
+    public String getErrorCodeName()
+    {
+        return errorCodeName;
+    }
+
+
+    /**
+     * Return the default description for the enum, used when there is not natural
+     * language resource bundle available.
+     *
+     * @return String default description
+     */
+    public String getErrorCodeDescription()
+    {
+        return errorCodeDescription;
+    }
+
+
+    /**
+     * Return the encoding to use in OMRSEvents.
+     *
+     * @return String OMRSEvent encoding for this errorCode
+     */
+    public OMRSEventErrorCode getErrorCodeEncoding()
+    {
+        return errorCodeEncoding;
+    }
+}
\ No newline at end of file