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:42 UTC
[26/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/archivemanager/properties/OpenMetadataArchive.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/properties/OpenMetadataArchive.java b/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/properties/OpenMetadataArchive.java
new file mode 100644
index 0000000..58c5c2a
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/properties/OpenMetadataArchive.java
@@ -0,0 +1,116 @@
+/*
+ * 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.archivemanager.properties;
+
+/**
+ * OpenMetadataArchive defines the structure of the properties inside of an open metadata archive.
+ * There are 3 sections:
+ * <ul>
+ * <li>
+ * ArchiveProperties - provides details of the source and contents of the archive.
+ * </li>
+ * <li>
+ * TypeStore - a list of new TypeDefs and patches to existing TypeDefs.
+ * </li>
+ * <li>
+ * InstanceStore - a list of new metadata instances (Entities and Relationships).
+ * </li>
+ * </ul>
+ */
+public class OpenMetadataArchive
+{
+ private OpenMetadataArchiveProperties archiveProperties = null;
+ private OpenMetadataArchiveTypeStore archiveTypeStore = null;
+ private OpenMetadataArchiveInstanceStore archiveInstanceStore = null;
+
+
+ /**
+ * Default constructor relies on the initialization of variables in their type declaration.
+ */
+ public OpenMetadataArchive()
+ {
+ }
+
+
+ /**
+ * Return details of the archive.
+ *
+ * @return OpenMetadataArchiveProperties object
+ */
+ public OpenMetadataArchiveProperties getArchiveProperties()
+ {
+ return archiveProperties;
+ }
+
+
+ /**
+ * Set the archive properties for a new archive.
+ *
+ * @param archiveProperties - the descriptive properties of the archive
+ */
+ public void setArchiveProperties(OpenMetadataArchiveProperties archiveProperties)
+ {
+ this.archiveProperties = archiveProperties;
+ }
+
+
+ /**
+ * Return the TypeStore for this archive. The TypeStore contains TypeDefs and TypeDef patches.
+ *
+ * @return OpenMetadataArchiveTypeStore object
+ */
+ public OpenMetadataArchiveTypeStore getArchiveTypeStore()
+ {
+ return archiveTypeStore;
+ }
+
+
+ /**
+ * Set up the TypeStore for this archive. The TypeStore contains TypeDefs and TypeDef patches.
+ *
+ * @param archiveTypeStore - OpenMetadataArchiveTypeStore object
+ */
+ public void setArchiveTypeStore(OpenMetadataArchiveTypeStore archiveTypeStore)
+ {
+ this.archiveTypeStore = archiveTypeStore;
+ }
+
+
+ /**
+ * Return the InstanceStore for this archive. The InstanceStore contains entity and relationship metadata
+ * instances.
+ *
+ * @return OpenMetadataArchiveInstanceStore object
+ */
+ public OpenMetadataArchiveInstanceStore getArchiveInstanceStore()
+ {
+ return archiveInstanceStore;
+ }
+
+
+ /**
+ * Set up the InstanceStore for this archive. The InstanceStore contains entity and relationship metadata
+ * instances.
+ *
+ * @param archiveInstanceStore - OpenMetadataArchiveInstanceStore object
+ */
+ public void setArchiveInstanceStore(OpenMetadataArchiveInstanceStore archiveInstanceStore)
+ {
+ this.archiveInstanceStore = archiveInstanceStore;
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/properties/OpenMetadataArchiveInstanceStore.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/properties/OpenMetadataArchiveInstanceStore.java b/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/properties/OpenMetadataArchiveInstanceStore.java
new file mode 100644
index 0000000..1d9b79b
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/properties/OpenMetadataArchiveInstanceStore.java
@@ -0,0 +1,86 @@
+/*
+ * 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.archivemanager.properties;
+
+
+import org.apache.atlas.omrs.metadatacollection.properties.instances.EntityDetail;
+import org.apache.atlas.omrs.metadatacollection.properties.instances.Relationship;
+
+import java.util.ArrayList;
+
+/**
+ * OpenMetadataArchiveInstanceStore defines the contents of the InstanceStore in an open metadata archive. It
+ * consists of a list of entities and a list of relationships.
+ */
+public class OpenMetadataArchiveInstanceStore
+{
+ private ArrayList<EntityDetail> entities = null;
+ private ArrayList<Relationship> relationships = null;
+
+
+ /**
+ * Default constructor relying on the initialization of variables in their declaration.
+ */
+ public OpenMetadataArchiveInstanceStore()
+ {
+ }
+
+
+ /**
+ * Return the list of entities defined in the open metadata archive.
+ *
+ * @return list of entities
+ */
+ public ArrayList<EntityDetail> getEntities()
+ {
+ return entities;
+ }
+
+
+ /**
+ * Set up the list of entities defined in the open metadata archive.
+ *
+ * @param entities - list of entities
+ */
+ public void setEntities(ArrayList<EntityDetail> entities)
+ {
+ this.entities = entities;
+ }
+
+
+ /**
+ * Return the list of relationships defined in this open metadata archive.
+ *
+ * @return list of relationships
+ */
+ public ArrayList<Relationship> getRelationships()
+ {
+ return relationships;
+ }
+
+
+ /**
+ * Set up the list of relationships defined in this open metadata archive.
+ *
+ * @param relationships - list of relationship objects
+ */
+ public void setRelationships(ArrayList<Relationship> relationships)
+ {
+ this.relationships = relationships;
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/properties/OpenMetadataArchiveProperties.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/properties/OpenMetadataArchiveProperties.java b/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/properties/OpenMetadataArchiveProperties.java
new file mode 100644
index 0000000..3ebb17a
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/properties/OpenMetadataArchiveProperties.java
@@ -0,0 +1,222 @@
+/*
+ * 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.archivemanager.properties;
+
+
+import java.util.ArrayList;
+import java.util.Date;
+
+/**
+ * OpenMetadataArchiveProperties defines the properties of an open metadata archive. This includes the following
+ * properties:
+ * <ul>
+ * <li>
+ * Unique identifier (GUID) of the archive.
+ * </li>
+ * <li>
+ * Archive name.
+ * </li>
+ * <li>
+ * Archive description.
+ * </li>
+ * <li>
+ * Archive Type (CONTENT_PACK or METADATA_EXPORT).
+ * </li>
+ * <li>
+ * Originator name (organization or person).
+ * </li>
+ * <li>
+ * Creation date
+ * </li>
+ * <li>
+ * GUIDs for archives that this archive depends on.
+ * </li>
+ * </ul>
+ */
+public class OpenMetadataArchiveProperties
+{
+ private String archiveGUID = null;
+ private String archiveName = null;
+ private String archiveDescription = null;
+ private OpenMetadataArchiveType archiveType = null;
+ private String originatorName = null;
+ private Date creationDate = null;
+ private ArrayList<String> dependsOnArchives = null;
+
+
+ /**
+ * Default constructor that relies on initialization of variables in their declaration.
+ */
+ public OpenMetadataArchiveProperties()
+ {
+ }
+
+
+ /**
+ * Return the unique identifier for this archive.
+ *
+ * @return String guid
+ */
+ public String getArchiveGUID()
+ {
+ return archiveGUID;
+ }
+
+
+ /**
+ * Set up the unique identifier for this open metadata archive.
+ *
+ * @param archiveGUID - String guid
+ */
+ public void setArchiveGUID(String archiveGUID)
+ {
+ this.archiveGUID = archiveGUID;
+ }
+
+
+ /**
+ * Return the descriptive name for this open metadata archive.
+ *
+ * @return String name
+ */
+ public String getArchiveName()
+ {
+ return archiveName;
+ }
+
+
+ /**
+ * Set up the descriptive name for this open metadata archive.
+ *
+ * @param archiveName - String name
+ */
+ public void setArchiveName(String archiveName)
+ {
+ this.archiveName = archiveName;
+ }
+
+
+ /**
+ * Return the description for this open metadata archive.
+ *
+ * @return String description
+ */
+ public String getArchiveDescription()
+ {
+ return archiveDescription;
+ }
+
+
+ /**
+ * Set up the description for this open metadata archive.
+ *
+ * @param archiveDescription - String description
+ */
+ public void setArchiveDescription(String archiveDescription)
+ {
+ this.archiveDescription = archiveDescription;
+ }
+
+
+ /**
+ * Return the type of this open metadata archive.
+ *
+ * @return OpenMetadataArchiveType enum
+ */
+ public OpenMetadataArchiveType getArchiveType()
+ {
+ return archiveType;
+ }
+
+
+ /**
+ * Set up the type of this open metadata archive.
+ *
+ * @param archiveType - OpenMetadataArchiveType enum
+ */
+ public void setArchiveType(OpenMetadataArchiveType archiveType)
+ {
+ this.archiveType = archiveType;
+ }
+
+
+ /**
+ * Return the name of the originator of this open metadata archive (persona or organization).
+ *
+ * @return String name
+ */
+ public String getOriginatorName()
+ {
+ return originatorName;
+ }
+
+
+ /**
+ * Set up the name of the originator of this open metadata archive (persona or organization).
+ *
+ * @param originatorName - String name
+ */
+ public void setOriginatorName(String originatorName)
+ {
+ this.originatorName = originatorName;
+ }
+
+
+ /**
+ * Return the date that this open metadata archive was created.
+ *
+ * @return Date object
+ */
+ public Date getCreationDate()
+ {
+ return creationDate;
+ }
+
+
+ /**
+ * Set up the date that this open metadata archive was created.
+ *
+ * @param creationDate - Date object
+ */
+ public void setCreationDate(Date creationDate)
+ {
+ this.creationDate = creationDate;
+ }
+
+
+ /**
+ * Return the list of GUIDs for open metadata archives that need to be loaded before this one.
+ *
+ * @return list of guids
+ */
+ public ArrayList<String> getDependsOnArchives()
+ {
+ return dependsOnArchives;
+ }
+
+
+ /**
+ * Set up the list of GUIDs for open metadata archives that need to be loaded before this one.
+ *
+ * @param dependsOnArchives - list of guids
+ */
+ public void setDependsOnArchives(ArrayList<String> dependsOnArchives)
+ {
+ this.dependsOnArchives = dependsOnArchives;
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/properties/OpenMetadataArchiveType.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/properties/OpenMetadataArchiveType.java b/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/properties/OpenMetadataArchiveType.java
new file mode 100644
index 0000000..fc764b6
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/properties/OpenMetadataArchiveType.java
@@ -0,0 +1,79 @@
+/*
+ * 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.archivemanager.properties;
+
+public enum OpenMetadataArchiveType
+{
+ CONTENT_PACK (1, "ContentPack",
+ "A collection of metadata elements that define a standard or support a specific use case."),
+ METADATA_EXPORT (2, "MetadataExport",
+ "A collection of metadata elements that have been extracted from a specific open metadata repository.");
+
+
+ private int archiveTypeCode;
+ private String archiveTypeName;
+ private String archiveTypeDescription;
+
+
+ /**
+ * Constructor fo an enum instance.
+ *
+ * @param archiveTypeCode - code number for the archive type
+ * @param archiveTypeName - name for the archive type
+ * @param archiveTypeDescription - default description ofr the archive type
+ */
+ OpenMetadataArchiveType(int archiveTypeCode, String archiveTypeName, String archiveTypeDescription)
+ {
+ this.archiveTypeCode = archiveTypeCode;
+ this.archiveTypeName = archiveTypeName;
+ this.archiveTypeDescription = archiveTypeDescription;
+ }
+
+
+ /**
+ * Return the code number for the archive type.
+ *
+ * @return int code number
+ */
+ public int getArchiveTypeCode()
+ {
+ return archiveTypeCode;
+ }
+
+
+ /**
+ * Return the printable name for the archive type.
+ *
+ * @return String archive type name
+ */
+ public String getArchiveTypeName()
+ {
+ return archiveTypeName;
+ }
+
+
+ /**
+ * Return the default description of the archive type.
+ *
+ * @return String archive description
+ */
+ public String getArchiveTypeDescription()
+ {
+ return archiveTypeDescription;
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/properties/OpenMetadataArchiveTypeStore.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/properties/OpenMetadataArchiveTypeStore.java b/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/properties/OpenMetadataArchiveTypeStore.java
new file mode 100644
index 0000000..d170ff2
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/properties/OpenMetadataArchiveTypeStore.java
@@ -0,0 +1,111 @@
+/*
+ * 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.archivemanager.properties;
+
+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.TypeDefPatch;
+
+import java.util.ArrayList;
+
+
+/**
+ * OpenMetadataArchiveTypeStore defines the contents of the TypeStore in an open metadata archive. The TypeStore
+ * contains a list of types used for attributes, a list of type definition (TypeDef) patches to update existing types
+ * and a list of TypeDefs for new types of classifications, entities and relationships.
+ */
+public class OpenMetadataArchiveTypeStore
+{
+ private ArrayList<AttributeTypeDef> attributeTypeDefs = null;
+ private ArrayList<TypeDefPatch> typeDefPatches = null;
+ private ArrayList<TypeDef> newTypeDefs = null;
+
+
+ /**
+ * Default constructor for OpenMetadataArchiveTypeStore relies on variables being initialized in their declaration.
+ */
+ public OpenMetadataArchiveTypeStore()
+ {
+ }
+
+
+ /**
+ * Return the list of attribute types used in this archive.
+ *
+ * @return list of AttributeTypeDef objects
+ */
+ public ArrayList<AttributeTypeDef> getAttributeTypeDefs()
+ {
+ return attributeTypeDefs;
+ }
+
+
+ /**
+ * Set up the list of attribute types used in this archive.
+ *
+ * @param attributeTypeDefs - list of AttributeTypeDef objects
+ */
+ public void setAttributeTypeDefs(ArrayList<AttributeTypeDef> attributeTypeDefs)
+ {
+ this.attributeTypeDefs = attributeTypeDefs;
+ }
+
+
+ /**
+ * Return the list of TypeDef patches from this archive.
+ *
+ * @return list of TypeDef objects
+ */
+ public ArrayList<TypeDefPatch> getTypeDefPatches()
+ {
+ return typeDefPatches;
+ }
+
+
+ /**
+ * Set up the list of TypeDef patches from this archive.
+ *
+ * @param typeDefPatches - list of TypeDef objects
+ */
+ public void setTypeDefPatches(ArrayList<TypeDefPatch> typeDefPatches)
+ {
+ this.typeDefPatches = typeDefPatches;
+ }
+
+
+ /**
+ * Return the list of new TypeDefs in this open metadata archive.
+ *
+ * @return list of TypeDef objects
+ */
+ public ArrayList<TypeDef> getNewTypeDefs()
+ {
+ return newTypeDefs;
+ }
+
+
+ /**
+ * Set up the list of new TypeDefs in this open metadata archive.
+ *
+ * @param newTypeDefs - list of TypeDef objects
+ */
+ public void setNewTypeDefs(ArrayList<TypeDef> newTypeDefs)
+ {
+ this.newTypeDefs = newTypeDefs;
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/store/OpenMetadataArchiveStore.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/store/OpenMetadataArchiveStore.java b/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/store/OpenMetadataArchiveStore.java
new file mode 100644
index 0000000..ac5dfd6
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/store/OpenMetadataArchiveStore.java
@@ -0,0 +1,72 @@
+/*
+ * 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.archivemanager.store;
+
+
+import org.apache.atlas.omrs.archivemanager.properties.OpenMetadataArchive;
+
+/**
+ * <p>
+ * OpenMetadataArchiveStore is the interface for a connector to an open metadata archive. The open metadata archive
+ * is a collection of type definitions (TypeDefs) and metadata instances (Entities and Relationships) that can be
+ * loaded into an open metadata repository.
+ * </p>
+ * <p>
+ * An open metadata archive has 3 sections:
+ * </p>
+ * <ul>
+ * <li>
+ * Archive properties
+ * </li>
+ * <li>
+ * Type store - ordered list of types
+ * </li>
+ * <li>
+ * Instance store - list of entities and relationships
+ * </li>
+ * </ul>
+ */
+public interface OpenMetadataArchiveStore
+{
+ /**
+ * Open the archive and retrieve archive contents (if any)
+ */
+ void openArchive();
+
+
+ /**
+ * Return the contents of the archive.
+ *
+ * @return OpenMetadataArchive object
+ */
+ OpenMetadataArchive getArchiveContents();
+
+
+ /**
+ * Set new contents into the archive. This overrides any content previously stored.
+ *
+ * @param archiveContents - OpenMetadataArchive object
+ */
+ void setArchiveContents(OpenMetadataArchive archiveContents);
+
+
+ /**
+ * Close the archive - this releases the connection and any resources held.
+ */
+ void closeArchive();
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/store/OpenMetadataArchiveStoreConnectorBase.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/store/OpenMetadataArchiveStoreConnectorBase.java b/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/store/OpenMetadataArchiveStoreConnectorBase.java
new file mode 100644
index 0000000..b0bd643
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/store/OpenMetadataArchiveStoreConnectorBase.java
@@ -0,0 +1,27 @@
+/*
+ * 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.archivemanager.store;
+
+import org.apache.atlas.ocf.ConnectorBase;
+
+/**
+ * OpenMetadataArchiveStoreConnectorBase is the base class for connectors that support the OpenMetadataArchiveStore
+ */
+public abstract class OpenMetadataArchiveStoreConnectorBase extends ConnectorBase implements OpenMetadataArchiveStore
+{
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/store/OpenMetadataArchiveStoreProviderBase.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/store/OpenMetadataArchiveStoreProviderBase.java b/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/store/OpenMetadataArchiveStoreProviderBase.java
new file mode 100644
index 0000000..463dd10
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/store/OpenMetadataArchiveStoreProviderBase.java
@@ -0,0 +1,41 @@
+/*
+ * 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.archivemanager.store;
+
+import org.apache.atlas.ocf.ConnectorProviderBase;
+
+/**
+ * The OpenMetadataArchiveProviderStoreBase provides a base class for the connector provider supporting OMRS
+ * open metadata archive stores. It extends ConnectorProviderBase which does the creation of connector instances.
+ * The subclasses of OpenMetadataArchiveStoreProviderBase must initialize ConnectorProviderBase with the Java class
+ * name of the audit log connector implementation (by calling super.setConnectorClassName(className)).
+ * Then the connector provider will work.
+ */
+public abstract class OpenMetadataArchiveStoreProviderBase extends ConnectorProviderBase
+{
+ /**
+ * Default Constructor
+ */
+ public OpenMetadataArchiveStoreProviderBase()
+ {
+ /*
+ * Nothing to do
+ */
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/auditlog/OMRSAuditCode.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/auditlog/OMRSAuditCode.java b/omrs/src/main/java/org/apache/atlas/omrs/auditlog/OMRSAuditCode.java
new file mode 100644
index 0000000..8e66f8b
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/auditlog/OMRSAuditCode.java
@@ -0,0 +1,500 @@
+/*
+ * 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.auditlog;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.text.MessageFormat;
+import java.util.Arrays;
+
+/**
+ * The OMRSAuditCode is used to define the message content for the OMRS Audit Log.
+ *
+ * The 5 fields in the enum are:
+ * <ul>
+ * <li>Log Message Id - to uniquely identify the message</li>
+ * <li>Severity - is this an event, decision, action, error or exception</li>
+ * <li>Log Message Text - includes placeholder to allow additional values to be captured</li>
+ * <li>Additional Information - further parameters and data relating to the audit message (optional)</li>
+ * <li>SystemAction - describes the result of the situation</li>
+ * <li>UserAction - describes how a user should correct the situation</li>
+ * </ul>
+ */
+public enum OMRSAuditCode
+{
+ OMRS_INITIALIZING("OMRS-AUDIT-0001",
+ OMRSAuditLogRecordSeverity.INFO,
+ "The Open Metadata Repository Services (OMRS) is initializing",
+ "The local server has started up the OMRS.",
+ "No action is required. This is part of the normal operation of the server."),
+
+ ENTERPRISE_ACCESS_INITIALIZING("OMRS-AUDIT-0002",
+ OMRSAuditLogRecordSeverity.INFO,
+ "Enterprise access through the Enterprise Repository Services is initializing",
+ "The local server has started the enterprise access support provided by the " +
+ "enterprise repository services.",
+ "No action is required. This is part of the normal operation of the server."),
+
+ LOCAL_REPOSITORY_INITIALIZING("OMRS-AUDIT-0003",
+ OMRSAuditLogRecordSeverity.INFO,
+ "The local repository is initializing with metadata collection id {0}",
+ "The local server has started to initialize the local repository.",
+ "No action is required. This is part of the normal operation of the server."),
+
+ METADATA_HIGHWAY_INITIALIZING("OMRS-AUDIT-0004",
+ OMRSAuditLogRecordSeverity.INFO,
+ "Connecting to the metadata highway",
+ "The local server has started to initialize the communication with the open metadata " +
+ "repository cohorts.",
+ "No action is required. This is part of the normal operation of the server."),
+
+ COHORT_INITIALIZING("OMRS-AUDIT-0005",
+ OMRSAuditLogRecordSeverity.INFO,
+ "Connecting to cohort {0}",
+ "The local server has started to initialize the communication with the named " +
+ "open metadata repository cohort.",
+ "No action is required. This is part of the normal operation of the server."),
+
+ COHORT_CONFIG_ERROR("OMRS-AUDIT-0006",
+ OMRSAuditLogRecordSeverity.EXCEPTION,
+ "Configuration error detected while connecting to cohort {0}",
+ "The local server has started to initialize the communication with the named " +
+ "open metadata repository cohort and a configuration error was detected.",
+ "Review the exception and resolve the issue it documents. " +
+ "Then disconnect and reconnect this server to the cohort."),
+
+ OMRS_INITIALIZED("OMRS-AUDIT-0007",
+ OMRSAuditLogRecordSeverity.INFO,
+ "The Open Metadata Repository Services (OMRS) has initialized",
+ "The local server has completed the initialization of the OMRS.",
+ "No action is required. This is part of the normal operation of the server."),
+
+ COHORT_DISCONNECTING("OMRS-AUDIT-0008",
+ OMRSAuditLogRecordSeverity.INFO,
+ "Disconnecting from cohort {0}",
+ "The local server has started to shutdown the communication with the named " +
+ "open metadata repository cohort.",
+ "No action is required. This is part of the normal operation of the server."),
+
+ COHORT_PERMANENTLY_DISCONNECTING("OMRS-AUDIT-0009",
+ OMRSAuditLogRecordSeverity.INFO,
+ "Unregistering from cohort {0}",
+ "The local server has started to unregister from all future communication with the named " +
+ "open metadata repository cohort.",
+ "No action is required. This is part of the normal operation of the server."),
+
+ OMRS_DISCONNECTING("OMRS-AUDIT-0010",
+ OMRSAuditLogRecordSeverity.INFO,
+ "The Open Metadata Repository Services (OMRS) is about to disconnect from the open metadata repositories.",
+ "The local server has completed the initialization of the OMRS.",
+ "No action is required. This is part of the normal operation of the server."),
+
+ OMRS_DISCONNECTED("OMRS-AUDIT-0011",
+ OMRSAuditLogRecordSeverity.INFO,
+ "The Open Metadata Repository Services (OMRS) has disconnected from the open metadata repositories.",
+ "The local server has completed the disconnection of the OMRS.",
+ "No action is required. This is part of the normal operation of the server."),
+
+ NO_LOCAL_REPOSITORY("OMRS-AUDIT-0012",
+ OMRSAuditLogRecordSeverity.INFO,
+ "No events will be sent to the open metadata repository cohort {0} because the local metadata collection id is null.",
+ "The local server will not send outbound events because there is no local metadata repository.",
+ "Validate that the server is configured without a local metadata repository. " +
+ "If there should be a metadata repository then, verify the server configuration is" +
+ "correct and look for errors that have occurred during server start up." +
+ "If necessary, correct the configuration and restart the server."),
+
+ NULL_TOPIC_CONNECTOR("OMRS-AUDIT-0013",
+ OMRSAuditLogRecordSeverity.EXCEPTION,
+ "Unable to send or receive events for cohort {0} because the connector to the OMRS Topic failed to initialize",
+ "The local server will not connect to the cohort.",
+ "The connection to the connector is configured in the server configuration. " +
+ "Review previous error messages to determine the precise error in the " +
+ "start up configuration. " +
+ "Correct the configuration and reconnect the server to the cohort. "),
+
+ REGISTERED_WITH_COHORT("OMRS-AUDIT-0101",
+ OMRSAuditLogRecordSeverity.INFO,
+ "Registering with open metadata repository cohort {0} using metadata collection id {1}",
+ "The local server has sent a registration event to the other members of the cohort.",
+ "No action is required. This is part of the normal operation of the server."),
+
+ RE_REGISTERED_WITH_COHORT("OMRS-AUDIT-0102",
+ OMRSAuditLogRecordSeverity.INFO,
+ "Refreshing registration information from open metadata repository cohort {0}",
+ "The local server has sent a registration refresh request to the other members of the cohort as " +
+ "part of its routine to re-connect with the open metadata repository cohort.",
+ "No action is required. This is part of the normal operation of the server."),
+
+ UNREGISTERING_FROM_COHORT("OMRS-AUDIT-0103",
+ OMRSAuditLogRecordSeverity.INFO,
+ "Unregistering with open metadata repository cohort {0} using metadata collection id {1}",
+ "The local server has sent a unregistration event to the other members of the cohort as " +
+ "part of its routine to permanently disconnect with the open metadata repository cohort.",
+ "No action is required. This is part of the normal operation of the server."),
+
+ SEND_REGISTRY_EVENT_ERROR("OMRS-AUDIT-0104",
+ OMRSAuditLogRecordSeverity.EXCEPTION,
+ "Unable to send a registry event for cohort {0} due to an error in the OMRS Topic Connector",
+ "The local server is unable to properly manage registration events for the metadata " +
+ "repository cohort. The cause of the error is recorded in the accompanying exception.",
+ "Review the exception and resolve the issue it documents. " +
+ "Then disconnect and reconnect this server to the cohort."),
+
+ REFRESHING_REGISTRATION_WITH_COHORT("OMRS-AUDIT-0105",
+ OMRSAuditLogRecordSeverity.INFO,
+ "Refreshing registration with open metadata repository cohort {0} using " +
+ "metadata collection id {1} at the request of server {2}",
+ "The local server has sent a re-registration event to the other members of the cohort in " +
+ "response to a registration refresh event from another member of the cohort.",
+ "No action is required. This is part of the normal operation of the server."),
+
+ INCOMING_CONFLICTING_LOCAL_METADATA_COLLECTION_ID("OMRS-AUDIT-0106",
+ OMRSAuditLogRecordSeverity.ACTION,
+ "Registration request for this server in cohort {0} was rejected by server {1} that " +
+ "hosts metadata collection {2} because the local metadata " +
+ "collection id {3} is not unique for this cohort",
+ "The local server will not receive metadata from the open metadata repository " +
+ "with the same metadata collection id. " +
+ "There is a chance of metadata integrity issues since " +
+ "a metadata instance can be updated in two places.",
+ "It is necessary to update the local metadata collection Id to remove the conflict."),
+
+ INCOMING_CONFLICTING_METADATA_COLLECTION_ID("OMRS-AUDIT-0107",
+ OMRSAuditLogRecordSeverity.ACTION,
+ "Two servers in cohort {0} are using the same metadata collection identifier {1}",
+ "The local server will not be able to distinguish ownership of metadata " +
+ "from these open metadata repositories" +
+ "with the same metadata collection id. " +
+ "There is a chance of metadata integrity issues since " +
+ "a metadata instance can be updated in two places.",
+ "It is necessary to update the local metadata collection Id to remove the conflict."),
+
+ INCOMING_BAD_CONNECTION("OMRS-AUDIT-0108",
+ OMRSAuditLogRecordSeverity.ACTION,
+ "Registration error occurred in cohort {0} because remote server {1} that hosts " +
+ "metadata collection {2} is unable to use connection {3} to create a " +
+ "connector to this local server",
+ "The remote server will not be able to query metadata from this local server.",
+ "This error may be caused because the connection is incorrectly " +
+ "configured, or that the jar file for the connector is not available in the remote server."),
+
+ NEW_MEMBER_IN_COHORT("OMRS-AUDIT-0109",
+ OMRSAuditLogRecordSeverity.INFO,
+ "A new registration request has been received for cohort {0} from server {1} that " +
+ "hosts metadata collection {2}",
+ "The local server will process the registration request and if the parameters are correct, " +
+ "it will accept the new member.",
+ "No action is required. This is part of the normal operation of the server."),
+
+ MEMBER_LEFT_COHORT("OMRS-AUDIT-0110",
+ OMRSAuditLogRecordSeverity.INFO,
+ "Server {0} hosting metadata collection {1} has left cohort {2}",
+ "The local server will process the incoming unregistration request and if the parameters are correct, " +
+ "it will remove the former member from its cohort registry store.",
+ "No action is required. This is part of the normal operation of the server. " +
+ "Any metadata from this remote repository that is stored in the local repository will no longer be updated. " +
+ "It may be kept in the local repository for reference or removed by calling the administration REST API."),
+
+ REFRESHED_MEMBER_IN_COHORT("OMRS-AUDIT-0111",
+ OMRSAuditLogRecordSeverity.INFO,
+ "A re-registration request has been received for cohort {0} from server {1} that " +
+ "hosts metadata collection {2}",
+ "The local server will process the registration request and if the parameters are correct, " +
+ "it will accept the latest registration values for this member.",
+ "No action is required. This is part of the normal operation of the server."),
+
+ OUTGOING_CONFLICTING_METADATA_COLLECTION_ID("OMRS-AUDIT-0112",
+ OMRSAuditLogRecordSeverity.ACTION,
+ "Registration request received from cohort {0} was rejected by the " +
+ "local server because the remote server {1} is using a metadata " +
+ "collection Id {2} that is not unique in the cohort",
+ "The remote server will not exchange metadata with this local server.",
+ "It is necessary to update the TypeDef to remove the conflict " +
+ "before the remote server will exchange metadata with this server."),
+
+ OUTGOING_BAD_CONNECTION("OMRS-AUDIT-0113",
+ OMRSAuditLogRecordSeverity.ACTION,
+ "Registration error occurred in cohort {0} because the local server is not able to use " +
+ "the remote connection {1} supplied by server {2} that hosts metadata " +
+ "collection {3} to create a connector to its metadata repository",
+ "The local server is not able to query metadata from the remote server.",
+ "This error may be caused because the connection is incorrectly " +
+ "configured, or that the jar file for the connector is not available in the " +
+ "local server."),
+
+ CREATE_REGISTRY_FILE("OMRS-AUDIT-0114",
+ OMRSAuditLogRecordSeverity.INFO,
+ "Creating new cohort registry store {0}",
+ "The local server is creating a new cohort registry store. " +
+ "The local server should continue to operate correctly.",
+ "Verify that the local server is connecting to the open metadata repository cohort for" +
+ "the first time."),
+
+ UNUSABLE_REGISTRY_FILE("OMRS-AUDIT-0115",
+ OMRSAuditLogRecordSeverity.EXCEPTION,
+ "Unable to write to cohort registry store {0}",
+ "The local server can not write to the cohort registry store. " +
+ "This is a serious issue because the local server is not able to record its " +
+ "interaction with other servers in the cohort.",
+ "Shutdown the local server and resolve the issue with the repository store."),
+
+ NULL_MEMBER_REGISTRATION("OMRS-AUDIT-0116",
+ OMRSAuditLogRecordSeverity.ERROR,
+ "Unable to read or write to cohort registry store {0} because registration information is null",
+ "The local server can not manage a member registration in the cohort registry store because " +
+ "the registration information is null. " +
+ "This is a serious issue because the local server is not able to record its " +
+ "interaction with other servers in the cohort.",
+ "Shutdown the local server and resolve the issue with the cohort registry."),
+
+ MISSING_MEMBER_REGISTRATION("OMRS-AUDIT-0117",
+ OMRSAuditLogRecordSeverity.ERROR,
+ "Unable to process the remote registration for {0} from cohort registry store {1} " +
+ "because registration information is not stored",
+ "The local server can not process a member registration event from the cohort registry store " +
+ "because the registration information is not stored. " +
+ "This may simply be a timing issue. " +
+ "However, it may be the result of an earlier issue with the " +
+ "local cohort registry store.",
+ "Verify that there are no issues with writing to the cohort registry store."),
+
+ INCOMING_CONFLICTING_TYPEDEFS("OMRS-AUDIT-0201",
+ OMRSAuditLogRecordSeverity.ACTION,
+ "Server {1} in cohort {0} that hosts metadata collection {2} has detected that " +
+ "TypeDef {3} ({4}) in the local " +
+ "server conflicts with TypeDef {5} ({6}) in the remote server",
+ "The remote server may not be able to exchange metadata with this local server.",
+ "It is necessary to update the TypeDef to remove the conflict before the " +
+ "remote server will exchange metadata with this server."),
+
+ INCOMING_TYPEDEF_PATCH_MISMATCH("OMRS-AUDIT-0202",
+ OMRSAuditLogRecordSeverity.ACTION,
+ "Registration request for this server in cohort {0} was rejected by server {1} that " +
+ "hosts metadata collection {2} because TypeDef {3} ({4}) in the local " +
+ "server is at versionName {5} which is different from this TypeDef in the " +
+ "remote server which is at versionName {6}",
+ "The remote server may not be able to exchange metadata with this local server.",
+ "It is necessary to update the TypeDef to remove the conflict to ensure that the remote server " +
+ "can exchange metadata with this server."),
+
+ OUTGOING_CONFLICTING_TYPEDEFS("OMRS-AUDIT-0203",
+ OMRSAuditLogRecordSeverity.ACTION,
+ "The local server has detected a conflict in cohort {0} in the registration request " +
+ "from server {1} that hosts metadata collection {2}. TypeDef " +
+ "{3} ({4}) in the local server conflicts with TypeDef {5} ({6}) in the remote server",
+ "The local server will not exchange metadata with this remote server.",
+ "It is necessary to update the TypeDef to remove the conflict before the local " +
+ "server will exchange metadata with this server."),
+
+ OUTGOING_TYPEDEF_PATCH_MISMATCH("OMRS-AUDIT-0204",
+ OMRSAuditLogRecordSeverity.ACTION,
+ "The local server in cohort {0} has rejected a TypeDef update from server {1} that hosts metadata " +
+ "collection {2} because the versionName of TypeDef {3} ({4}) in the local server " +
+ "is at versionName {5} is different from this TypeDef in the remote server " +
+ "which is at versionName {6}",
+ "The local server will not exchange metadata with this remote server.",
+ "It is necessary to update the TypeDef to remove the conflict before the local server will " +
+ "exchange metadata with the remote server."),
+
+ OUTGOING_TYPE_MISMATCH("OMRS-AUDIT-0205",
+ OMRSAuditLogRecordSeverity.ACTION,
+ "The local server in cohort {0} has rejected a TypeDef update from server {1} that hosts " +
+ "metadata collection {2} because the versionName of TypeDef {3} ({4}) in the local " +
+ "server is at versionName {5} is different from this TypeDef in the remote server " +
+ "which is at versionName {6}",
+ "The local server will not exchange metadata with this remote server.",
+ "It is necessary to update the TypeDef to remove the conflict before the local server will " +
+ "exchange metadata with the remote server."),
+
+ PROCESS_UNKNOWN_EVENT("OMRS-AUDIT-8001",
+ OMRSAuditLogRecordSeverity.EVENT,
+ "Received unknown event: {0}",
+ "The local server has received an unknown event from another member of the metadata repository " +
+ "cohort and is unable to process it. " +
+ "This is possible if a server in the cohort is at a higher level than this server and " +
+ "is using a more advanced versionName of the protocol. " +
+ "The local server should continue to operate correctly.",
+ "Verify that the event is a new event type introduced after this server was written."),
+
+ NULL_OMRS_EVENT_RECEIVED("OMRS-AUDIT-9002",
+ OMRSAuditLogRecordSeverity.EXCEPTION,
+ "Unable to process a received event because its content is null",
+ "The system is unable to process an incoming event.",
+ "This may be caused by an internal logic error or the receipt of an incompatible OMRSEvent"),
+
+ SEND_TYPEDEF_EVENT_ERROR("OMRS-AUDIT-9003",
+ OMRSAuditLogRecordSeverity.EXCEPTION,
+ "Unable to send a TypeDef event for cohort {0} due to an error in the OMRS Topic Connector",
+ "The local server is unable to properly manage TypeDef events for the metadata " +
+ "repository cohort. The cause of the error is recorded in the accompanying exception.",
+ "Review the exception and resolve the issue it documents. " +
+ "Then disconnect and reconnect this server to the cohort."),
+
+ SEND_INSTANCE_EVENT_ERROR("OMRS-AUDIT-9005",
+ OMRSAuditLogRecordSeverity.EXCEPTION,
+ "Unable to send or receive a metadata instance event for cohort {0} due to an error in the OMRS Topic Connector",
+ "The local server is unable to properly manage the replication of metadata instances for " +
+ "the metadata repository cohort. The cause of the error is recorded in the accompanying exception.",
+ "Review the exception and resolve the issue it documents. " +
+ "Then disconnect and reconnect this server to the cohort."),
+
+ NULL_REGISTRY_PROCESSOR("OMRS-AUDIT-9006",
+ OMRSAuditLogRecordSeverity.EXCEPTION,
+ "Unable to send or receive a registry event because the event processor is null",
+ "The local server is unable to properly manage registration events for the metadata " +
+ "repository cohort.",
+ "This is an internal logic error. Raise a JIRA, including the audit log, to get this fixed."),
+
+ NULL_TYPEDEF_PROCESSOR("OMRS-AUDIT-9007",
+ OMRSAuditLogRecordSeverity.EXCEPTION,
+ "Unable to send or receive a TypeDef event because the event processor is null",
+ "The local server is unable to properly manage the exchange of TypeDefs for the metadata " +
+ "repository cohort.",
+ "This is an internal logic error. Raise a JIRA, including the audit log, to get this fixed."),
+
+ NULL_INSTANCE_PROCESSOR("OMRS-AUDIT-9008",
+ OMRSAuditLogRecordSeverity.EXCEPTION,
+ "Unable to send or receive a metadata instance event because the event processor is null",
+ "The local server is unable to properly manage the replication of metadata instances for " +
+ "the metadata repository cohort.",
+ "This is an internal logic error. Raise a JIRA, including the audit log, to get this fixed."),
+
+ NULL_OMRS_CONFIG("OMRS-AUDIT-9009",
+ OMRSAuditLogRecordSeverity.EXCEPTION,
+ "Unable to initialize part of the Open Metadata Repository Service (OMRS) because the configuration is null",
+ "The local server is unable to properly manage the replication of metadata instances for " +
+ "the metadata repository cohort.",
+ "This is an internal logic error. Raise a JIRA, including the audit log, to get this fixed."),
+
+ SENT_UNKNOWN_EVENT("OMRS-AUDIT-9010",
+ OMRSAuditLogRecordSeverity.EXCEPTION,
+ "Unable to send an event because the event is of an unknown type",
+ "The local server may not be communicating properly with other servers in " +
+ "the metadata repository cohort.",
+ "This is an internal logic error. Raise a JIRA, including the audit log, to get this fixed.")
+
+ ;
+
+ private String logMessageId;
+ private OMRSAuditLogRecordSeverity severity;
+ private String logMessage;
+ private String systemAction;
+ private String userAction;
+
+ private static final Logger log = LoggerFactory.getLogger(OMRSAuditCode.class);
+
+
+ /**
+ * The constructor for OMRSAuditCode expects to be passed one of the enumeration rows defined in
+ * OMRSAuditCode above. For example:
+ *
+ * OMRSAuditCode auditCode = OMRSAuditCode.SERVER_NOT_AVAILABLE;
+ *
+ * This will expand out to the 4 parameters shown below.
+ *
+ * @param messageId - unique Id for the message
+ * @param severity - severity of the message
+ * @param message - text for the message
+ * @param systemAction - description of the action taken by the system when the condition happened
+ * @param userAction - instructions for resolving the situation, if any
+ */
+ OMRSAuditCode(String messageId,
+ OMRSAuditLogRecordSeverity severity,
+ String message,
+ String systemAction,
+ String userAction)
+ {
+ this.logMessageId = messageId;
+ this.severity = severity;
+ this.logMessage = message;
+ this.systemAction = systemAction;
+ this.userAction = userAction;
+ }
+
+
+ /**
+ * Returns the unique identifier for the error message.
+ *
+ * @return logMessageId
+ */
+ public String getLogMessageId()
+ {
+ return logMessageId;
+ }
+
+
+ /**
+ * Return the severity of the audit log record.
+ *
+ * @return OMRSAuditLogRecordSeverity enum
+ */
+ public OMRSAuditLogRecordSeverity getSeverity()
+ {
+ return severity;
+ }
+
+ /**
+ * Returns the log message with the placeholders filled out with the supplied parameters.
+ *
+ * @param params - strings that plug into the placeholders in the logMessage
+ * @return logMessage (formatted with supplied parameters)
+ */
+ public String getFormattedLogMessage(String... params)
+ {
+ if (log.isDebugEnabled())
+ {
+ log.debug(String.format("<== OMRS Audit Code.getMessage(%s)", Arrays.toString(params)));
+ }
+
+ MessageFormat mf = new MessageFormat(logMessage);
+ String result = mf.format(params);
+
+ if (log.isDebugEnabled())
+ {
+ log.debug(String.format("==> OMRS Audit Code.getMessage(%s): %s", Arrays.toString(params), result));
+ }
+
+ return result;
+ }
+
+
+
+ /**
+ * Returns a description of the action taken by the system when the condition that caused this exception was
+ * detected.
+ *
+ * @return systemAction String
+ */
+ public String getSystemAction()
+ {
+ return systemAction;
+ }
+
+
+ /**
+ * Returns instructions of how to resolve the issue reported in this exception.
+ *
+ * @return userAction String
+ */
+ public String getUserAction()
+ {
+ return userAction;
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/auditlog/OMRSAuditLog.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/auditlog/OMRSAuditLog.java b/omrs/src/main/java/org/apache/atlas/omrs/auditlog/OMRSAuditLog.java
new file mode 100644
index 0000000..5f63c92
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/auditlog/OMRSAuditLog.java
@@ -0,0 +1,197 @@
+/*
+ * 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.auditlog;
+
+
+import org.apache.atlas.omrs.auditlog.store.OMRSAuditLogRecord;
+import org.apache.atlas.omrs.auditlog.store.OMRSAuditLogRecordOriginator;
+import org.apache.atlas.omrs.auditlog.store.OMRSAuditLogReportingComponent;
+import org.apache.atlas.omrs.auditlog.store.OMRSAuditLogStore;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+
+/**
+ * OMRSAuditLog is a class for managing the audit logging of activity for the OMRS components. Each auditing component
+ * will have their own instance of an OMRSAuditLog. OMRSAuditLog will ensure audit log records are written to
+ * disk in the common OMRSAuditLog for this local server.
+ *
+ * There are different levels of log record to cover all of the activity of the OMRS.
+ *
+ * This audit log is critical to validate the behavior of the OMRS, particularly in the initial interaction of
+ * a new metadata repository to the OMRS Cohort.
+ */
+public class OMRSAuditLog
+{
+ static private final OMRSAuditLogRecordOriginator originator = new OMRSAuditLogRecordOriginator();
+ static private OMRSAuditLogStore auditLogStore = null;
+
+ private static final Logger log = LoggerFactory.getLogger(OMRSAuditLog.class);
+
+ private OMRSAuditLogReportingComponent reportingComponent = null;
+
+
+ /**
+ * Initialize the static values used in all log records. These values help to pin-point the source of messages
+ * when audit log records from many servers are consolidated into centralized operational tooling.
+ *
+ * @param localServerName - name of the local server
+ * @param localServerType - type of the local server
+ * @param localOrganizationName - name of the organization that owns the local server
+ * @param auditLogStore - destination for the audit log records
+ */
+ public static void initialize(String localServerName,
+ String localServerType,
+ String localOrganizationName,
+ OMRSAuditLogStore auditLogStore)
+ {
+ OMRSAuditLog.originator.setServerName(localServerName);
+ OMRSAuditLog.originator.setServerType(localServerType);
+ OMRSAuditLog.originator.setOrganizationName(localOrganizationName);
+
+ OMRSAuditLog.auditLogStore = auditLogStore;
+ }
+
+
+ /**
+ * Set up the local metadata collection Id. This is null if there is no local repository.
+ *
+ * @param localMetadataCollectionId - String unique identifier for the metadata collection
+ */
+ public static void setLocalMetadataCollectionId(String localMetadataCollectionId)
+ {
+ OMRSAuditLog.originator.setMetadataCollectionId(localMetadataCollectionId);
+ }
+
+
+ /**
+ * Typical constructor - Each component using the Audit log will create their own OMRSAuditLog instance and
+ * will push log records to it.
+ *
+ * @param reportingComponent - information about the component that will use this instance of the audit log.
+ */
+ public OMRSAuditLog(OMRSAuditingComponent reportingComponent)
+ {
+ this.reportingComponent = new OMRSAuditLogReportingComponent(reportingComponent.getComponentId(),
+ reportingComponent.getComponentName(),
+ reportingComponent.getComponentDescription(),
+ reportingComponent.getComponentWikiURL());
+ }
+
+
+ /**
+ * Log an audit log record for an event, decision, error, or exception detected by the OMRS.
+ *
+ * @param actionDescription - description of the activity creating the audit log record
+ * @param logMessageId - id for the audit log record
+ * @param severity - is this an event, decision, error or exception?
+ * @param logMessage - description of the audit log record including specific resources involved
+ * @param additionalInformation - additional data to help resolve issues of verify behavior
+ * @param systemAction - the related action taken by the OMRS.
+ * @param userAction - details of any action that an administrator needs to take.
+ */
+ public void logRecord(String actionDescription,
+ String logMessageId,
+ OMRSAuditLogRecordSeverity severity,
+ String logMessage,
+ String additionalInformation,
+ String systemAction,
+ String userAction)
+ {
+ if (severity != null)
+ {
+ if ((severity == OMRSAuditLogRecordSeverity.ERROR) || (severity == OMRSAuditLogRecordSeverity.EXCEPTION))
+ {
+ log.error("New Audit Log Record", actionDescription, logMessageId, severity, logMessage, additionalInformation, systemAction, userAction);
+ }
+ else
+ {
+ log.info("New Audit Log Record", actionDescription, logMessageId, severity, logMessage, additionalInformation, systemAction, userAction);
+ }
+ }
+ else
+ {
+ severity = OMRSAuditLogRecordSeverity.UNKNOWN;
+ }
+
+ if (auditLogStore != null)
+ {
+ ArrayList<String> additionalInformationArray = null;
+
+ if (additionalInformation != null)
+ {
+ additionalInformationArray = new ArrayList<>();
+ additionalInformationArray.add(additionalInformation);
+ }
+
+ OMRSAuditLogRecord logRecord = new OMRSAuditLogRecord(originator,
+ reportingComponent,
+ severity.getSeverityName(),
+ logMessageId,
+ logMessage,
+ additionalInformationArray,
+ systemAction,
+ userAction);
+ try
+ {
+ auditLogStore.storeLogRecord(logRecord);
+ }
+ catch (Throwable error)
+ {
+ log.error("Error writing audit log: ", logRecord, error);
+ }
+ }
+ }
+
+ /**
+ * Log details of an unexpected exception detected by the OMRS. These exceptions typically mean that the local
+ * server is not configured correctly, or there is a logic error in the code. When exceptions are logged, it is
+ * important that they are investigated and the cause corrected since the local repository is not able to operate
+ * as a proper peer in the metadata repository cluster whilst these conditions persist.
+ *
+ * @param actionDescription - description of the activity in progress when the error occurred
+ * @param logMessageId - id for the type of exception caught
+ * @param severity - severity of the error
+ * @param logMessage - description of the exception including specific resources involved
+ * @param additionalInformation - additional data to help resolve issues of verify behavior
+ * @param systemAction - the action taken by the OMRS in response to the error.
+ * @param userAction - details of any action that an administrator needs to take.
+ * @param caughtException - the original exception.
+ */
+ public void logException(String actionDescription,
+ String logMessageId,
+ OMRSAuditLogRecordSeverity severity,
+ String logMessage,
+ String additionalInformation,
+ String systemAction,
+ String userAction,
+ Throwable caughtException)
+ {
+ if (caughtException != null)
+ {
+ this.logRecord(actionDescription,
+ logMessageId,
+ severity,
+ logMessage,
+ additionalInformation + caughtException.toString(),
+ systemAction,
+ userAction);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/auditlog/OMRSAuditLogRecordSeverity.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/auditlog/OMRSAuditLogRecordSeverity.java b/omrs/src/main/java/org/apache/atlas/omrs/auditlog/OMRSAuditLogRecordSeverity.java
new file mode 100644
index 0000000..61b1e16
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/auditlog/OMRSAuditLogRecordSeverity.java
@@ -0,0 +1,122 @@
+/*
+ * 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.auditlog;
+
+/**
+ * OMRSAuditLogRecordSeverity defines the different levels of severity for log records stored in the OMRSAuditLogRecord.
+ * <ul>
+ * <li>
+ * UNKNOWN - Uninitialized Severity - if this is seen then there is a logic error in the audit log processing.
+ * </li>
+ * <li>
+ * INFO - An activity occurred as part of the normal operation of the open metadata repository.
+ * </li>
+ * <li>
+ * EVENT - An OMRS Event was sent to or received from members of an open metadata repository cohort.
+ * </li>
+ * <li>
+ * DECISION - A decision has been made related to the interaction of the local metadata repository and the
+ * rest of the open metadata repository cohort.
+ * </li>
+ * <li>
+ * ACTION - A situation has been detected that requires administrator intervention.
+ * </li>
+ * <li>
+ * ERROR - An unexpected error occurred, possibly caused by an incompatibility between the local metadata repository
+ * and one of the remote repositories. The local repository may restrict some of the metadata interchange
+ * functions as a result.
+ * </li>
+ * <li>
+ * EXCEPTION - Unexpected exception occurred. This means that the local repository needs some administration
+ * attention to correct configuration or fix a logic error because it is not operating as a proper peer in the
+ * metadata repository cluster.
+ * </li>
+ * </ul>
+ */
+public enum OMRSAuditLogRecordSeverity
+{
+ UNKNOWN (0, "<Unknown>", "Uninitialized Severity."),
+ INFO (1, "Information", "The server is providing information about its normal operation."),
+ EVENT (2, "Event", "An OMRSEvent was exchanged amongst members of the metadata repository cohort."),
+ DECISION (3, "Decision", "A decision has been made related to the interaction of the local metadata repository and the rest of the cohort."),
+ ACTION (4, "Action", "Action is required by the administrator. " +
+ "At a minimum, the situation needs to be investigated and if necessary, corrective action taken."),
+ ERROR (5, "Error", "An error occurred, possibly caused by an incompatibility between the local metadata repository \n" +
+ "and one of the remote repositories. " +
+ "The local repository may restrict some of the metadata interchange \n" +
+ "functions as a result."),
+ EXCEPTION (6, "Exception", "Unexpected exception occurred. This means that the local repository needs some administration\n" +
+ " attention to correct configuration or fix a logic error because it is not operating as a proper peer in the\n" +
+ " metadata repository cohort.");
+
+
+ private int severityCode;
+ private String severityName;
+ private String severityDescription;
+
+
+ /**
+ * Typical constructor sets up the selected enum value.
+ *
+ * @param severityCode - numeric of this enum.
+ * @param severityName - name of enum.
+ * @param severityDescription - default description of enum..
+ */
+ OMRSAuditLogRecordSeverity(int severityCode,
+ String severityName,
+ String severityDescription)
+ {
+ this.severityCode = severityCode;
+ this.severityName = severityName;
+ this.severityDescription = severityDescription;
+ }
+
+ /**
+ * Return the code for this enum.
+ *
+ * @return int numeric for this enum
+ */
+ public int getSeverityCode()
+ {
+ return severityCode;
+ }
+
+
+ /**
+ * Return the name of this enum.
+ *
+ * @return String name
+ */
+ public String getSeverityName()
+ {
+ return severityName;
+ }
+
+
+ /**
+ * Return the default description of this enum. This description is in English. Natural language translations can be
+ * created using a Resource Bundle indexed by the severity code. This description is a fall back when the resource
+ * bundle is not available.
+ *
+ * @return String default description
+ */
+ public String getSeverityDescription()
+ {
+ return severityDescription;
+ }
+}