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:17 UTC
[01/30] atlas git commit: ATLAS-2246: OMRS Connector API plus REST
and IGC Connector skeleton - 15th February 2018
Repository: atlas
Updated Branches:
refs/heads/master c2be0646d -> 8a57e6571
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/metadatahighway/cohortregistry/store/file/FileBasedRegistryStoreConnector.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/metadatahighway/cohortregistry/store/file/FileBasedRegistryStoreConnector.java b/omrs/src/main/java/org/apache/atlas/omrs/metadatahighway/cohortregistry/store/file/FileBasedRegistryStoreConnector.java
new file mode 100644
index 0000000..7402a81
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/metadatahighway/cohortregistry/store/file/FileBasedRegistryStoreConnector.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.metadatahighway.cohortregistry.store.file;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.atlas.omrs.auditlog.OMRSAuditCode;
+import org.apache.atlas.omrs.auditlog.OMRSAuditLog;
+import org.apache.atlas.omrs.auditlog.OMRSAuditingComponent;
+import org.apache.atlas.omrs.metadatahighway.cohortregistry.store.OMRSCohortRegistryStoreConnectorBase;
+import org.apache.atlas.omrs.metadatahighway.cohortregistry.store.properties.CohortMembership;
+import org.apache.atlas.omrs.metadatahighway.cohortregistry.store.properties.MemberRegistration;
+
+import org.apache.commons.io.FileUtils;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * FileBasedRegistryStoreConnector uses JSON to store details of the membership of the open metadata repository
+ * cohort on behalf of the OMRSCohortRegistry.
+ */
+public class FileBasedRegistryStoreConnector extends OMRSCohortRegistryStoreConnectorBase
+{
+ /*
+ * This is the name of the cohort registry file that is used if there is no file name in the connection.
+ */
+ private static final String defaultFilename = "cohort.registry";
+
+ /*
+ * Variables used in writing to the file.
+ */
+ private String registryStoreName = defaultFilename;
+ private CohortMembership registryStoreProperties = null;
+
+ /*
+ * Variables used for logging and debug.
+ */
+ private static final OMRSAuditLog auditLog = new OMRSAuditLog(OMRSAuditingComponent.REGISTRY_STORE);
+
+ private static final Logger log = LoggerFactory.getLogger(FileBasedRegistryStoreConnector.class);
+
+ /**
+ * Default constructor
+ */
+ public FileBasedRegistryStoreConnector()
+ {
+ /*
+ * Nothing to do
+ */
+ }
+
+
+ /**
+ * Returns the index of the requested member in the members array list. If the member is not found, the index
+ * returned is the size of the array.
+ *
+ * @param metadataCollectionId - id of the member to find.
+ * @param members - list of members
+ * @return int index pointing to the location of the member (or the size of the array if the member is not found).
+ */
+ private int findRemoteRegistration(String metadataCollectionId, ArrayList<MemberRegistration> members)
+ {
+ int indexOfNewMember = members.size();
+
+ for (int i=0; i<members.size(); i++)
+ {
+ String memberId = members.get(i).getMetadataCollectionId();
+
+ if (metadataCollectionId.equals(memberId))
+ {
+ if (log.isDebugEnabled())
+ {
+ log.debug("Found existing registration for " + metadataCollectionId + " at position " + i);
+ }
+ return i;
+ }
+ }
+
+ if (log.isDebugEnabled())
+ {
+ log.debug("New registration for " + metadataCollectionId + " - saving at position " + indexOfNewMember);
+ }
+ return indexOfNewMember;
+ }
+
+
+ /**
+ * Save the local registration to the cohort registry store. This provides details of the local repository's
+ * registration with the metadata repository cohort.
+ * Any previous local registration information is overwritten.
+ *
+ * @param localRegistration - details of the local repository's registration with the metadata cohort.
+ */
+ public void saveLocalRegistration(MemberRegistration localRegistration)
+ {
+ if (localRegistration != null)
+ {
+ if (registryStoreProperties == null)
+ {
+ registryStoreProperties = this.retrieveRegistryStoreProperties();
+ }
+
+ registryStoreProperties.setLocalRegistration(localRegistration);
+
+ this.writeRegistryStoreProperties(registryStoreProperties);
+ }
+ else
+ {
+ String actionDescription = "Saving Local Registration to Registry Store";
+
+ OMRSAuditCode auditCode = OMRSAuditCode.NULL_MEMBER_REGISTRATION;
+
+ auditLog.logRecord(actionDescription,
+ auditCode.getLogMessageId(),
+ auditCode.getSeverity(),
+ auditCode.getFormattedLogMessage(registryStoreName),
+ null,
+ auditCode.getSystemAction(),
+ auditCode.getUserAction());
+
+ if (log.isDebugEnabled())
+ {
+ log.debug("Null local registration passed to saveLocalRegistration :(");
+ }
+ }
+ }
+
+
+ /**
+ * Retrieve details of the local registration from the cohort registry store. A null may be returned if the
+ * local registration information has not been saved (typically because this is a new server instance).
+ *
+ * @return MemberRegistration object containing details for the local repository's registration with the
+ * metadata cohort (may be null if no registration has taken place).
+ */
+ public MemberRegistration retrieveLocalRegistration()
+ {
+ MemberRegistration localRegistration = null;
+
+ if (registryStoreProperties == null)
+ {
+ registryStoreProperties = this.retrieveRegistryStoreProperties();
+ }
+
+ localRegistration = registryStoreProperties.getLocalRegistration();
+
+ if (log.isDebugEnabled())
+ {
+ if (localRegistration == null)
+ {
+ log.debug("Null local registration returned from retrieveLocalRegistration");
+ }
+ else
+ {
+ log.debug("Local Registration details: " +
+ "metadataCollectionId: " + localRegistration.getMetadataCollectionId() +
+ "; displayName: " + localRegistration.getServerName() +
+ "; serverType: " + localRegistration.getServerType() +
+ "; organizationName: " + localRegistration.getOrganizationName() +
+ "; registrationTime " + localRegistration.getRegistrationTime());
+ }
+ }
+
+ return localRegistration;
+ }
+
+
+ /**
+ * Remove details of the local registration from the cohort registry store. This is used when the local
+ * repository unregisters from the open metadata repository cohort.
+ *
+ * There is a side-effect that all of the remote registrations are removed to since the local repository is
+ * no longer a member of this cohort.
+ */
+ public void removeLocalRegistration()
+ {
+ if (log.isDebugEnabled())
+ {
+ log.debug("Emptying cohort registry store.");
+ }
+
+ this.writeRegistryStoreProperties(new CohortMembership());
+ }
+
+
+ /**
+ * Save details of a remote registration. This contains details of one of the other repositories in the
+ * metadata repository cohort.
+ *
+ * @param remoteRegistration - details of a remote repository in the metadata repository cohort.
+ */
+ public void saveRemoteRegistration(MemberRegistration remoteRegistration)
+ {
+ if (remoteRegistration != null)
+ {
+ /*
+ * Retrieve the current properties from the file is necessary.
+ */
+ if (registryStoreProperties == null)
+ {
+ registryStoreProperties = this.retrieveRegistryStoreProperties();
+ }
+
+ /*
+ * It is possible that the remote repository already has an entry in the cohort registry and if this is
+ * the case, it will be overwritten. Otherwise the new remote properties are added.
+ */
+ ArrayList<MemberRegistration> remotePropertiesList = registryStoreProperties.getRemoteRegistrations();
+
+ int index = findRemoteRegistration(remoteRegistration.getMetadataCollectionId(), remotePropertiesList);
+
+ if (index < remotePropertiesList.size())
+ {
+ remotePropertiesList.set(index, remoteRegistration);
+ }
+ else
+ {
+ remotePropertiesList.add(remoteRegistration);
+ }
+ registryStoreProperties.setRemoteRegistrations(remotePropertiesList);
+
+ /*
+ * Write out the new cohort registry content.
+ */
+ this.writeRegistryStoreProperties(registryStoreProperties);
+ }
+ else
+ {
+ String actionDescription = "Saving a Remote Registration to Cohort Registry Store";
+
+ OMRSAuditCode auditCode = OMRSAuditCode.NULL_MEMBER_REGISTRATION;
+
+ auditLog.logRecord(actionDescription,
+ auditCode.getLogMessageId(),
+ auditCode.getSeverity(),
+ auditCode.getFormattedLogMessage(registryStoreName),
+ null,
+ auditCode.getSystemAction(),
+ auditCode.getUserAction());
+
+ if (log.isDebugEnabled())
+ {
+ log.debug("Null remote registration passed to saveRemoteRegistration :(");
+ }
+ }
+ }
+
+
+ /**
+ * Return a list of all of the remote metadata repositories registered in the metadata repository cohort.
+ *
+ * @return Remote registrations iterator
+ */
+ public ArrayList<MemberRegistration> retrieveRemoteRegistrations()
+ {
+ ArrayList<MemberRegistration> remoteRegistrations = null;
+
+ /*
+ * Ensure the current properties are retrieved from the registry.
+ */
+ if (registryStoreProperties == null)
+ {
+ registryStoreProperties = this.retrieveRegistryStoreProperties();
+ }
+
+ /*
+ * Copy the remote member properties into a registration iterator for return.
+ */
+ ArrayList<MemberRegistration> remotePropertiesList = registryStoreProperties.getRemoteRegistrations();
+ ArrayList<MemberRegistration> remoteRegistrationArray = new ArrayList<>();
+
+ for (MemberRegistration remoteRegistration : remotePropertiesList)
+ {
+ MemberRegistration member = new MemberRegistration(remoteRegistration);
+
+ remoteRegistrationArray.add(member);
+ }
+
+ if (remoteRegistrationArray.size() > 0)
+ {
+ remoteRegistrations = remoteRegistrationArray;
+ }
+
+ return remoteRegistrations;
+ }
+
+
+ /**
+ * Return the registration information for a specific metadata repository, identified by its metadataCollectionId.
+ * If the metadataCollectionId is not recognized then null is returned.
+ *
+ * @param metadataCollectionId - unique identifier for the repository
+ * @return MemberRegistration object containing details of the remote metadata repository. (null if not found)
+ */
+ public MemberRegistration retrieveRemoteRegistration(String metadataCollectionId)
+ {
+ MemberRegistration remoteRegistration = null;
+
+ if (metadataCollectionId != null)
+ {
+ /*
+ * Ensure the current properties are retrieved from the registry.
+ */
+ if (registryStoreProperties == null)
+ {
+ registryStoreProperties = this.retrieveRegistryStoreProperties();
+ }
+
+ /*
+ * Retrieve the list of remote registrations
+ */
+ ArrayList<MemberRegistration> remotePropertiesList = registryStoreProperties.getRemoteRegistrations();
+
+ /*
+ * Locate the required entry
+ */
+ int indexOfEntry = findRemoteRegistration(metadataCollectionId, remotePropertiesList);
+
+ /*
+ * If the entry is found create a registration object from it.
+ */
+ if (indexOfEntry < remotePropertiesList.size())
+ {
+ remoteRegistration = remotePropertiesList.get(indexOfEntry);
+ }
+ }
+ else
+ {
+ String actionDescription = "Retrieving Remote Registration from Cohort Registry Store";
+
+ OMRSAuditCode auditCode = OMRSAuditCode.NULL_MEMBER_REGISTRATION;
+
+ auditLog.logRecord(actionDescription,
+ auditCode.getLogMessageId(),
+ auditCode.getSeverity(),
+ auditCode.getFormattedLogMessage(registryStoreName),
+ null,
+ auditCode.getSystemAction(),
+ auditCode.getUserAction());
+
+ if (log.isDebugEnabled())
+ {
+ log.debug("Null metadataCollectionId passed to retrieveRemoteRegistration :(");
+ }
+ }
+
+ return remoteRegistration;
+ }
+
+
+ /**
+ * Remove details of the requested remote repository's registration from the store.
+ *
+ * @param metadataCollectionId - unique identifier for the repository
+ */
+ public void removeRemoteRegistration(String metadataCollectionId)
+ {
+ if (metadataCollectionId != null)
+ {
+ /*
+ * Ensure the current properties are retrieved from the registry.
+ */
+ if (registryStoreProperties == null)
+ {
+ registryStoreProperties = this.retrieveRegistryStoreProperties();
+ }
+
+ /*
+ * Retrieve the list of remote registrations
+ */
+ ArrayList<MemberRegistration> remotePropertiesList = registryStoreProperties.getRemoteRegistrations();
+
+ /*
+ * Locate the required entry
+ */
+ int indexOfEntry = findRemoteRegistration(metadataCollectionId, remotePropertiesList);
+
+ /*
+ * If the entry is found create a registration object from it.
+ */
+ if (indexOfEntry < remotePropertiesList.size())
+ {
+ remotePropertiesList.remove(indexOfEntry);
+ registryStoreProperties.setRemoteRegistrations(remotePropertiesList);
+ writeRegistryStoreProperties(registryStoreProperties);
+ }
+ else
+ {
+ String actionDescription = "Removing Remote Registration from Cohort Registry Store";
+
+ OMRSAuditCode auditCode = OMRSAuditCode.MISSING_MEMBER_REGISTRATION;
+
+ auditLog.logRecord(actionDescription,
+ auditCode.getLogMessageId(),
+ auditCode.getSeverity(),
+ auditCode.getFormattedLogMessage(metadataCollectionId, registryStoreName),
+ null,
+ auditCode.getSystemAction(),
+ auditCode.getUserAction());
+
+ if (log.isDebugEnabled())
+ {
+ log.debug("MetadataCollectionId : " + metadataCollectionId + " passed to removeRemoteRegistration not found :(");
+ }
+ }
+ }
+ else
+ {
+ String actionDescription = "Removing Remote Registration from Cohort Registry Store";
+
+ OMRSAuditCode auditCode = OMRSAuditCode.NULL_MEMBER_REGISTRATION;
+
+ auditLog.logRecord(actionDescription,
+ auditCode.getLogMessageId(),
+ auditCode.getSeverity(),
+ auditCode.getFormattedLogMessage(registryStoreName),
+ null,
+ auditCode.getSystemAction(),
+ auditCode.getUserAction());
+
+ if (log.isDebugEnabled())
+ {
+ log.debug("Null metadataCollectionId passed to removeRemoteRegistration :(");
+ }
+ }
+ }
+
+
+ /**
+ * Remove the local and remote registrations from the cohort registry store since the local server has
+ * unregistered from the cohort.
+ */
+ public void clearAllRegistrations()
+ {
+ writeRegistryStoreProperties(null);
+ }
+
+
+ /**
+ * Close the config file
+ */
+ public void disconnect()
+ {
+ registryStoreProperties = null;
+
+ if (log.isDebugEnabled())
+ {
+ log.debug("Closing Cohort Registry Store.");
+ }
+ }
+
+
+ /**
+ * Refresh the registry store properties with the current values in the file base registry store.
+ *
+ * @return CohortRegistryProperties object containing the currently stored properties.
+ */
+ private CohortMembership retrieveRegistryStoreProperties()
+ {
+ File registryStoreFile = new File(registryStoreName);
+ CohortMembership newRegistryStoreProperties = null;
+
+ try
+ {
+ if (log.isDebugEnabled())
+ {
+ log.debug("Retrieving cohort registry store properties");
+ }
+
+ String registryStoreFileContents = FileUtils.readFileToString(registryStoreFile, "UTF-8");
+
+ ObjectMapper objectMapper = new ObjectMapper();
+ newRegistryStoreProperties = objectMapper.readValue(registryStoreFileContents, CohortMembership.class);
+ }
+ catch (IOException ioException)
+ {
+ /*
+ * The registry file is not found, create a new one ...
+ */
+ String actionDescription = "Retrieving Cohort Registry Store Properties";
+
+ OMRSAuditCode auditCode = OMRSAuditCode.CREATE_REGISTRY_FILE;
+
+ auditLog.logRecord(actionDescription,
+ auditCode.getLogMessageId(),
+ auditCode.getSeverity(),
+ auditCode.getFormattedLogMessage(registryStoreName),
+ null,
+ auditCode.getSystemAction(),
+ auditCode.getUserAction());
+
+ if (log.isDebugEnabled())
+ {
+ log.debug("New Cohort Registry Store", ioException);
+ }
+
+ newRegistryStoreProperties = new CohortMembership();
+ }
+
+ return newRegistryStoreProperties;
+ }
+
+
+ /**
+ * Writes the supplied registry store properties to the registry store.
+ *
+ * @param newRegistryStoreProperties - contents of the registry store
+ */
+ private void writeRegistryStoreProperties(CohortMembership newRegistryStoreProperties)
+ {
+ File registryStoreFile = new File(registryStoreName);
+
+ try
+ {
+ if (log.isDebugEnabled())
+ {
+ log.debug("Writing cohort registry store properties", newRegistryStoreProperties);
+ }
+
+ if (newRegistryStoreProperties == null)
+ {
+ registryStoreFile.delete();
+ }
+ else
+ {
+ ObjectMapper objectMapper = new ObjectMapper();
+
+ String registryStoreFileContents = objectMapper.writeValueAsString(newRegistryStoreProperties);
+
+ FileUtils.writeStringToFile(registryStoreFile, registryStoreFileContents, false);
+ }
+ }
+ catch (IOException ioException)
+ {
+ String actionDescription = "Writing Cohort Registry Store Properties";
+
+ OMRSAuditCode auditCode = OMRSAuditCode.UNUSABLE_REGISTRY_FILE;
+
+ auditLog.logException(actionDescription,
+ auditCode.getLogMessageId(),
+ auditCode.getSeverity(),
+ auditCode.getFormattedLogMessage(registryStoreName),
+ null,
+ auditCode.getSystemAction(),
+ auditCode.getUserAction(),
+ ioException);
+
+ if (log.isDebugEnabled())
+ {
+ log.debug("Unusable Cohort Registry Store :(", ioException);
+ }
+ }
+ }
+
+ /**
+ * Flush all changes and close the registry store.
+ */
+ public void close()
+ {
+ this.disconnect();
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/metadatahighway/cohortregistry/store/file/FileBasedRegistryStoreProvider.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/metadatahighway/cohortregistry/store/file/FileBasedRegistryStoreProvider.java b/omrs/src/main/java/org/apache/atlas/omrs/metadatahighway/cohortregistry/store/file/FileBasedRegistryStoreProvider.java
new file mode 100644
index 0000000..6f33ec1
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/metadatahighway/cohortregistry/store/file/FileBasedRegistryStoreProvider.java
@@ -0,0 +1,37 @@
+/*
+ * 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.metadatahighway.cohortregistry.store.file;
+
+import org.apache.atlas.omrs.metadatahighway.cohortregistry.store.OMRSCohortRegistryStoreProviderBase;
+
+/**
+ * FileBasedRegistryStoreProvider is the OCF connector provider for the file based cohort registry store.
+ */
+public class FileBasedRegistryStoreProvider extends OMRSCohortRegistryStoreProviderBase
+{
+ /**
+ * Constructor used to initialize the ConnectorProviderBase with the Java class name of the specific
+ * registry store implementation.
+ */
+ public FileBasedRegistryStoreProvider()
+ {
+ Class connectorClass = FileBasedRegistryStoreConnector.class;
+
+ super.setConnectorClassName(connectorClass.getName());
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/metadatahighway/cohortregistry/store/properties/CohortMembership.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/metadatahighway/cohortregistry/store/properties/CohortMembership.java b/omrs/src/main/java/org/apache/atlas/omrs/metadatahighway/cohortregistry/store/properties/CohortMembership.java
new file mode 100644
index 0000000..60bcc43
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/metadatahighway/cohortregistry/store/properties/CohortMembership.java
@@ -0,0 +1,67 @@
+/*
+ * 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.metadatahighway.cohortregistry.store.properties;
+
+import com.fasterxml.jackson.annotation.JsonAutoDetect;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+
+import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY;
+import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE;
+
+/**
+ * CohortMembership describes the structure of the cohort registry store. It contains details
+ * of the local registration and a list of remote member registrations.
+ */
+@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown=true)
+public class CohortMembership implements Serializable
+{
+ private static final long serialVersionUID = 1L;
+
+ private MemberRegistration localRegistration = null;
+ private ArrayList<MemberRegistration> remoteRegistrations = null;
+
+ public CohortMembership()
+ {
+ }
+
+ public MemberRegistration getLocalRegistration()
+ {
+ return localRegistration;
+ }
+
+ public void setLocalRegistration(MemberRegistration localRegistration)
+ {
+ this.localRegistration = localRegistration;
+ }
+
+ public ArrayList<MemberRegistration> getRemoteRegistrations()
+ {
+ return remoteRegistrations;
+ }
+
+ public void setRemoteRegistrations(ArrayList<MemberRegistration> remoteRegistrations)
+ {
+ this.remoteRegistrations = remoteRegistrations;
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/metadatahighway/cohortregistry/store/properties/MemberRegistration.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/metadatahighway/cohortregistry/store/properties/MemberRegistration.java b/omrs/src/main/java/org/apache/atlas/omrs/metadatahighway/cohortregistry/store/properties/MemberRegistration.java
new file mode 100644
index 0000000..4f43b0f
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/metadatahighway/cohortregistry/store/properties/MemberRegistration.java
@@ -0,0 +1,206 @@
+/*
+ * 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.metadatahighway.cohortregistry.store.properties;
+
+import org.apache.atlas.ocf.properties.Connection;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * MemberRegistration is a POJO for storing the information about a metadata repository that is a member
+ * of the open metadata repository cohort. This information is saved to disk by the
+ * OMRSCohortRegistryStore.
+ */
+public class MemberRegistration implements Serializable
+{
+ private static final long serialVersionUID = 1L;
+
+ /*
+ * Information about a metadata repository that is a member of the metadata repository cluster
+ */
+ private String metadataCollectionId = null;
+ private String serverName = null;
+ private String serverType = null;
+ private String organizationName = null;
+ private Date registrationTime = null;
+ private Connection repositoryConnection = null;
+
+
+ /**
+ * Default constructor - initialize registration information to null.
+ */
+ public MemberRegistration()
+ {
+ /*
+ * Nothing to do
+ */
+ }
+
+
+ /**
+ * Copy/clone constructor - copy registration information from the template.
+ *
+ * @param template - MemberRegistration properties to copy
+ */
+ public MemberRegistration(MemberRegistration template)
+ {
+ if (template != null)
+ {
+ metadataCollectionId = template.getMetadataCollectionId();
+ serverName = template.getServerName();
+ serverType = template.getServerType();
+ organizationName = template.getOrganizationName();
+ registrationTime = template.getRegistrationTime();
+ repositoryConnection = template.getRepositoryConnection();
+
+ }
+ }
+
+
+ /**
+ * Return the unique identifier of the repository's metadata collection id.
+ *
+ * @return String metadata collection id
+ */
+ public String getMetadataCollectionId() { return metadataCollectionId; }
+
+
+ /**
+ * Set up the unique identifier of the repository's metadata collection id.
+ *
+ * @param metadataCollectionId - String guid
+ */
+ public void setMetadataCollectionId(String metadataCollectionId) { this.metadataCollectionId = metadataCollectionId; }
+
+
+ /**
+ * Return the display name for the server. It is not guaranteed to be unique - just confusing for
+ * administrators if it is different. The display name can change over time with no loss of data integrity.
+ *
+ * @return String display name
+ */
+ public String getServerName()
+ {
+ return serverName;
+ }
+
+
+ /**
+ * Set up the display name for the server. It is not guaranteed to be unique - just confusing for
+ * administrators if it is different. The display name can change over time with no loss of data integrity.
+ *
+ * @param serverName - String display name
+ */
+ public void setServerName(String serverName)
+ {
+ this.serverName = serverName;
+ }
+
+
+ /**
+ * Return the type of server.
+ *
+ * @return String server type
+ */
+ public String getServerType()
+ {
+ return serverType;
+ }
+
+
+ /**
+ * Set up the type of server.
+ *
+ * @param serverType - String server type
+ */
+ public void setServerType(String serverType)
+ {
+ this.serverType = serverType;
+ }
+
+
+ /**
+ * Return the name of the organization.
+ *
+ * @return String name of the organization
+ */
+ public String getOrganizationName()
+ {
+ return organizationName;
+ }
+
+
+ /**
+ * Set up the name of the organization.
+ *
+ * @param organizationName - String name of the organization
+ */
+ public void setOrganizationName(String organizationName)
+ {
+ this.organizationName = organizationName;
+ }
+
+
+ /**
+ * Return the time that this repository registered with the cluster. (Or null if it has not yet registered.)
+ *
+ * @return Date object representing the registration time stamp
+ */
+ public Date getRegistrationTime()
+ {
+ return registrationTime;
+ }
+
+
+ /**
+ * Set up the time that this repository registered with the cluster. (Or null if it has not yet registered.)
+ *
+ * @param registrationTime - Date object representing the registration time stamp
+ */
+ public void setRegistrationTime(Date registrationTime) { this.registrationTime = registrationTime; }
+
+
+ /**
+ * Return the connection information for a connector that enables remote calls to the repository server.
+ *
+ * @return Connection object containing the properties of the connection
+ */
+ public Connection getRepositoryConnection()
+ {
+ if (repositoryConnection == null)
+ {
+ return repositoryConnection;
+ }
+ else
+ {
+ return new Connection(repositoryConnection);
+ }
+ }
+
+
+ /**
+ * Set up the connection information for a connector that enables remote calls to the repository server.
+ *
+ * @param repositoryConnection - Connection object containing the properties of the connection
+ */
+ public void setRepositoryConnection(Connection repositoryConnection)
+ {
+ this.repositoryConnection = repositoryConnection;
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/rest/repositoryconnector/OMRSRESTMetadataCollection.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/rest/repositoryconnector/OMRSRESTMetadataCollection.java b/omrs/src/main/java/org/apache/atlas/omrs/rest/repositoryconnector/OMRSRESTMetadataCollection.java
new file mode 100644
index 0000000..db48af7
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/rest/repositoryconnector/OMRSRESTMetadataCollection.java
@@ -0,0 +1,59 @@
+/*
+ * 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.rest.repositoryconnector;
+
+import org.apache.atlas.omrs.ffdc.exception.NotImplementedRuntimeException;
+import org.apache.atlas.omrs.metadatacollection.OMRSMetadataCollectionBase;
+
+/**
+ * The OMRSRESTMetadataCollection represents a remote metadata repository that supports the OMRS REST API.
+ * Requests to this metadata collection are translated one-for-one to requests to the remote repository since
+ * the OMRS REST API has a one-to-one correspondence with the metadata collection.
+ */
+/*
+ * This class is using OMRSMetadataCollectionBase while it is under construction. It will change to
+ * inheriting from OMRSMetadataCollection once it is implemented
+ */
+public class OMRSRESTMetadataCollection extends OMRSMetadataCollectionBase
+{
+ private OMRSRESTRepositoryConnector parentConnector = null;
+
+ /**
+ * Default constructor.
+ *
+ * @param parentConnector - connector that this metadata collection supports. The connector has the information
+ * to call the metadata repository.
+ * @param metadataCollectionId - unique identifier for the metadata collection
+ */
+ public OMRSRESTMetadataCollection(OMRSRESTRepositoryConnector parentConnector,
+ String metadataCollectionId)
+ {
+ super(metadataCollectionId);
+
+ /*
+ * Save parentConnector since this has the connection information.
+ */
+ this.parentConnector = parentConnector;
+
+ /*
+ * This is a temporary implementation to allow the structural implementation of the connectors to
+ * be committed before the metadata collection implementation is complete.
+ */
+ throw new NotImplementedRuntimeException("OMRSRESTMetadataCollection", "constructor", "ATLAS-1773");
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/rest/repositoryconnector/OMRSRESTRepositoryConnector.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/rest/repositoryconnector/OMRSRESTRepositoryConnector.java b/omrs/src/main/java/org/apache/atlas/omrs/rest/repositoryconnector/OMRSRESTRepositoryConnector.java
new file mode 100644
index 0000000..423e829
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/rest/repositoryconnector/OMRSRESTRepositoryConnector.java
@@ -0,0 +1,87 @@
+/*
+ * 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.rest.repositoryconnector;
+
+import org.apache.atlas.ocf.ffdc.ConnectorCheckedException;
+import org.apache.atlas.omrs.metadatacollection.repositoryconnector.OMRSRepositoryConnector;
+import org.apache.atlas.omrs.metadatacollection.OMRSMetadataCollection;
+
+/**
+ * The OMRSRESTRepositoryConnector is a connector to a remote Apache Atlas repository (or any other metadata repository
+ * that supports the OMRS REST APIs). This is the connector used by the EnterpriseOMRSRepositoryConnector to make a direct call
+ * to another open metadata repository.
+ */
+public class OMRSRESTRepositoryConnector extends OMRSRepositoryConnector
+{
+ private OMRSRESTMetadataCollection metadataCollection = null;
+ private String metadataCollectionId = null;
+
+
+ /**
+ * Default constructor used by the OCF Connector Provider.
+ */
+ public OMRSRESTRepositoryConnector()
+ {
+ /*
+ * Nothing to do (yet !)
+ */
+ }
+
+
+ /**
+ * Set up the unique Id for this metadata collection.
+ *
+ * @param metadataCollectionId - String unique Id
+ */
+ public void setMetadataCollectionId(String metadataCollectionId)
+ {
+ this.metadataCollectionId = metadataCollectionId;
+
+ /*
+ * Initialize the metadata collection only once the connector is properly set up.
+ */
+ metadataCollection = new OMRSRESTMetadataCollection(this, metadataCollectionId);
+ }
+
+
+ /**
+ * Returns the metadata collection object that provides an OMRS abstraction of the metadata within
+ * a metadata repository.
+ *
+ * @return OMRSMetadataCollection - metadata information retrieved from the metadata repository.
+ */
+ public OMRSMetadataCollection getMetadataCollection()
+ {
+ if (metadataCollection == null)
+ {
+ // TODO Throw exception since it means the local metadata collection id is not set up.
+ }
+ return metadataCollection;
+ }
+
+
+ /**
+ * Free up any resources held since the connector is no longer needed.
+ *
+ * @throws ConnectorCheckedException - there is a problem disconnecting the connector.
+ */
+ public void disconnect() throws ConnectorCheckedException
+ {
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/rest/repositoryconnector/OMRSRESTRepositoryConnectorProvider.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/rest/repositoryconnector/OMRSRESTRepositoryConnectorProvider.java b/omrs/src/main/java/org/apache/atlas/omrs/rest/repositoryconnector/OMRSRESTRepositoryConnectorProvider.java
new file mode 100644
index 0000000..f9c0a9f
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/rest/repositoryconnector/OMRSRESTRepositoryConnectorProvider.java
@@ -0,0 +1,44 @@
+/*
+ * 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.rest.repositoryconnector;
+
+import org.apache.atlas.omrs.metadatacollection.repositoryconnector.OMRSRepositoryConnectorProviderBase;
+
+/**
+ * In the Open Connector Framework (OCF), a ConnectorProvider is a factory for a specific type of connector.
+ * The OMRSRESTRepositoryConnectorProvider is the connector provider for the OMRSRESTRepositoryConnector.
+ * It extends OMRSRepositoryConnectorProviderBase which in turn extends the OCF ConnectorProviderBase.
+ * ConnectorProviderBase supports the creation of connector instances.
+ *
+ * The OMRSRESTRepositoryConnectorProvider must initialize ConnectorProviderBase with the Java class
+ * name of the OMRS Connector implementation (by calling super.setConnectorClassName(className)).
+ * Then the connector provider will work.
+ */
+public class OMRSRESTRepositoryConnectorProvider extends OMRSRepositoryConnectorProviderBase
+{
+ /**
+ * Constructor used to initialize the ConnectorProviderBase with the Java class name of the specific
+ * OMRS Connector implementation.
+ */
+ public OMRSRESTRepositoryConnectorProvider()
+ {
+ Class connectorClass = OMRSRESTRepositoryConnector.class;
+
+ super.setConnectorClassName(connectorClass.getName());
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/rest/server/OMRSRepositoryRESTServices.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/rest/server/OMRSRepositoryRESTServices.java b/omrs/src/main/java/org/apache/atlas/omrs/rest/server/OMRSRepositoryRESTServices.java
new file mode 100644
index 0000000..d53c795
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/rest/server/OMRSRepositoryRESTServices.java
@@ -0,0 +1,44 @@
+/*
+ * 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.rest.server;
+
+import org.apache.atlas.omrs.metadatacollection.repositoryconnector.OMRSRepositoryConnector;
+
+/**
+ * OMRSRepositoryRESTServices provides the server-side support for the OMRS Repository REST Services API.
+ * It is a minimal wrapper around the OMRSRepositoryConnector for the local server's metadata collection.
+ * If localRepositoryConnector is null when a REST calls is received, the request is rejected.
+ */
+public class OMRSRepositoryRESTServices
+{
+ //TODO remember to support getInstanceURL from TypeDefManager
+ public static OMRSRepositoryConnector localRepositoryConnector = null;
+
+
+ /**
+ * Set up the local repository connector that will service the REST Calls.
+ *
+ * @param localRepositoryConnector - link to the local repository responsible for servicing the REST calls.
+ * If localRepositoryConnector is null when a REST calls is received, the request
+ * is rejected.
+ */
+ public static void setLocalRepository(OMRSRepositoryConnector localRepositoryConnector)
+ {
+ OMRSRepositoryRESTServices.localRepositoryConnector = localRepositoryConnector;
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/topicconnectors/OMRSTopic.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/topicconnectors/OMRSTopic.java b/omrs/src/main/java/org/apache/atlas/omrs/topicconnectors/OMRSTopic.java
new file mode 100644
index 0000000..0fec97c
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/topicconnectors/OMRSTopic.java
@@ -0,0 +1,43 @@
+/*
+ * 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.topicconnectors;
+
+
+import org.apache.atlas.omrs.eventmanagement.events.v1.OMRSEventV1;
+
+/**
+ * OMRSTopic defines the interface to the messaging Topic for OMRS Events. It implemented by the OMTSTopicConnector.
+ */
+public interface OMRSTopic
+{
+ /**
+ * Register a listener object. This object will be supplied with all of the events
+ * received on the topic.
+ *
+ * @param newListener - object implementing the OMRSTopicListener interface
+ */
+ void registerListener(OMRSTopicListener newListener);
+
+
+ /**
+ * Sends the supplied event to the topic.
+ *
+ * @param event - OMRSEvent object containing the event properties.
+ */
+ void sendEvent(OMRSEventV1 event);
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/topicconnectors/OMRSTopicConnector.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/topicconnectors/OMRSTopicConnector.java b/omrs/src/main/java/org/apache/atlas/omrs/topicconnectors/OMRSTopicConnector.java
new file mode 100644
index 0000000..6cde7e6
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/topicconnectors/OMRSTopicConnector.java
@@ -0,0 +1,102 @@
+/*
+ * 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.topicconnectors;
+
+import org.apache.atlas.ocf.ConnectorBase;
+import org.apache.atlas.ocf.ffdc.ConnectorCheckedException;
+import org.apache.atlas.omrs.eventmanagement.events.v1.OMRSEventV1;
+
+import java.util.ArrayList;
+
+
+/**
+ * OMRSTopicConnector provides the support for the registration of listeners and the distribution of
+ * incoming events to the registered listeners. An implementation of the OMRSTopicConnector needs to
+ * extend this class to include the interaction with the eventing/messaging layer.
+ * <ul>
+ * <li>
+ * For inbound events it should call the protected distributeEvents() method.
+ * </li>
+ * <li>
+ * For outbound events, callers will invoke the sendEvent() method.
+ * </li>
+ * <li>
+ * When the server no longer needs the topic, it will call close().
+ * </li>
+ * </ul>
+ */
+public abstract class OMRSTopicConnector extends ConnectorBase implements OMRSTopic
+{
+ ArrayList<OMRSTopicListener> topicListeners = new ArrayList<>();
+
+ /**
+ * Simple constructor
+ */
+ public OMRSTopicConnector()
+ {
+ /*
+ * Nothing to do
+ */
+ }
+
+
+ /**
+ * Pass an event that has been received on the topic to each of the registered listeners.
+ *
+ * @param event - OMRSEvent to distribute
+ */
+ protected void distributeEvent(OMRSEventV1 event)
+ {
+ for (OMRSTopicListener topicListener : topicListeners)
+ {
+ try
+ {
+ topicListener.processEvent(event);
+ }
+ catch (Throwable error)
+ {
+ // TODO Need to log error
+ }
+ }
+ }
+
+
+ /**
+ * Register a listener object. This object will be supplied with all of the events received on the topic.
+ *
+ * @param topicListener - object implementing the OMRSTopicListener interface
+ */
+ public void registerListener(OMRSTopicListener topicListener)
+ {
+ if (topicListener != null)
+ {
+ topicListeners.add(topicListener);
+ }
+ }
+
+
+ /**
+ * Free up any resources held since the connector is no longer needed.
+ *
+ * @throws ConnectorCheckedException - there is a problem disconnecting the connector.
+ */
+ public void disconnect() throws ConnectorCheckedException
+ {
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/topicconnectors/OMRSTopicListener.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/topicconnectors/OMRSTopicListener.java b/omrs/src/main/java/org/apache/atlas/omrs/topicconnectors/OMRSTopicListener.java
new file mode 100644
index 0000000..89ab683
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/topicconnectors/OMRSTopicListener.java
@@ -0,0 +1,35 @@
+/*
+ * 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.topicconnectors;
+
+import org.apache.atlas.omrs.eventmanagement.events.v1.OMRSEventV1;
+
+
+/**
+ * OMRSTopicListener defines the interface that a listener must implement in order to receive events
+ * from the OMRSTopicConnector.
+ */
+public interface OMRSTopicListener
+{
+ /**
+ * Method to pass an event received on topic.
+ *
+ * @param event - inbound event
+ */
+ void processEvent(OMRSEventV1 event);
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/topicconnectors/kafka/KafkaOMRSTopicConnector.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/topicconnectors/kafka/KafkaOMRSTopicConnector.java b/omrs/src/main/java/org/apache/atlas/omrs/topicconnectors/kafka/KafkaOMRSTopicConnector.java
new file mode 100644
index 0000000..c9f0396
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/topicconnectors/kafka/KafkaOMRSTopicConnector.java
@@ -0,0 +1,55 @@
+/*
+ * 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.topicconnectors.kafka;
+
+import org.apache.atlas.ocf.ffdc.ConnectorCheckedException;
+import org.apache.atlas.omrs.eventmanagement.events.v1.OMRSEventV1;
+import org.apache.atlas.omrs.topicconnectors.OMRSTopicConnector;
+
+
+/**
+ * KafkaOMRSTopicConnector provides a concrete implementation of the OMRSTopicConnector that
+ * uses native Apache Kafka as the event/messaging infrastructure.
+ */
+public class KafkaOMRSTopicConnector extends OMRSTopicConnector
+{
+ public KafkaOMRSTopicConnector()
+ {
+ super();
+ }
+
+ /**
+ * Sends the supplied event to the topic.
+ *
+ * @param event - OMRSEvent object containing the event properties.
+ */
+ public void sendEvent(OMRSEventV1 event)
+ {
+ // TODO Needs implementation to connect to Kafka and send/receive events
+
+ }
+
+ /**
+ * Free up any resources held since the connector is no longer needed.
+ *
+ * @throws ConnectorCheckedException - there is a problem disconnecting the connector.
+ */
+ public void disconnect() throws ConnectorCheckedException
+ {
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/topicconnectors/kafka/KafkaOMRSTopicProvider.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/topicconnectors/kafka/KafkaOMRSTopicProvider.java b/omrs/src/main/java/org/apache/atlas/omrs/topicconnectors/kafka/KafkaOMRSTopicProvider.java
new file mode 100644
index 0000000..2297750
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/topicconnectors/kafka/KafkaOMRSTopicProvider.java
@@ -0,0 +1,38 @@
+/*
+ * 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.topicconnectors.kafka;
+
+import org.apache.atlas.ocf.ConnectorProviderBase;
+
+
+/**
+ * KafkaOMRSTopicProvider provides implementation of the connector provider for the KafkaOMRSTopicConnector.
+ */
+public class KafkaOMRSTopicProvider extends ConnectorProviderBase
+{
+ /**
+ * Constructor used to initialize the ConnectorProviderBase with the Java class name of the specific
+ * OMRS Connector implementation.
+ */
+ public KafkaOMRSTopicProvider()
+ {
+ Class connectorClass = KafkaOMRSTopicConnector.class;
+
+ super.setConnectorClassName(connectorClass.getName());
+ }
+}
[09/30] atlas git commit: ATLAS-2246: OMRS Connector API plus REST
and IGC Connector skeleton - 15th February 2018
Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositorycontentmanager/OMRSRepositoryHelper.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositorycontentmanager/OMRSRepositoryHelper.java b/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositorycontentmanager/OMRSRepositoryHelper.java
new file mode 100644
index 0000000..bd7fcbd
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositorycontentmanager/OMRSRepositoryHelper.java
@@ -0,0 +1,551 @@
+/*
+ * 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.localrepository.repositorycontentmanager;
+
+
+import org.apache.atlas.omrs.ffdc.OMRSErrorCode;
+import org.apache.atlas.omrs.ffdc.exception.OMRSLogicErrorException;
+import org.apache.atlas.omrs.ffdc.exception.PatchErrorException;
+import org.apache.atlas.omrs.metadatacollection.properties.instances.*;
+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.TypeDefPatch;
+
+import org.apache.atlas.omrs.ffdc.exception.TypeErrorException;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.UUID;
+
+/**
+ * OMRSRepositoryHelper provides methods to repository connectors and repository event mappers to help
+ * them build valid type definitions (TypeDefs), entities and relationships. It is a facade to the
+ * repository content manager which holds an in memory cache of all the active TypeDefs in the local server.
+ * OMRSRepositoryHelper's purpose is to create a object that the repository connectors and event mappers can
+ * create, use and discard without needing to know how to connect to the repository content manager.
+ */
+public class OMRSRepositoryHelper implements OMRSTypeDefHelper, OMRSInstanceHelper
+{
+ private static OMRSRepositoryContentManager repositoryContentManager = null;
+
+ /**
+ * Set up the local repository's content manager. This maintains a cache of the local repository's type
+ * definitions and rules to provide helpers and validators for TypeDefs and instances that are
+ * exchanged amongst the open metadata repositories and open metadata access services (OMAS).
+ *
+ * @param repositoryContentManager - link to repository content manager.
+ */
+ public static synchronized void setRepositoryContentManager(OMRSRepositoryContentManager repositoryContentManager)
+ {
+ OMRSRepositoryHelper.repositoryContentManager = repositoryContentManager;
+ }
+
+
+ /*
+ * ========================
+ * OMRSTypeDefHelper
+ */
+
+ /**
+ * Return the TypeDef identified by the name supplied by the caller. This is used in the connectors when
+ * validating the actual types of the repository with the known open metadata types - looking specifically
+ * for types of the same name but with different content.
+ *
+ * @param sourceName - source of the request (used for logging)
+ * @param typeDefName - unique name for the TypeDef
+ * @return TypeDef object or null if TypeDef is not known.
+ */
+ public TypeDef getTypeDefByName (String sourceName,
+ String typeDefName)
+ {
+ final String methodName = "getTypeDefByName()";
+
+ if (repositoryContentManager != null)
+ {
+ /*
+ * Delegate call to repository content manager.
+ */
+ return repositoryContentManager.getTypeDefByName(sourceName, typeDefName);
+ }
+ else
+ {
+ OMRSErrorCode errorCode = OMRSErrorCode.LOCAL_REPOSITORY_CONFIGURATION_ERROR;
+ String errorMessage = errorCode.getErrorMessageId()
+ + errorCode.getFormattedErrorMessage();
+
+ throw new OMRSLogicErrorException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ methodName,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+ }
+
+
+ /**
+ * Return the AttributeTypeDef identified by the name supplied by the caller. This is used in the connectors when
+ * validating the actual types of the repository with the known open metadata types - looking specifically
+ * for types of the same name but with different content.
+ *
+ * @param sourceName - source of the request (used for logging)
+ * @param attributeTypeDefName - unique name for the TypeDef
+ * @return AttributeTypeDef object or null if AttributeTypeDef is not known.
+ */
+ public AttributeTypeDef getAttributeTypeDefByName (String sourceName,
+ String attributeTypeDefName)
+ {
+ final String methodName = "getAttributeTypeDefByName()";
+
+ if (repositoryContentManager != null)
+ {
+ /*
+ * Delegate call to repository content manager.
+ */
+ return repositoryContentManager.getAttributeTypeDefByName(sourceName, attributeTypeDefName);
+ }
+ else
+ {
+ OMRSErrorCode errorCode = OMRSErrorCode.LOCAL_REPOSITORY_CONFIGURATION_ERROR;
+ String errorMessage = errorCode.getErrorMessageId()
+ + errorCode.getFormattedErrorMessage();
+
+ throw new OMRSLogicErrorException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ methodName,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+ }
+
+
+ /**
+ * Return the TypeDef identified by the guid and name supplied by the caller. This call is used when
+ * retrieving a type that should exist. For example, retrieving the type of a metadata instance.
+ *
+ * @param sourceName - source of the request (used for logging)
+ * @param typeDefGUID - unique identifier for the TypeDef
+ * @param typeDefName - unique name for the TypeDef
+ * @return TypeDef object
+ * @throws TypeErrorException - unknown or invalid type
+ */
+ public TypeDef getTypeDef (String sourceName,
+ String typeDefGUID,
+ String typeDefName) throws TypeErrorException
+ {
+ final String methodName = "getTypeDef()";
+
+ if (repositoryContentManager != null)
+ {
+ /*
+ * Delegate call to repository content manager.
+ */
+ return repositoryContentManager.getTypeDef(sourceName, typeDefGUID, typeDefName);
+ }
+ else
+ {
+ OMRSErrorCode errorCode = OMRSErrorCode.LOCAL_REPOSITORY_CONFIGURATION_ERROR;
+ String errorMessage = errorCode.getErrorMessageId()
+ + errorCode.getFormattedErrorMessage();
+
+ throw new OMRSLogicErrorException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ methodName,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+ }
+
+
+ /**
+ * Return the AttributeTypeDef identified by the guid and name supplied by the caller. This call is used when
+ * retrieving a type that should exist. For example, retrieving the type definition of a metadata instance's
+ * property.
+ *
+ * @param sourceName - source of the request (used for logging)
+ * @param attributeTypeDefGUID - unique identifier for the AttributeTypeDef
+ * @param attributeTypeDefName - unique name for the AttributeTypeDef
+ * @return TypeDef object
+ * @throws TypeErrorException - unknown or invalid type
+ */
+ public AttributeTypeDef getAttributeTypeDef (String sourceName,
+ String attributeTypeDefGUID,
+ String attributeTypeDefName) throws TypeErrorException
+ {
+ final String methodName = "getAttributeTypeDef()";
+
+ if (repositoryContentManager != null)
+ {
+ /*
+ * Delegate call to repository content manager.
+ */
+ return repositoryContentManager.getAttributeTypeDef(sourceName, attributeTypeDefGUID, attributeTypeDefName);
+ }
+ else
+ {
+ OMRSErrorCode errorCode = OMRSErrorCode.LOCAL_REPOSITORY_CONFIGURATION_ERROR;
+ String errorMessage = errorCode.getErrorMessageId()
+ + errorCode.getFormattedErrorMessage();
+
+ throw new OMRSLogicErrorException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ methodName,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+ }
+
+
+ /**
+ * Returns an updated TypeDef that has had the supplied patch applied. It throws an exception if any part of
+ * the patch is incompatible with the original TypeDef. For example, if there is a mismatch between
+ * the type or version that either represents.
+ *
+ * @param sourceName - source of the request (used for logging)
+ * @param typeDefPatch - patch to apply
+ * @return updated TypeDef
+ * @throws PatchErrorException - the patch is either badly formatted, or does not apply to the supplied TypeDef
+ */
+ public TypeDef applyPatch(String sourceName, TypeDefPatch typeDefPatch) throws PatchErrorException
+ {
+ final String methodName = "applyPatch()";
+
+ if (repositoryContentManager != null)
+ {
+ /*
+ * Delegate call to repository content manager.
+ */
+ return repositoryContentManager.applyPatch(sourceName, typeDefPatch);
+ }
+ else
+ {
+ OMRSErrorCode errorCode = OMRSErrorCode.LOCAL_REPOSITORY_CONFIGURATION_ERROR;
+ String errorMessage = errorCode.getErrorMessageId()
+ + errorCode.getFormattedErrorMessage();
+
+ throw new OMRSLogicErrorException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ methodName,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+ }
+
+
+ /*
+ * ======================
+ * OMRSInstanceHelper
+ */
+
+
+ /**
+ * Return an entity with the header and type information filled out. The caller only needs to add properties
+ * and classifications to complete the set up of the entity.
+ *
+ * @param sourceName - source of the request (used for logging)
+ * @param metadataCollectionId - unique identifier for the home metadata collection
+ * @param provenanceType - origin of the entity
+ * @param userName - name of the creator
+ * @param typeName - name of the type
+ * @return partially filled out entity - needs classifications and properties
+ * @throws TypeErrorException - the type name is not recognized.
+ */
+ public EntityDetail getSkeletonEntity(String sourceName,
+ String metadataCollectionId,
+ InstanceProvenanceType provenanceType,
+ String userName,
+ String typeName) throws TypeErrorException
+ {
+ final String methodName = "getSkeletonEntity()";
+
+ if (repositoryContentManager != null)
+ {
+ EntityDetail entity = new EntityDetail();
+ String guid = UUID.randomUUID().toString();
+
+ entity.setInstanceProvenanceType(provenanceType);
+ entity.setMetadataCollectionId(metadataCollectionId);
+ entity.setCreateTime(new Date());
+ entity.setGUID(guid);
+ entity.setVersion(1L);
+
+ entity.setType(repositoryContentManager.getInstanceType(sourceName, TypeDefCategory.ENTITY_DEF, typeName));
+ entity.setStatus(repositoryContentManager.getInitialStatus(sourceName, typeName));
+ entity.setCreatedBy(userName);
+ entity.setInstanceURL(repositoryContentManager.getInstanceURL(sourceName, guid));
+
+ return entity;
+ }
+ else
+ {
+ OMRSErrorCode errorCode = OMRSErrorCode.LOCAL_REPOSITORY_CONFIGURATION_ERROR;
+ String errorMessage = errorCode.getErrorMessageId()
+ + errorCode.getFormattedErrorMessage();
+
+ throw new OMRSLogicErrorException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ methodName,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+ }
+
+
+ /**
+ * Return a classification with the header and type information filled out. The caller only needs to add properties
+ * and possibility origin information if it is propagated to complete the set up of the classification.
+ *
+ * @param sourceName - source of the request (used for logging)
+ * @param userName - name of the creator
+ * @param classificationTypeName - name of the classification type
+ * @param entityTypeName - name of the type for the entity that this classification is to be attached to.
+ * @return partially filled out classification - needs properties and possibly origin information
+ * @throws TypeErrorException - the type name is not recognized as a classification type.
+ */
+ public Classification getSkeletonClassification(String sourceName,
+ String userName,
+ String classificationTypeName,
+ String entityTypeName) throws TypeErrorException
+ {
+ final String methodName = "getSkeletonClassification()";
+
+ if (repositoryContentManager != null)
+ {
+ if (repositoryContentManager.isValidTypeCategory(sourceName,
+ TypeDefCategory.CLASSIFICATION_DEF,
+ classificationTypeName))
+ {
+ if (repositoryContentManager.isValidClassificationForEntity(sourceName,
+ classificationTypeName,
+ entityTypeName))
+ {
+ Classification classification = new Classification();
+
+ classification.setName(classificationTypeName);
+ classification.setCreateTime(new Date());
+ classification.setCreatedBy(userName);
+ classification.setVersion(1L);
+ classification.setStatus(repositoryContentManager.getInitialStatus(sourceName,
+ classificationTypeName));
+
+ return classification;
+ }
+ else
+ {
+ OMRSErrorCode errorCode = OMRSErrorCode.INVALID_CLASSIFICATION_FOR_ENTITY;
+ String errorMessage = errorCode.getErrorMessageId()
+ + errorCode.getFormattedErrorMessage(classificationTypeName, entityTypeName);
+
+ throw new TypeErrorException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ methodName,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+ }
+ else
+ {
+ OMRSErrorCode errorCode = OMRSErrorCode.UNKNOWN_CLASSIFICATION;
+ String errorMessage = errorCode.getErrorMessageId()
+ + errorCode.getFormattedErrorMessage(classificationTypeName);
+
+ throw new TypeErrorException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ methodName,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+ }
+ else
+ {
+ OMRSErrorCode errorCode = OMRSErrorCode.LOCAL_REPOSITORY_CONFIGURATION_ERROR;
+ String errorMessage = errorCode.getErrorMessageId()
+ + errorCode.getFormattedErrorMessage();
+
+ throw new OMRSLogicErrorException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ methodName,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+ }
+
+
+ /**
+ * Return a relationship with the header and type information filled out. The caller only needs to add properties
+ * to complete the set up of the relationship.
+ *
+ * @param sourceName - source of the request (used for logging)
+ * @param metadataCollectionId - unique identifier for the home metadata collection
+ * @param provenanceType - origin type of the relationship
+ * @param userName - name of the creator
+ * @param typeName - name of the relationship's type
+ * @return partially filled out relationship - needs properties
+ * @throws TypeErrorException - the type name is not recognized as a relationship type.
+ */
+ public Relationship getSkeletonRelationship(String sourceName,
+ String metadataCollectionId,
+ InstanceProvenanceType provenanceType,
+ String userName,
+ String typeName) throws TypeErrorException
+ {
+ final String methodName = "getSkeletonRelationship()";
+
+
+ if (repositoryContentManager != null)
+ {
+ Relationship relationship = new Relationship();
+ String guid = UUID.randomUUID().toString();
+
+ relationship.setInstanceProvenanceType(provenanceType);
+ relationship.setMetadataCollectionId(metadataCollectionId);
+ relationship.setCreateTime(new Date());
+ relationship.setGUID(guid);
+ relationship.setVersion(1L);
+
+ relationship.setType(repositoryContentManager.getInstanceType(sourceName,
+ TypeDefCategory.RELATIONSHIP_DEF,
+ typeName));
+ relationship.setStatus(repositoryContentManager.getInitialStatus(sourceName, typeName));
+ relationship.setCreatedBy(userName);
+ relationship.setInstanceURL(repositoryContentManager.getInstanceURL(sourceName, guid));
+
+ return relationship;
+ }
+ else
+ {
+ OMRSErrorCode errorCode = OMRSErrorCode.LOCAL_REPOSITORY_CONFIGURATION_ERROR;
+ String errorMessage = errorCode.getErrorMessageId()
+ + errorCode.getFormattedErrorMessage();
+
+ throw new OMRSLogicErrorException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ methodName,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+ }
+
+
+ /**
+ * Return a filled out entity. It just needs to add the classifications.
+ *
+ * @param sourceName - source of the request (used for logging)
+ * @param metadataCollectionId - unique identifier for the home metadata collection
+ * @param provenanceType - origin of the entity
+ * @param userName - name of the creator
+ * @param typeName - name of the type
+ * @param properties - properties for the entity
+ * @param classifications - list of classifications for the entity
+ * @return an entity that is filled out
+ * @throws TypeErrorException - the type name is not recognized as an entity type
+ */
+ public EntityDetail getNewEntity(String sourceName,
+ String metadataCollectionId,
+ InstanceProvenanceType provenanceType,
+ String userName,
+ String typeName,
+ InstanceProperties properties,
+ ArrayList<Classification> classifications) throws TypeErrorException
+ {
+ EntityDetail entity = this.getSkeletonEntity(sourceName,
+ metadataCollectionId,
+ provenanceType,
+ userName,
+ typeName);
+
+ entity.setProperties(properties);
+ entity.setClassifications(classifications);
+
+ return entity;
+ }
+
+
+ /**
+ * Return a filled out relationship.
+ *
+ * @param sourceName - source of the request (used for logging)
+ * @param metadataCollectionId - unique identifier for the home metadata collection
+ * @param provenanceType - origin of the relationship
+ * @param userName - name of the creator
+ * @param typeName - name of the type
+ * @param properties - properties for the relationship
+ * @return a relationship that is filled out
+ * @throws TypeErrorException - the type name is not recognized as a relationship type
+ */
+ public Relationship getNewRelationship(String sourceName,
+ String metadataCollectionId,
+ InstanceProvenanceType provenanceType,
+ String userName,
+ String typeName,
+ InstanceProperties properties) throws TypeErrorException
+ {
+ Relationship relationship = this.getSkeletonRelationship(sourceName,
+ metadataCollectionId,
+ provenanceType,
+ userName,
+ typeName);
+
+ relationship.setProperties(properties);
+
+ return relationship;
+ }
+
+
+ /**
+ * Return a classification with the header and type information filled out. The caller only needs to add properties
+ * to complete the set up of the classification.
+ *
+ * @param sourceName - source of the request (used for logging)
+ * @param userName - name of the creator
+ * @param typeName - name of the type
+ * @param entityTypeName - name of the type for the entity that this classification is to be attached to.
+ * @param properties - properties for the classification
+ * @return partially filled out classification - needs properties and possibly origin information
+ * @throws TypeErrorException - the type name is not recognized as a classification type.
+ */
+ public Classification getNewClassification(String sourceName,
+ String userName,
+ String typeName,
+ String entityTypeName,
+ ClassificationOrigin classificationOrigin,
+ String classificationOriginGUID,
+ InstanceProperties properties) throws TypeErrorException
+ {
+ Classification classification = this.getSkeletonClassification(sourceName,
+ userName,
+ typeName,
+ entityTypeName);
+
+ classification.setClassificationOrigin(classificationOrigin);
+ classification.setClassificationOriginGUID(classificationOriginGUID);
+ classification.setProperties(properties);
+
+ return classification;
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositorycontentmanager/OMRSRepositoryValidator.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositorycontentmanager/OMRSRepositoryValidator.java b/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositorycontentmanager/OMRSRepositoryValidator.java
new file mode 100644
index 0000000..6a73a9d
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositorycontentmanager/OMRSRepositoryValidator.java
@@ -0,0 +1,529 @@
+/*
+ * 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.localrepository.repositorycontentmanager;
+
+import org.apache.atlas.omrs.ffdc.OMRSErrorCode;
+import org.apache.atlas.omrs.ffdc.exception.OMRSLogicErrorException;
+import org.apache.atlas.omrs.metadatacollection.properties.instances.EntityDetail;
+import org.apache.atlas.omrs.metadatacollection.properties.instances.InstanceType;
+import org.apache.atlas.omrs.metadatacollection.properties.instances.Relationship;
+import org.apache.atlas.omrs.metadatacollection.properties.typedefs.TypeDef;
+import org.apache.atlas.omrs.metadatacollection.properties.typedefs.TypeDefCategory;
+import org.apache.atlas.omrs.metadatacollection.properties.typedefs.TypeDefSummary;
+
+import java.util.ArrayList;
+
+/**
+ * OMRSRepositoryValidator provides methods to validate TypeDefs and Instances returned from
+ * an open metadata repository. An instance can be created by any OMRS component, or OMRS adapter and
+ * it will connect to the local repository's content manager to access the local type definitions (TypeDefs)
+ * and rules.
+ */
+public class OMRSRepositoryValidator implements OMRSTypeDefValidator, OMRSInstanceValidator
+{
+ private static OMRSRepositoryContentManager repositoryContentManager = null;
+
+ /**
+ * Set up the local repository's content manager. This maintains a cache of the local repository's type
+ * definitions and rules to provide helpers and validators for TypeDefs and instances that are
+ * exchanged amongst the open metadata repositories and open metadata access services (OMAS).
+ *
+ * @param repositoryContentManager - link to repository content manager.
+ */
+ public static synchronized void setRepositoryContentManager(OMRSRepositoryContentManager repositoryContentManager)
+ {
+ OMRSRepositoryHelper.setRepositoryContentManager(repositoryContentManager);
+ }
+
+
+ /**
+ * Return a summary list of the TypeDefs supported by the local metadata repository. This is
+ * broadcast to the other servers/repositories in the cluster during the membership registration exchanges
+ * managed by the cluster registries.
+ *
+ * @return TypeDefSummary iterator
+ */
+ public ArrayList<TypeDefSummary> getLocalTypeDefs()
+ {
+ final String methodName = "getLocalTypeDefs()";
+
+ if (repositoryContentManager != null)
+ {
+ return repositoryContentManager.getLocalTypeDefs();
+ }
+ else
+ {
+ OMRSErrorCode errorCode = OMRSErrorCode.LOCAL_REPOSITORY_CONFIGURATION_ERROR;
+ String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage();
+
+ throw new OMRSLogicErrorException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ methodName,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+
+ }
+
+
+ /**
+ * Return a boolean flag indicating whether the list of TypeDefs passed are compatible with the
+ * local metadata repository. A true response means it is ok; false means conflicts have been found.
+ *
+ * A valid TypeDef is one that:
+ * <ul>
+ * <li>
+ * Matches name, GUID and version to a TypeDef in the local repository, or
+ * </li>
+ * <li>
+ * Is not defined in the local repository.
+ * </li>
+ * </ul>
+ *
+ * @param sourceName - name of the caller
+ * @param typeDefSummaries - list of summary information about the TypeDefs.
+ */
+ public void validateAgainstLocalTypeDefs(String sourceName,
+ ArrayList<TypeDefSummary> typeDefSummaries)
+ {
+ final String methodName = "validateAgainstLocalTypeDefs()";
+
+ if (repositoryContentManager != null)
+ {
+ repositoryContentManager.validateAgainstLocalTypeDefs(sourceName, typeDefSummaries);
+ }
+ else
+ {
+ OMRSErrorCode errorCode = OMRSErrorCode.LOCAL_REPOSITORY_CONFIGURATION_ERROR;
+ String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage();
+
+ throw new OMRSLogicErrorException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ methodName,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+ }
+
+
+ /**
+ * Return a boolean flag indicating whether the list of TypeDefs passed are compatible with the
+ * all known typedefs.
+ *
+ * A valid TypeDef is one that matches name, GUID and version to the full list of TypeDefs.
+ * If a new TypeDef is present, it is added to the enterprise list.
+ *
+ * @param typeDefs - list of TypeDefs.
+ * @return boolean flag
+ */
+ public boolean validateEnterpriseTypeDefs(String sourceName,
+ ArrayList<TypeDef> typeDefs)
+ {
+ final String methodName = "validateEnterpriseTypeDefs()";
+
+ if (repositoryContentManager != null)
+ {
+ return repositoryContentManager.validateEnterpriseTypeDefs(sourceName, typeDefs);
+ }
+ else
+ {
+ OMRSErrorCode errorCode = OMRSErrorCode.LOCAL_REPOSITORY_CONFIGURATION_ERROR;
+ String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage();
+
+ throw new OMRSLogicErrorException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ methodName,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+ }
+
+
+ /**
+ * Return boolean indicating whether the TypeDef is in use in the repository.
+ *
+ * @param sourceName - name of caller
+ * @param typeDefGUID - unique identifier of the type
+ * @param typeDefName - unique name of the type
+ * @return boolean flag
+ */
+ public boolean isActiveType(String sourceName, String typeDefGUID, String typeDefName)
+ {
+ final String methodName = "isActiveType()";
+
+ if (repositoryContentManager != null)
+ {
+ return repositoryContentManager.isActiveType(sourceName, typeDefGUID, typeDefName);
+ }
+ else
+ {
+ OMRSErrorCode errorCode = OMRSErrorCode.LOCAL_REPOSITORY_CONFIGURATION_ERROR;
+ String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage();
+
+ throw new OMRSLogicErrorException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ methodName,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+ }
+
+ /**
+ * Return boolean indicating whether the TypeDef is one of the open metadata types.
+ *
+ * @param sourceName - name of caller
+ * @param typeDefGUID - unique identifier of the type
+ * @param typeDefName - unique name of the type
+ * @return boolean flag
+ */
+ public boolean isOpenType(String sourceName, String typeDefGUID, String typeDefName)
+ {
+ final String methodName = "isOpenType()";
+
+ if (repositoryContentManager != null)
+ {
+ return repositoryContentManager.isOpenType(sourceName, typeDefGUID, typeDefName);
+ }
+ else
+ {
+ OMRSErrorCode errorCode = OMRSErrorCode.LOCAL_REPOSITORY_CONFIGURATION_ERROR;
+ String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage();
+
+ throw new OMRSLogicErrorException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ methodName,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+ }
+
+
+ /**
+ * Return boolean indicating whether the TypeDef is in use in the repository.
+ *
+ * @param sourceName - name of caller
+ * @param typeDefGUID - unique identifier of the type
+ * @param typeDefName - unique name of the type
+ * @return boolean flag
+ */
+ public boolean isKnownType(String sourceName, String typeDefGUID, String typeDefName)
+ {
+ final String methodName = "isKnownType()";
+
+ if (repositoryContentManager != null)
+ {
+ return repositoryContentManager.isKnownType(sourceName, typeDefGUID, typeDefName);
+ }
+ else
+ {
+ OMRSErrorCode errorCode = OMRSErrorCode.LOCAL_REPOSITORY_CONFIGURATION_ERROR;
+ String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage();
+
+ throw new OMRSLogicErrorException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ methodName,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+ }
+
+
+ /**
+ * Return boolean indicating whether the TypeDef identifiers are from a single known type or not.
+ *
+ * @param sourceName - source of the request (used for logging)
+ * @param typeDefGUID - unique identifier of the TypeDef
+ * @param typeDefName - unique name of the TypeDef
+ * @return boolean result
+ */
+ public boolean validTypeId(String sourceName,
+ String typeDefGUID,
+ String typeDefName)
+ {
+ final String methodName = "validTypeId()";
+
+ if (repositoryContentManager != null)
+ {
+ return repositoryContentManager.validTypeId(sourceName,
+ typeDefGUID,
+ typeDefName);
+ }
+ else
+ {
+ OMRSErrorCode errorCode = OMRSErrorCode.LOCAL_REPOSITORY_CONFIGURATION_ERROR;
+ String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage();
+
+ throw new OMRSLogicErrorException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ methodName,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+ }
+
+
+ /**
+ * Return boolean indicating whether the TypeDef identifiers are from a single known type or not.
+ *
+ * @param sourceName - source of the request (used for logging)
+ * @param typeDefGUID - unique identifier of the TypeDef
+ * @param typeDefName - unique name of the TypeDef
+ * @param category - category for the TypeDef
+ * @return boolean result
+ */
+ public boolean validTypeId(String sourceName,
+ String typeDefGUID,
+ String typeDefName,
+ TypeDefCategory category)
+ {
+ final String methodName = "validTypeId()";
+
+ if (repositoryContentManager != null)
+ {
+ return repositoryContentManager.validTypeId(sourceName,
+ typeDefGUID,
+ typeDefName,
+ category);
+ }
+ else
+ {
+ OMRSErrorCode errorCode = OMRSErrorCode.LOCAL_REPOSITORY_CONFIGURATION_ERROR;
+ String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage();
+
+ throw new OMRSLogicErrorException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ methodName,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+ }
+
+
+ /**
+ * Return boolean indicating whether the TypeDef identifiers are from a single known type or not.
+ *
+ * @param sourceName - source of the request (used for logging)
+ * @param typeDefGUID - unique identifier of the TypeDef
+ * @param typeDefName - unique name of the TypeDef
+ * @param typeDefVersion - versionName of the type
+ * @param category - category for the TypeDef
+ * @return boolean result
+ */
+ public boolean validTypeId(String sourceName,
+ String typeDefGUID,
+ String typeDefName,
+ long typeDefVersion,
+ TypeDefCategory category)
+ {
+ final String methodName = "validTypeId()";
+
+ if (repositoryContentManager != null)
+ {
+ return repositoryContentManager.validTypeId(sourceName,
+ typeDefGUID,
+ typeDefName,
+ typeDefVersion,
+ category);
+ }
+ else
+ {
+ OMRSErrorCode errorCode = OMRSErrorCode.LOCAL_REPOSITORY_CONFIGURATION_ERROR;
+ String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage();
+
+ throw new OMRSLogicErrorException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ methodName,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+ }
+
+
+ /**
+ * Return boolean indicating whether the supplied TypeDef is valid or not.
+ *
+ * @param sourceName - source of the TypeDef (used for logging)
+ * @param typeDef - TypeDef to test
+ * @return boolean result
+ */
+ public boolean validTypeDef(String sourceName,
+ TypeDef typeDef)
+ {
+ final String methodName = "validTypeDef()";
+
+ if (repositoryContentManager != null)
+ {
+ return repositoryContentManager.validTypeDef(sourceName, typeDef);
+ }
+ else
+ {
+ OMRSErrorCode errorCode = OMRSErrorCode.LOCAL_REPOSITORY_CONFIGURATION_ERROR;
+ String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage();
+
+ throw new OMRSLogicErrorException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ methodName,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+ }
+
+
+ /**
+ * Return boolean indicating whether the supplied TypeDefSummary is valid or not.
+ *
+ * @param sourceName - source of the TypeDefSummary (used for logging)
+ * @param typeDefSummary - TypeDefSummary to test.
+ * @return boolean result.
+ */
+ public boolean validTypeDefSummary(String sourceName,
+ TypeDefSummary typeDefSummary)
+ {
+ final String methodName = "validTypeDefSummary()";
+
+ if (repositoryContentManager != null)
+ {
+ return repositoryContentManager.validTypeDefSummary(sourceName, typeDefSummary);
+ }
+ else
+ {
+ OMRSErrorCode errorCode = OMRSErrorCode.LOCAL_REPOSITORY_CONFIGURATION_ERROR;
+ String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage();
+
+ throw new OMRSLogicErrorException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ methodName,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+ }
+
+
+ /**
+ * Test that the supplied entity is valid.
+ *
+ * @param sourceName - source of the entity (used for logging)
+ * @param entity - entity to test
+ * @return boolean result
+ */
+ public boolean validEntity(String sourceName,
+ EntityDetail entity)
+ {
+ final String methodName = "validEntity()";
+
+ if (repositoryContentManager != null)
+ {
+ return repositoryContentManager.validEntity(sourceName, entity);
+ }
+ else
+ {
+ OMRSErrorCode errorCode = OMRSErrorCode.LOCAL_REPOSITORY_CONFIGURATION_ERROR;
+ String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage();
+
+ throw new OMRSLogicErrorException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ methodName,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+ }
+
+
+ /**
+ * Test that the supplied relationship is valid.
+ *
+ * @param sourceName - name of the caller (used for logging)
+ * @param relationship - relationship to test
+ * @return boolean result
+ */
+ public boolean validRelationship(String sourceName,
+ Relationship relationship)
+ {
+ final String methodName = "validRelationship()";
+
+ if (repositoryContentManager != null)
+ {
+ return repositoryContentManager.validRelationship(sourceName, relationship);
+ }
+ else
+ {
+ OMRSErrorCode errorCode = OMRSErrorCode.LOCAL_REPOSITORY_CONFIGURATION_ERROR;
+ String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage();
+
+ throw new OMRSLogicErrorException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ methodName,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+ }
+
+
+ /**
+ * Verify that the identifiers for an instance are correct.
+ *
+ * @param sourceName - source of the instance (used for logging)
+ * @param typeDefGUID - unique identifier for the type.
+ * @param typeDefName - unique name for the type.
+ * @param category - expected category of the instance.
+ * @param instanceGUID - unique identifier for the instance.
+ * @return boolean indicating whether the identifiers are ok.
+ */
+ public boolean validInstanceId(String sourceName,
+ String typeDefGUID,
+ String typeDefName,
+ TypeDefCategory category,
+ String instanceGUID)
+ {
+ final String methodName = "validInstanceId()";
+
+ if (repositoryContentManager != null)
+ {
+ return repositoryContentManager.validInstanceId(sourceName,
+ typeDefGUID,
+ typeDefName,
+ category,
+ instanceGUID);
+ }
+ else
+ {
+ OMRSErrorCode errorCode = OMRSErrorCode.LOCAL_REPOSITORY_CONFIGURATION_ERROR;
+ String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage();
+
+ throw new OMRSLogicErrorException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ methodName,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositorycontentmanager/OMRSTypeDefHelper.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositorycontentmanager/OMRSTypeDefHelper.java b/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositorycontentmanager/OMRSTypeDefHelper.java
new file mode 100644
index 0000000..113393b
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositorycontentmanager/OMRSTypeDefHelper.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.localrepository.repositorycontentmanager;
+
+import org.apache.atlas.omrs.ffdc.exception.PatchErrorException;
+import org.apache.atlas.omrs.ffdc.exception.TypeErrorException;
+import org.apache.atlas.omrs.metadatacollection.properties.instances.InstanceType;
+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;
+
+/**
+ * OMRSTypeDefHelper provides methods for manipulating TypeDefs and creating metadata instances with the correct TypeDef
+ * headers
+ */
+public interface OMRSTypeDefHelper
+{
+ /**
+ * Return the TypeDef identified by the name supplied by the caller. This is used in the connectors when
+ * validating the actual types of the repository with the known open metadata types - looking specifically
+ * for types of the same name but with different content.
+ *
+ * @param sourceName - source of the request (used for logging)
+ * @param typeDefName - unique name for the TypeDef
+ * @return TypeDef object or null if TypeDef is not known.
+ */
+ TypeDef getTypeDefByName (String sourceName,
+ String typeDefName);
+
+
+ /**
+ * Return the AttributeTypeDef identified by the name supplied by the caller. This is used in the connectors when
+ * validating the actual types of the repository with the known open metadata types - looking specifically
+ * for types of the same name but with different content.
+ *
+ * @param sourceName - source of the request (used for logging)
+ * @param attributeTypeDefName - unique name for the TypeDef
+ * @return AttributeTypeDef object or null if AttributeTypeDef is not known.
+ */
+ AttributeTypeDef getAttributeTypeDefByName (String sourceName,
+ String attributeTypeDefName);
+
+
+ /**
+ * Return the TypeDef identified by the guid and name supplied by the caller. This call is used when
+ * retrieving a type that should exist. For example, retrieving the type of a metadata instance.
+ *
+ * @param sourceName - source of the request (used for logging)
+ * @param typeDefGUID - unique identifier for the TypeDef
+ * @param typeDefName - unique name for the TypeDef
+ * @return TypeDef object
+ * @throws TypeErrorException - unknown or invalid type
+ */
+ TypeDef getTypeDef (String sourceName,
+ String typeDefGUID,
+ String typeDefName) throws TypeErrorException;
+
+
+ /**
+ * Return the AttributeTypeDef identified by the guid and name supplied by the caller. This call is used when
+ * retrieving a type that should exist. For example, retrieving the type definition of a metadata instance's
+ * property.
+ *
+ * @param sourceName - source of the request (used for logging)
+ * @param attributeTypeDefGUID - unique identifier for the AttributeTypeDef
+ * @param attributeTypeDefName - unique name for the AttributeTypeDef
+ * @return TypeDef object
+ * @throws TypeErrorException - unknown or invalid type
+ */
+ AttributeTypeDef getAttributeTypeDef (String sourceName,
+ String attributeTypeDefGUID,
+ String attributeTypeDefName) throws TypeErrorException;
+
+
+ /**
+ * Returns an updated TypeDef that has had the supplied patch applied. It throws an exception if any part of
+ * the patch is incompatible with the original TypeDef. For example, if there is a mismatch between
+ * the type or version that either represents.
+ *
+ * @param sourceName - source of the request (used for logging)
+ * @param typeDefPatch - patch to apply
+ * @return updated TypeDef
+ * @throws PatchErrorException - the patch is either badly formatted, or does not apply to the supplied TypeDef
+ */
+ TypeDef applyPatch(String sourceName, TypeDefPatch typeDefPatch) throws PatchErrorException;
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositorycontentmanager/OMRSTypeDefManager.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositorycontentmanager/OMRSTypeDefManager.java b/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositorycontentmanager/OMRSTypeDefManager.java
new file mode 100644
index 0000000..34bc02a
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositorycontentmanager/OMRSTypeDefManager.java
@@ -0,0 +1,181 @@
+/*
+ * 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.localrepository.repositorycontentmanager;
+
+import org.apache.atlas.omrs.ffdc.exception.TypeErrorException;
+import org.apache.atlas.omrs.metadatacollection.properties.instances.InstanceStatus;
+import org.apache.atlas.omrs.metadatacollection.properties.instances.InstanceType;
+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;
+
+
+/**
+ * OMRSTypeDefManager provides maintenance methods for managing the TypeDefs in the local cache and supporting
+ * the OMRSInstanceHelper to build instances that respect their type definition (TypeDef).
+ */
+public interface OMRSTypeDefManager
+{
+ /**
+ * Cache a definition of a new TypeDef.
+ *
+ * @param sourceName - source of the request (used for logging)
+ * @param newTypeDef - TypeDef structure describing the new TypeDef.
+ */
+ void addTypeDef(String sourceName, TypeDef newTypeDef);
+
+
+ /**
+ * Cache a definition of a new AttributeTypeDef.
+ *
+ * @param sourceName - source of the request (used for logging)
+ * @param newAttributeTypeDef - AttributeTypeDef structure describing the new TypeDef.
+ */
+ void addAttributeTypeDef(String sourceName, AttributeTypeDef newAttributeTypeDef);
+
+
+ /**
+ * Update one or more properties of a cached TypeDef.
+ *
+ * @param sourceName - source of the request (used for logging)
+ * @param typeDef - TypeDef structure.
+ */
+ void updateTypeDef(String sourceName, TypeDef typeDef);
+
+
+ /**
+ * Delete a cached TypeDef.
+ *
+ * @param sourceName - source of the request (used for logging)
+ * @param obsoleteTypeDefGUID - String unique identifier for the TypeDef.
+ * @param obsoleteTypeDefName - String unique name for the TypeDef.
+ */
+ void deleteTypeDef(String sourceName,
+ String obsoleteTypeDefGUID,
+ String obsoleteTypeDefName);
+
+
+ /**
+ * Delete a cached AttributeTypeDef.
+ *
+ * @param sourceName - source of the request (used for logging)
+ * @param obsoleteTypeDefGUID - String unique identifier for the AttributeTypeDef.
+ * @param obsoleteTypeDefName - String unique name for the AttributeTypeDef.
+ */
+ void deleteAttributeTypeDef(String sourceName,
+ String obsoleteTypeDefGUID,
+ String obsoleteTypeDefName);
+
+
+ /**
+ * Change the identifiers for a TypeDef.
+ *
+ * @param sourceName - source of the request (used for logging).
+ * @param originalTypeDefGUID - TypeDef's original unique identifier.
+ * @param originalTypeDefName - TypeDef's original unique name.
+ * @param newTypeDef - updated TypeDef with new identifiers.
+ */
+ void reIdentifyTypeDef(String sourceName,
+ String originalTypeDefGUID,
+ String originalTypeDefName,
+ TypeDef newTypeDef);
+
+
+ /**
+ * Change the identifiers for an AttributeTypeDef.
+ *
+ * @param sourceName - source of the request (used for logging).
+ * @param originalAttributeTypeDefGUID - AttributeTypeDef's original unique identifier.
+ * @param originalAttributeTypeDefName - AttributeTypeDef's original unique name.
+ * @param newAttributeTypeDef - updated AttributeTypeDef with new identifiers
+ */
+ void reIdentifyAttributeTypeDef(String sourceName,
+ String originalAttributeTypeDefGUID,
+ String originalAttributeTypeDefName,
+ AttributeTypeDef newAttributeTypeDef);
+
+
+ /**
+ * Return a boolean indicating that the type name matches the category.
+ *
+ * @param sourceName - source of the request (used for logging)
+ * @param category - TypeDefCategory enum value to test
+ * @param typeName - type name to test
+ * @return - boolean flag indicating that the type name is of the specified category
+ * @throws TypeErrorException - the type name is not a recognized type or the category is incorrect or there
+ * is an error in the type definition (TypeDef) cached.
+ */
+ boolean isValidTypeCategory(String sourceName,
+ TypeDefCategory category,
+ String typeName) throws TypeErrorException;
+
+
+ /**
+ * Return boolean indicating if a classification type can be applied to a specified entity. This
+ * uses the list of valid entity types located in the ClassificationDef.
+ *
+ * @param sourceName - source of the request (used for logging)
+ * @param classificationTypeName - name of the classification's type (ClassificationDef)
+ * @param entityTypeName - name of the entity's type (EntityDef)
+ * @return boolean indicating if the classification is valid for the entity.
+ * @throws TypeErrorException - the type name is not a recognized type or the category is incorrect or there
+ * is an error in the type definition (TypeDef) cached.
+ */
+ boolean isValidClassificationForEntity(String sourceName,
+ String classificationTypeName,
+ String entityTypeName) throws TypeErrorException;
+
+
+ /**
+ * Return identifiers for the TypeDef that matches the supplied type name. If the type name is not recognized,
+ * null is returned.
+ *
+ * @param sourceName - source of the request (used for logging)
+ * @param category - category of type
+ * @param typeName - String type name - the type name is not recognized or of the wrong category.
+ * @return InstanceType object containing TypeDef unique identifier (guid), typeDef name and versionName
+ * @throws TypeErrorException - the type name is not a recognized type or the category is incorrect or there
+ * is an error in the type definition (TypeDef) cached.
+ */
+ InstanceType getInstanceType(String sourceName,
+ TypeDefCategory category,
+ String typeName) throws TypeErrorException;
+
+
+ /**
+ * Return the initial status set up for the instance.
+ *
+ * @param sourceName - source of the request (used for logging)
+ * @param typeName - name of the type to extract the initial status from.
+ * @return InstanceStatus enum
+ * @throws TypeErrorException - the type name is not recognized.
+ */
+ InstanceStatus getInitialStatus(String sourceName, String typeName) throws TypeErrorException;
+
+
+ /**
+ * Return the URL string to use for direct access to the metadata instance. This can be used for
+ * entities and relationships. However, not all servers support direct access, in which case, this
+ * URL is null.
+ *
+ * @param sourceName - source of the request (used for logging)
+ * @param guid - unique identifier for the instance.
+ * @return String URL with placeholder for variables such as userId.
+ */
+ String getInstanceURL(String sourceName, String guid);
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositorycontentmanager/OMRSTypeDefValidator.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositorycontentmanager/OMRSTypeDefValidator.java b/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositorycontentmanager/OMRSTypeDefValidator.java
new file mode 100644
index 0000000..9c7281a
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositorycontentmanager/OMRSTypeDefValidator.java
@@ -0,0 +1,176 @@
+/*
+ * 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.localrepository.repositorycontentmanager;
+
+import org.apache.atlas.omrs.metadatacollection.properties.typedefs.TypeDef;
+import org.apache.atlas.omrs.metadatacollection.properties.typedefs.TypeDefCategory;
+import org.apache.atlas.omrs.metadatacollection.properties.typedefs.TypeDefSummary;
+
+import java.util.ArrayList;
+
+/**
+ * OMRSTypeDefValidator describes a component that is able to manage TypeDefs for the local metadata repository.
+ */
+public interface OMRSTypeDefValidator
+{
+ /**
+ * Return a summary list of the TypeDefs supported by the local metadata repository. This is
+ * broadcast to the other servers/repositories in the cohort during the membership registration exchanges
+ * managed by the cohort registries.
+ *
+ * @return TypeDefSummary list
+ */
+ ArrayList<TypeDefSummary> getLocalTypeDefs();
+
+
+ /**
+ * Return a boolean flag indicating whether the list of TypeDefs passed are compatible with the
+ * local metadata repository. A true response means it is ok; false means conflicts have been found.
+ *
+ * A valid TypeDef is one that:
+ * <ul>
+ * <li>
+ * Matches name, GUID and version to a TypeDef in the local repository, or
+ * </li>
+ * <li>
+ * Is not defined in the local repository.
+ * </li>
+ * </ul>
+ *
+ * @param sourceName - source of the request (used for logging)
+ * @param typeDefSummaries - list of summary information about the TypeDefs.
+ */
+ void validateAgainstLocalTypeDefs(String sourceName,
+ ArrayList<TypeDefSummary> typeDefSummaries);
+
+
+ /**
+ * Return a boolean flag indicating whether the list of TypeDefs passed are compatible with the
+ * all known typedefs.
+ *
+ * A valid TypeDef is one that matches name, GUID and version to the full list of TypeDefs.
+ * If a new TypeDef is present, it is added to the enterprise list.
+ *
+ * @param sourceName - source of the request (used for logging)
+ * @param typeDefs - list of TypeDefs.
+ * @return boolean flag
+ */
+ boolean validateEnterpriseTypeDefs(String sourceName,
+ ArrayList<TypeDef> typeDefs);
+
+
+ /**
+ * Return boolean indicating whether the TypeDef is one of the standard open metadata types.
+ *
+ * @param sourceName - source of the request (used for logging)
+ * @param typeDefGUID - unique identifier of the type
+ * @param typeDefName - unique name of the type
+ * @return boolean result
+ */
+ boolean isOpenType(String sourceName, String typeDefGUID, String typeDefName);
+
+
+ /**
+ * Return boolean indicating whether the TypeDef is known, either as an open type, or one defined
+ * by one or more of the members of the cohort.
+ *
+ * @param sourceName - source of the request (used for logging)
+ * @param typeDefGUID - unique identifier of the type
+ * @param typeDefName - unique name of the type
+ * @return boolean result
+ */
+ boolean isKnownType(String sourceName, String typeDefGUID, String typeDefName);
+
+
+ /**
+ * Return boolean indicating whether the TypeDef is in use in the local repository.
+ *
+ * @param sourceName - source of the request (used for logging)
+ * @param typeDefGUID - unique identifier of the type
+ * @param typeDefName - unique name of the type
+ * @return boolean result
+ */
+ boolean isActiveType(String sourceName, String typeDefGUID, String typeDefName);
+
+
+ /**
+ * Return boolean indicating whether the TypeDef identifiers are from a single known type or not.
+ *
+ * @param sourceName - source of the request (used for logging)
+ * @param typeDefGUID - unique identifier of the TypeDef
+ * @param typeDefName - unique name of the TypeDef
+ * @return boolean result
+ */
+ boolean validTypeId(String sourceName,
+ String typeDefGUID,
+ String typeDefName);
+
+
+ /**
+ * Return boolean indicating whether the TypeDef identifiers are from a single known type or not.
+ *
+ * @param sourceName - source of the request (used for logging)
+ * @param typeDefGUID - unique identifier of the TypeDef
+ * @param typeDefName - unique name of the TypeDef
+ * @param category - category for the TypeDef
+ * @return boolean result
+ */
+ boolean validTypeId(String sourceName,
+ String typeDefGUID,
+ String typeDefName,
+ TypeDefCategory category);
+
+
+ /**
+ * Return boolean indicating whether the TypeDef identifiers are from a single known type or not.
+ *
+ * @param sourceName - source of the request (used for logging)
+ * @param typeDefGUID - unique identifier of the TypeDef
+ * @param typeDefName - unique name of the TypeDef
+ * @param typeDefVersion - versionName of the type
+ * @param category - category for the TypeDef
+ * @return boolean result
+ */
+ boolean validTypeId(String sourceName,
+ String typeDefGUID,
+ String typeDefName,
+ long typeDefVersion,
+ TypeDefCategory category);
+
+
+ /**
+ * Return boolean indicating whether the supplied TypeDef is valid or not.
+ *
+ * @param sourceName - source of the request (used for logging)
+ * @param typeDef - TypeDef to test
+ * @return boolean result
+ */
+ boolean validTypeDef(String sourceName,
+ TypeDef typeDef);
+
+
+ /**
+ * Return boolean indicating whether the supplied TypeDefSummary is valid or not.
+ *
+ * @param sourceName - source of the TypeDefSummary (used for logging)
+ * @param typeDefSummary - TypeDefSummary to test.
+ * @return boolean result.
+ */
+ boolean validTypeDefSummary(String sourceName,
+ TypeDefSummary typeDefSummary);
+}
[30/30] atlas git commit: ATLAS-2246: OMRS Connector API plus REST
and IGC Connector skeleton - 15th February 2018
Posted by da...@apache.org.
ATLAS-2246: OMRS Connector API plus REST and IGC Connector skeleton - 15th February 2018
Signed-off-by: David Radley <da...@uk.ibm.com>
Project: http://git-wip-us.apache.org/repos/asf/atlas/repo
Commit: http://git-wip-us.apache.org/repos/asf/atlas/commit/8a57e657
Tree: http://git-wip-us.apache.org/repos/asf/atlas/tree/8a57e657
Diff: http://git-wip-us.apache.org/repos/asf/atlas/diff/8a57e657
Branch: refs/heads/master
Commit: 8a57e6571c0079c25c147732ad3a6994be8e14ea
Parents: c2be064
Author: Mandy Chessell <ma...@uk.ibm.com>
Authored: Thu Feb 15 12:46:01 2018 +0000
Committer: David Radley <da...@uk.ibm.com>
Committed: Fri Feb 16 09:39:05 2018 +0000
----------------------------------------------------------------------
.../org/apache/atlas/ocf/ConnectorBase.java | 40 +
.../apache/atlas/ocf/ConnectorProviderBase.java | 2 +-
.../apache/atlas/ocf/properties/Connection.java | 8 +-
.../apache/atlas/ocf/properties/KeyPattern.java | 18 +-
omrs/README.md | 43 +
omrs/pom.xml | 98 +
.../AtlasOMRSRepositoryEventMapper.java | 39 +
.../AtlasOMRSRepositoryEventMapperProvider.java | 45 +
.../LocalAtlasOMRSMetadataCollection.java | 61 +
.../LocalAtlasOMRSRepositoryConnector.java | 85 +
...calAtlasOMRSRepositoryConnectorProvider.java | 45 +
.../IGCOMRSRepositoryEventMapper.java | 44 +
.../IGCOMRSRepositoryEventMapperProvider.java | 44 +
.../IGCOMRSMetadataCollection.java | 60 +
.../IGCOMRSRepositoryConnector.java | 84 +
.../IGCOMRSRepositoryConnectorProvider.java | 44 +
.../IGCV2OMRSRepositoryEventMapper.java | 44 +
.../IGCV2OMRSRepositoryEventMapperProvider.java | 45 +
.../IGCV2OMRSMetadataCollection.java | 60 +
.../IGCV2OMRSRepositoryConnector.java | 86 +
.../IGCV2OMRSRepositoryConnectorProvider.java | 45 +
.../omrs/admin/OMRSConfigurationFactory.java | 228 +
.../omrs/admin/OMRSOperationalServices.java | 858 +++
.../omrs/admin/properties/CohortConfig.java | 233 +
.../properties/EnterpriseAccessConfig.java | 167 +
.../admin/properties/LocalRepositoryConfig.java | 310 +
.../OpenMetadataEventProtocolVersion.java | 28 +
.../properties/OpenMetadataExchangeRule.java | 106 +
.../properties/RepositoryServicesConfig.java | 207 +
.../omrs/archivemanager/OMRSArchiveBuilder.java | 338 ++
.../omrs/archivemanager/OMRSArchiveManager.java | 348 ++
.../opentypes/OpenMetadataTypesArchive.java | 5657 ++++++++++++++++++
.../properties/OpenMetadataArchive.java | 116 +
.../OpenMetadataArchiveInstanceStore.java | 86 +
.../OpenMetadataArchiveProperties.java | 222 +
.../properties/OpenMetadataArchiveType.java | 79 +
.../OpenMetadataArchiveTypeStore.java | 111 +
.../store/OpenMetadataArchiveStore.java | 72 +
.../OpenMetadataArchiveStoreConnectorBase.java | 27 +
.../OpenMetadataArchiveStoreProviderBase.java | 41 +
.../atlas/omrs/auditlog/OMRSAuditCode.java | 500 ++
.../atlas/omrs/auditlog/OMRSAuditLog.java | 197 +
.../auditlog/OMRSAuditLogRecordSeverity.java | 122 +
.../omrs/auditlog/OMRSAuditingComponent.java | 261 +
.../omrs/auditlog/store/OMRSAuditLogRecord.java | 243 +
.../store/OMRSAuditLogRecordOriginator.java | 179 +
.../store/OMRSAuditLogReportingComponent.java | 145 +
.../omrs/auditlog/store/OMRSAuditLogStore.java | 108 +
.../store/OMRSAuditLogStoreConnectorBase.java | 27 +
.../store/OMRSAuditLogStoreProviderBase.java | 41 +
.../file/FileBasedAuditLogStoreConnector.java | 164 +
.../file/FileBasedAuditLogStoreProvider.java | 37 +
.../OMRSConnectionConsumer.java | 62 +
.../connectormanager/OMRSConnectorConsumer.java | 61 +
.../connectormanager/OMRSConnectorManager.java | 48 +
.../OMRSEnterpriseConnectorManager.java | 539 ++
.../EnterpriseOMRSConnection.java | 49 +
.../EnterpriseOMRSConnectorProperties.java | 52 +
.../EnterpriseOMRSConnectorProvider.java | 153 +
.../EnterpriseOMRSMetadataCollection.java | 3995 +++++++++++++
.../EnterpriseOMRSRepositoryConnector.java | 357 ++
.../omrs/eventmanagement/OMRSEventListener.java | 832 +++
.../eventmanagement/OMRSEventPublisher.java | 1972 ++++++
.../OMRSRepositoryEventExchangeRule.java | 166 +
.../OMRSRepositoryEventManager.java | 1608 +++++
.../OMRSRepositoryEventProcessor.java | 30 +
.../omrs/eventmanagement/events/OMRSEvent.java | 582 ++
.../events/OMRSEventCategory.java | 101 +
.../events/OMRSEventDirection.java | 84 +
.../events/OMRSEventErrorCode.java | 39 +
.../events/OMRSEventOriginator.java | 171 +
.../events/OMRSInstanceEvent.java | 477 ++
.../events/OMRSInstanceEventErrorCode.java | 118 +
.../events/OMRSInstanceEventProcessor.java | 667 +++
.../events/OMRSInstanceEventType.java | 148 +
.../events/OMRSRegistryEvent.java | 289 +
.../events/OMRSRegistryEventErrorCode.java | 126 +
.../events/OMRSRegistryEventProcessor.java | 159 +
.../events/OMRSRegistryEventType.java | 128 +
.../events/OMRSTypeDefEvent.java | 453 ++
.../events/OMRSTypeDefEventErrorCode.java | 122 +
.../events/OMRSTypeDefEventProcessor.java | 262 +
.../events/OMRSTypeDefEventType.java | 111 +
.../eventmanagement/events/v1/OMRSEventV1.java | 132 +
.../events/v1/OMRSEventV1ErrorSection.java | 182 +
.../events/v1/OMRSEventV1InstanceSection.java | 149 +
.../events/v1/OMRSEventV1RegistrySection.java | 83 +
.../events/v1/OMRSEventV1TypeDefSection.java | 127 +
.../OMRSRepositoryEventMapper.java | 65 +
.../OMRSRepositoryEventMapperBase.java | 92 +
.../OMRSRepositoryEventMapperProviderBase.java | 41 +
.../apache/atlas/omrs/ffdc/OMRSErrorCode.java | 413 ++
.../java/org/apache/atlas/omrs/ffdc/README.md | 47 +
.../exception/ClassificationErrorException.java | 57 +
.../ffdc/exception/EntityConflictException.java | 60 +
.../exception/EntityNotDeletedException.java | 57 +
.../ffdc/exception/EntityNotKnownException.java | 57 +
.../ffdc/exception/HomeEntityException.java | 57 +
.../exception/HomeRelationshipException.java | 57 +
.../ffdc/exception/InvalidEntityException.java | 60 +
.../exception/InvalidParameterException.java | 57 +
.../exception/InvalidRelationshipException.java | 60 +
.../ffdc/exception/InvalidTypeDefException.java | 60 +
.../NotImplementedRuntimeException.java | 32 +
.../exception/OMRSCheckedExceptionBase.java | 161 +
.../exception/OMRSConfigErrorException.java | 185 +
.../exception/OMRSConnectorErrorException.java | 184 +
.../ffdc/exception/OMRSLogicErrorException.java | 185 +
.../ffdc/exception/OMRSRuntimeException.java | 181 +
.../ffdc/exception/PagingErrorException.java | 57 +
.../ffdc/exception/PatchErrorException.java | 60 +
.../ffdc/exception/PropertyErrorException.java | 57 +
.../RelationshipConflictException.java | 60 +
.../exception/RelationshipKnownException.java | 57 +
.../RelationshipNotDeletedException.java | 58 +
.../RelationshipNotKnownException.java | 61 +
.../exception/RepositoryErrorException.java | 61 +
.../exception/StatusNotSupportedException.java | 61 +
.../exception/TypeDefConflictException.java | 60 +
.../ffdc/exception/TypeDefInUseException.java | 60 +
.../ffdc/exception/TypeDefKnownException.java | 60 +
.../exception/TypeDefNotKnownException.java | 60 +
.../exception/TypeDefNotSupportedException.java | 60 +
.../omrs/ffdc/exception/TypeErrorException.java | 57 +
.../exception/UserNotAuthorizedException.java | 57 +
.../localrepository/OMRSLocalRepository.java | 83 +
.../LocalOMRSConnectorProvider.java | 200 +
.../LocalOMRSInstanceEventProcessor.java | 1056 ++++
.../LocalOMRSMetadataCollection.java | 3157 ++++++++++
.../LocalOMRSRepositoryConnector.java | 259 +
.../OMRSInstanceRetrievalEventProcessor.java | 78 +
.../OMRSInstanceHelper.java | 149 +
.../OMRSInstanceValidator.java | 69 +
.../OMRSRepositoryContentManager.java | 2056 +++++++
.../OMRSRepositoryHelper.java | 551 ++
.../OMRSRepositoryValidator.java | 529 ++
.../OMRSTypeDefHelper.java | 101 +
.../OMRSTypeDefManager.java | 181 +
.../OMRSTypeDefValidator.java | 176 +
.../OMRSMetadataCollection.java | 1957 ++++++
.../OMRSMetadataCollectionBase.java | 2143 +++++++
.../properties/MatchCriteria.java | 80 +
.../properties/SequencingOrder.java | 111 +
.../instances/ArrayPropertyValue.java | 155 +
.../properties/instances/Classification.java | 254 +
.../instances/ClassificationOrigin.java | 81 +
.../properties/instances/EntityDetail.java | 107 +
.../properties/instances/EntityProxy.java | 107 +
.../properties/instances/EntitySummary.java | 114 +
.../properties/instances/EntityUniverse.java | 115 +
.../properties/instances/EnumPropertyValue.java | 123 +
.../instances/InstanceAuditHeader.java | 266 +
.../instances/InstanceElementHeader.java | 53 +
.../properties/instances/InstanceGraph.java | 259 +
.../properties/instances/InstanceHeader.java | 172 +
.../instances/InstanceProperties.java | 196 +
.../instances/InstancePropertyCategory.java | 91 +
.../instances/InstancePropertyValue.java | 114 +
.../instances/InstanceProvenanceType.java | 109 +
.../properties/instances/InstanceStatus.java | 91 +
.../properties/instances/InstanceType.java | 311 +
.../properties/instances/MapPropertyValue.java | 133 +
.../instances/PrimitivePropertyValue.java | 172 +
.../properties/instances/Relationship.java | 320 +
.../instances/StructPropertyValue.java | 95 +
.../typedefs/AttributeCardinality.java | 111 +
.../properties/typedefs/AttributeTypeDef.java | 215 +
.../typedefs/AttributeTypeDefCategory.java | 84 +
.../properties/typedefs/ClassificationDef.java | 162 +
.../typedefs/ClassificationPropagationRule.java | 87 +
.../properties/typedefs/CollectionDef.java | 143 +
.../typedefs/CollectionDefCategory.java | 101 +
.../properties/typedefs/EntityDef.java | 93 +
.../properties/typedefs/EnumDef.java | 119 +
.../properties/typedefs/EnumElementDef.java | 144 +
.../typedefs/ExternalStandardMapping.java | 141 +
.../properties/typedefs/PrimitiveDef.java | 83 +
.../typedefs/PrimitiveDefCategory.java | 103 +
.../typedefs/RelationshipCategory.java | 94 +
.../typedefs/RelationshipContainerEnd.java | 75 +
.../properties/typedefs/RelationshipDef.java | 217 +
.../properties/typedefs/RelationshipEndDef.java | 193 +
.../properties/typedefs/TypeDef.java | 437 ++
.../properties/typedefs/TypeDefAttribute.java | 310 +
.../properties/typedefs/TypeDefCategory.java | 84 +
.../typedefs/TypeDefElementHeader.java | 51 +
.../properties/typedefs/TypeDefGallery.java | 121 +
.../properties/typedefs/TypeDefLink.java | 175 +
.../properties/typedefs/TypeDefPatch.java | 399 ++
.../properties/typedefs/TypeDefPatchAction.java | 103 +
.../properties/typedefs/TypeDefProperties.java | 154 +
.../properties/typedefs/TypeDefSummary.java | 168 +
.../OMRSMetadataCollectionManager.java | 46 +
.../OMRSRepositoryConnector.java | 29 +
.../OMRSRepositoryConnectorProviderBase.java | 43 +
.../metadatahighway/CohortConnectionStatus.java | 122 +
.../omrs/metadatahighway/OMRSCohortManager.java | 382 ++
.../OMRSMetadataHighwayManager.java | 453 ++
.../cohortregistry/OMRSCohortRegistry.java | 1097 ++++
.../store/OMRSCohortRegistryStore.java | 114 +
.../OMRSCohortRegistryStoreConnectorBase.java | 24 +
.../OMRSCohortRegistryStoreProviderBase.java | 41 +
.../file/FileBasedRegistryStoreConnector.java | 582 ++
.../file/FileBasedRegistryStoreProvider.java | 37 +
.../store/properties/CohortMembership.java | 67 +
.../store/properties/MemberRegistration.java | 206 +
.../OMRSRESTMetadataCollection.java | 59 +
.../OMRSRESTRepositoryConnector.java | 87 +
.../OMRSRESTRepositoryConnectorProvider.java | 44 +
.../rest/server/OMRSRepositoryRESTServices.java | 44 +
.../atlas/omrs/topicconnectors/OMRSTopic.java | 43 +
.../topicconnectors/OMRSTopicConnector.java | 102 +
.../omrs/topicconnectors/OMRSTopicListener.java | 35 +
.../kafka/KafkaOMRSTopicConnector.java | 55 +
.../kafka/KafkaOMRSTopicProvider.java | 38 +
215 files changed, 54323 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/ConnectorBase.java
----------------------------------------------------------------------
diff --git a/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/ConnectorBase.java b/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/ConnectorBase.java
index cc2e430..38ac964 100644
--- a/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/ConnectorBase.java
+++ b/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/ConnectorBase.java
@@ -18,6 +18,7 @@
package org.apache.atlas.ocf;
import org.apache.atlas.ocf.ffdc.PropertyServerException;
+import org.apache.atlas.ocf.properties.AdditionalProperties;
import org.apache.atlas.ocf.properties.ConnectedAssetProperties;
import org.apache.atlas.ocf.properties.Connection;
import org.slf4j.Logger;
@@ -51,6 +52,12 @@ public abstract class ConnectorBase extends Connector
protected Connection connection = null;
protected ConnectedAssetProperties connectedAssetProperties = null;
+ /*
+ * Secured properties are protected properties from the connection. They are retrieved as a protected
+ * variable to allow subclasses of ConnectorBase to access them.
+ */
+ protected AdditionalProperties securedProperties = null;
+
private static final int hashCode = UUID.randomUUID().hashCode();
private static final Logger log = LoggerFactory.getLogger(ConnectorBase.class);
@@ -86,6 +93,12 @@ public abstract class ConnectorBase extends Connector
this.connectorInstanceId = connectorInstanceId;
this.connection = connection;
+ /*
+ * Set up the secured properties
+ */
+ ProtectedConnection protectedConnection = new ProtectedConnection(connection);
+ this.securedProperties = protectedConnection.getSecuredProperties();
+
if (log.isDebugEnabled())
{
log.debug("New Connector initialized: " + connectorInstanceId + ", " + connection.getConnectionName());
@@ -217,4 +230,31 @@ public abstract class ConnectorBase extends Connector
", connectedAssetProperties=" + connectedAssetProperties +
'}';
}
+
+ private class ProtectedConnection extends Connection
+ {
+ private ProtectedConnection(Connection templateConnection)
+ {
+ super(templateConnection);
+ }
+
+ /**
+ * Return a copy of the secured properties. Null means no secured properties are available.
+ * This method is protected so only OCF (or subclasses) can access them. When Connector is passed to calling
+ * OMAS, the secured properties are not available.
+ *
+ * @return secured properties - typically user credentials for the connection
+ */
+ protected AdditionalProperties getSecuredProperties()
+ {
+ if (super.securedProperties == null)
+ {
+ return securedProperties;
+ }
+ else
+ {
+ return new AdditionalProperties(super.getParentAsset(), securedProperties);
+ }
+ }
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/ConnectorProviderBase.java
----------------------------------------------------------------------
diff --git a/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/ConnectorProviderBase.java b/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/ConnectorProviderBase.java
index fafd20c..4e0762a 100644
--- a/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/ConnectorProviderBase.java
+++ b/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/ConnectorProviderBase.java
@@ -65,7 +65,7 @@ public abstract class ConnectorProviderBase extends ConnectorProvider
*
* @return guid for a new connector instance
*/
- private String getNewConnectorGUID()
+ protected String getNewConnectorGUID()
{
UUID newUUID = UUID.randomUUID();
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/properties/Connection.java
----------------------------------------------------------------------
diff --git a/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/properties/Connection.java b/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/properties/Connection.java
index d34e6f4..0d5cfdb 100644
--- a/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/properties/Connection.java
+++ b/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/properties/Connection.java
@@ -77,10 +77,10 @@ public class Connection extends Referenceable
/*
* Attributes of a connector
*/
- private String displayName = null;
- private String description = null;
- private ConnectorType connectorType = null;
- private Endpoint endpoint = null;
+ protected String displayName = null;
+ protected String description = null;
+ protected ConnectorType connectorType = null;
+ protected Endpoint endpoint = null;
/*
* Secured properties are protected so they can only be accessed by subclassing this object.
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/properties/KeyPattern.java
----------------------------------------------------------------------
diff --git a/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/properties/KeyPattern.java b/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/properties/KeyPattern.java
index ce6dae1..7cfd30c 100644
--- a/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/properties/KeyPattern.java
+++ b/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/properties/KeyPattern.java
@@ -20,19 +20,19 @@ package org.apache.atlas.ocf.properties;
import java.io.Serializable;
/**
- * A KeyPattern defines the type of External Identifier in use of an asset, or the type of Primary Key used within an
+ * A KeyPattern defines the type of External Identifier in use for an asset, or the type of Primary Key used within an
* asset.
*/
public enum KeyPattern implements Serializable
{
- LOCAL_KEY(0, "Local Key", "Unique key allocated and used within the scope of a single system."),
- RECYCLED_KEY(1, "Recycled Key", "Key allocated and used within the scope of a single system that is periodically reused for different records."),
- NATURAL_KEY(2, "Natural Key", "Key derived from an attribute of the entity, such as email address, passport number."),
- MIRROR_KEY(3, "Mirror Key", "Key value copied from another system."),
- AGGREGATE_KEY(4, "Aggregate Key", "Key formed by combining keys from multiple systems."),
- CALLERS_KEY(5, "Caller's Key", "Key from another system can bey used if system name provided."),
- STABLE_KEY(6, "Stable Key", "Key value will remain active even if records are merged."),
- OTHER(99, "Other", "Another key pattern.");
+ LOCAL_KEY (0, "Local Key", "Unique key allocated and used within the scope of a single system."),
+ RECYCLED_KEY (1, "Recycled Key", "Key allocated and used within the scope of a single system that is periodically reused for different records."),
+ NATURAL_KEY (2, "Natural Key", "Key derived from an attribute of the entity, such as email address, passport number."),
+ MIRROR_KEY (3, "Mirror Key", "Key value copied from another system."),
+ AGGREGATE_KEY (4, "Aggregate Key", "Key formed by combining keys from multiple systems."),
+ CALLERS_KEY (5, "Caller's Key", "Key from another system can bey used if system name provided."),
+ STABLE_KEY (6, "Stable Key", "Key value will remain active even if records are merged."),
+ OTHER (99, "Other", "Another key pattern.");
private static final long serialVersionUID = 1L;
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/README.md
----------------------------------------------------------------------
diff --git a/omrs/README.md b/omrs/README.md
new file mode 100644
index 0000000..e219288
--- /dev/null
+++ b/omrs/README.md
@@ -0,0 +1,43 @@
+<!--
+ ~ 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
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ 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.
+ -->
+
+# Open Metadata Repository Service (OMRS)
+
+The Open Metadata Repository Services (OMRS) enable metadata repositories to exchange metadata.
+Traditional metadata management technology tends to centralize metadata into a single repository.
+An organization often begins with a single metadata repository, typically deployed to support a
+single project or initiative.
+However, over time, depending on the tools they buy, the projects they run or the political structures
+within the organization, the number of deployed metadata repositories grows, creating multiple metadata silos.
+So for example, an organization may have:
+
+* a metadata repository and tools for its governance team.
+This metadata repository may host the canonical glossary, and the governance policies, rules and classifications.
+
+* a metadata repository for its data lake.
+This metadata repository has the details of the data repositories in the data lake and the
+movement of data between them.
+
+* a metadata repository for its data integration tools that continuously extract data
+from the operational systems and sends them to the data lake.
+
+The role of the OMRS is to bring these metadata repositories together so this metadata can be linked
+and used together across the organization.
+It enables these metadata repositories to act as a aggregated source of metadata.
+The metadata repositories using OMRS may be instances of Apache Atlas and they may
+include a mixture of repositories from different vendors that support the OMRS integration interfaces.
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/pom.xml
----------------------------------------------------------------------
diff --git a/omrs/pom.xml b/omrs/pom.xml
new file mode 100644
index 0000000..4861499
--- /dev/null
+++ b/omrs/pom.xml
@@ -0,0 +1,98 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ 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.
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <artifactId>apache-atlas</artifactId>
+ <groupId>org.apache.atlas</groupId>
+ <version>1.0.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>omrs</artifactId>
+
+ <name>Open Metadata Repository Services (OMRS)</name>
+ <description>Open Metadata Repository Services (OMRS) interfaces and implementation for linking metadata repositories into a cohort</description>
+
+ <packaging>jar</packaging>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>commons-collections</groupId>
+ <artifactId>commons-collections</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>com.fasterxml.jackson.jaxrs</groupId>
+ <artifactId>jackson-jaxrs-base</artifactId>
+ <version>${jackson.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>com.fasterxml.jackson.jaxrs</groupId>
+ <artifactId>jackson-jaxrs-json-provider</artifactId>
+ <version>${jackson.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.inject</groupId>
+ <artifactId>javax.inject</artifactId>
+ <version>${javax-inject.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.atlas</groupId>
+ <artifactId>om-fwk-ocf</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <version>2.4</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>test-jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/adapters/atlas/eventmapper/AtlasOMRSRepositoryEventMapper.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/adapters/atlas/eventmapper/AtlasOMRSRepositoryEventMapper.java b/omrs/src/main/java/org/apache/atlas/omrs/adapters/atlas/eventmapper/AtlasOMRSRepositoryEventMapper.java
new file mode 100644
index 0000000..62b1d2f
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/adapters/atlas/eventmapper/AtlasOMRSRepositoryEventMapper.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.adapters.atlas.eventmapper;
+
+import org.apache.atlas.omrs.eventmanagement.repositoryeventmapper.OMRSRepositoryEventMapperBase;
+
+public class AtlasOMRSRepositoryEventMapper extends OMRSRepositoryEventMapperBase
+{
+ /**
+ * Default constructor
+ */
+ public AtlasOMRSRepositoryEventMapper()
+ {
+ }
+
+
+ /**
+ * Free up any resources held since the connector is no longer needed.
+ */
+ public void disconnect()
+ {
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/adapters/atlas/eventmapper/AtlasOMRSRepositoryEventMapperProvider.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/adapters/atlas/eventmapper/AtlasOMRSRepositoryEventMapperProvider.java b/omrs/src/main/java/org/apache/atlas/omrs/adapters/atlas/eventmapper/AtlasOMRSRepositoryEventMapperProvider.java
new file mode 100644
index 0000000..28b79ed
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/adapters/atlas/eventmapper/AtlasOMRSRepositoryEventMapperProvider.java
@@ -0,0 +1,45 @@
+/*
+ * 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.adapters.atlas.eventmapper;
+
+import org.apache.atlas.omrs.adapters.igc.v1.eventmapper.IGCOMRSRepositoryEventMapper;
+import org.apache.atlas.omrs.metadatacollection.repositoryconnector.OMRSRepositoryConnectorProviderBase;
+
+/**
+ * In the Open Connector Framework (OCF), a ConnectorProvider is a factory for a specific type of connector.
+ * The IGCOMRSRepositoryEventMapperProvider is the connector provider for the IGCOMRSRepositoryEventMapper.
+ * It extends OMRSRepositoryEventMapperProviderBase which in turn extends the OCF ConnectorProviderBase.
+ * ConnectorProviderBase supports the creation of connector instances.
+ *
+ * The OMRSRESTRepositoryConnectorProvider must initialize ConnectorProviderBase with the Java class
+ * name of the OMRS Connector implementation (by calling super.setConnectorClassName(className)).
+ * Then the connector provider will work.
+ */
+public class AtlasOMRSRepositoryEventMapperProvider extends OMRSRepositoryConnectorProviderBase
+{
+ /**
+ * Constructor used to initialize the ConnectorProviderBase with the Java class name of the specific
+ * OMRS Connector implementation.
+ */
+ public AtlasOMRSRepositoryEventMapperProvider()
+ {
+ Class connectorClass = IGCOMRSRepositoryEventMapper.class;
+
+ super.setConnectorClassName(connectorClass.getName());
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/adapters/atlas/repositoryconnector/LocalAtlasOMRSMetadataCollection.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/adapters/atlas/repositoryconnector/LocalAtlasOMRSMetadataCollection.java b/omrs/src/main/java/org/apache/atlas/omrs/adapters/atlas/repositoryconnector/LocalAtlasOMRSMetadataCollection.java
new file mode 100644
index 0000000..f14caf6
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/adapters/atlas/repositoryconnector/LocalAtlasOMRSMetadataCollection.java
@@ -0,0 +1,61 @@
+/*
+ * 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.adapters.atlas.repositoryconnector;
+
+import org.apache.atlas.omrs.ffdc.exception.NotImplementedRuntimeException;
+import org.apache.atlas.omrs.metadatacollection.OMRSMetadataCollectionBase;
+
+/**
+ * The OMRSRESTMetadataCollection represents a remote metadata repository that supports the OMRS REST API.
+ * Requests to this metadata collection are translated one-for-one to requests to the remote repository since
+ * the OMRS REST API has a one-to-one correspondence with the metadata collection.
+ */
+public class LocalAtlasOMRSMetadataCollection extends OMRSMetadataCollectionBase
+{
+ private LocalAtlasOMRSRepositoryConnector parentConnector = null;
+ private String metadataCollectionId = null;
+
+ /**
+ * Default constructor.
+ *
+ * @param parentConnector - connector that this metadata collection supports. The connector has the information
+ * to call the metadata repository.
+ * @param metadataCollectionId - unique Identifier of the metadata collection Id.
+ */
+ public LocalAtlasOMRSMetadataCollection(LocalAtlasOMRSRepositoryConnector parentConnector,
+ String metadataCollectionId)
+ {
+ /*
+ * The metadata collection Id is the unique Id for the metadata collection. It is managed by the super class.
+ */
+ super(metadataCollectionId);
+ this.metadataCollectionId = metadataCollectionId;
+
+ /*
+ * Save parentConnector since this has the connection information and access to the metadata about the
+ * metadata cluster.
+ */
+ this.parentConnector = parentConnector;
+
+ /*
+ * This is a temporary implementation to allow the structural implementation of the connectors to
+ * be committed before the metadata collection implementation is complete.
+ */
+ throw new NotImplementedRuntimeException("LocalAtlasMetadataCollection", "constructor", "ATLAS-1773");
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/adapters/atlas/repositoryconnector/LocalAtlasOMRSRepositoryConnector.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/adapters/atlas/repositoryconnector/LocalAtlasOMRSRepositoryConnector.java b/omrs/src/main/java/org/apache/atlas/omrs/adapters/atlas/repositoryconnector/LocalAtlasOMRSRepositoryConnector.java
new file mode 100644
index 0000000..8f331be
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/adapters/atlas/repositoryconnector/LocalAtlasOMRSRepositoryConnector.java
@@ -0,0 +1,85 @@
+/*
+ * 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.adapters.atlas.repositoryconnector;
+
+import org.apache.atlas.ocf.ffdc.ConnectorCheckedException;
+import org.apache.atlas.omrs.metadatacollection.OMRSMetadataCollection;
+import org.apache.atlas.omrs.metadatacollection.repositoryconnector.OMRSRepositoryConnector;
+
+/**
+ * The OMRSRESTRepositoryConnector is a connector to a remote Apache Atlas repository (or any other metadata repository
+ * that supports the OMRS REST APIs). This is the connector used by the EnterpriseOMRSRepositoryConnector to make a direct call
+ * to another open metadata repository.
+ */
+public class LocalAtlasOMRSRepositoryConnector extends OMRSRepositoryConnector
+{
+ private LocalAtlasOMRSMetadataCollection metadataCollection = null;
+ private String metadataCollectionId = null;
+
+ /**
+ * Default constructor used by the OCF Connector Provider.
+ */
+ public LocalAtlasOMRSRepositoryConnector()
+ {
+ /*
+ * Nothing to do (yet !)
+ */
+ }
+
+
+ /**
+ * Set up the unique Id for this metadata collection.
+ *
+ * @param metadataCollectionId - String unique Id
+ */
+ public void setMetadataCollectionId(String metadataCollectionId)
+ {
+ this.metadataCollectionId = metadataCollectionId;
+
+ /*
+ * Initialize the metadata collection only once the connector is properly set up.
+ */
+ metadataCollection = new LocalAtlasOMRSMetadataCollection(this, metadataCollectionId);
+ }
+
+
+ /**
+ * Returns the metadata collection object that provides an OMRS abstraction of the metadata within
+ * a metadata repository.
+ *
+ * @return OMRSMetadataCollection - metadata information retrieved from the metadata repository.
+ */
+ public OMRSMetadataCollection getMetadataCollection()
+ {
+ if (metadataCollection == null)
+ {
+ // TODO Throw exception since it means the local metadata collection id is not set up.
+ }
+ return metadataCollection;
+ }
+
+
+ /**
+ * Free up any resources held since the connector is no longer needed.
+ *
+ * @throws ConnectorCheckedException - there is a problem disconnecting the connector.
+ */
+ public void disconnect() throws ConnectorCheckedException
+ {
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/adapters/atlas/repositoryconnector/LocalAtlasOMRSRepositoryConnectorProvider.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/adapters/atlas/repositoryconnector/LocalAtlasOMRSRepositoryConnectorProvider.java b/omrs/src/main/java/org/apache/atlas/omrs/adapters/atlas/repositoryconnector/LocalAtlasOMRSRepositoryConnectorProvider.java
new file mode 100644
index 0000000..ca7d086
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/adapters/atlas/repositoryconnector/LocalAtlasOMRSRepositoryConnectorProvider.java
@@ -0,0 +1,45 @@
+/*
+ * 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.adapters.atlas.repositoryconnector;
+
+import org.apache.atlas.omrs.metadatacollection.repositoryconnector.OMRSRepositoryConnectorProviderBase;
+import org.apache.atlas.omrs.rest.repositoryconnector.OMRSRESTRepositoryConnector;
+
+/**
+ * In the Open Connector Framework (OCF), a ConnectorProvider is a factory for a specific type of connector.
+ * The OMRSRESTRepositoryConnectorProvider is the connector provider for the OMRSRESTRepositoryConnector.
+ * It extends OMRSRepositoryConnectorProviderBase which in turn extends the OCF ConnectorProviderBase.
+ * ConnectorProviderBase supports the creation of connector instances.
+ *
+ * The OMRSRESTRepositoryConnectorProvider must initialize ConnectorProviderBase with the Java class
+ * name of the OMRS Connector implementation (by calling super.setConnectorClassName(className)).
+ * Then the connector provider will work.
+ */
+public class LocalAtlasOMRSRepositoryConnectorProvider extends OMRSRepositoryConnectorProviderBase
+{
+ /**
+ * Constructor used to initialize the ConnectorProviderBase with the Java class name of the specific
+ * OMRS Connector implementation.
+ */
+ public LocalAtlasOMRSRepositoryConnectorProvider()
+ {
+ Class connectorClass = OMRSRESTRepositoryConnector.class;
+
+ super.setConnectorClassName(connectorClass.getName());
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/adapters/igc/v1/eventmapper/IGCOMRSRepositoryEventMapper.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/adapters/igc/v1/eventmapper/IGCOMRSRepositoryEventMapper.java b/omrs/src/main/java/org/apache/atlas/omrs/adapters/igc/v1/eventmapper/IGCOMRSRepositoryEventMapper.java
new file mode 100644
index 0000000..3eef8c8
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/adapters/igc/v1/eventmapper/IGCOMRSRepositoryEventMapper.java
@@ -0,0 +1,44 @@
+/*
+ * 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.adapters.igc.v1.eventmapper;
+
+import org.apache.atlas.omrs.eventmanagement.repositoryeventmapper.OMRSRepositoryEventMapperBase;
+
+
+/**
+ * IGCOMRSRepositoryEventMapper provides an implementation of a repository event mapper for the
+ * IBM Governance Catalog (IGC).
+ */
+public class IGCOMRSRepositoryEventMapper extends OMRSRepositoryEventMapperBase
+{
+ /**
+ * Default constructor
+ */
+ public IGCOMRSRepositoryEventMapper()
+ {
+ }
+
+
+ /**
+ * Free up any resources held since the connector is no longer needed.
+ */
+ public void disconnect()
+ {
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/adapters/igc/v1/eventmapper/IGCOMRSRepositoryEventMapperProvider.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/adapters/igc/v1/eventmapper/IGCOMRSRepositoryEventMapperProvider.java b/omrs/src/main/java/org/apache/atlas/omrs/adapters/igc/v1/eventmapper/IGCOMRSRepositoryEventMapperProvider.java
new file mode 100644
index 0000000..f51fb06
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/adapters/igc/v1/eventmapper/IGCOMRSRepositoryEventMapperProvider.java
@@ -0,0 +1,44 @@
+/*
+ * 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.adapters.igc.v1.eventmapper;
+
+import org.apache.atlas.omrs.metadatacollection.repositoryconnector.OMRSRepositoryConnectorProviderBase;
+
+/**
+ * In the Open Connector Framework (OCF), a ConnectorProvider is a factory for a specific type of connector.
+ * The IGCOMRSRepositoryEventMapperProvider is the connector provider for the IGCOMRSRepositoryEventMapper.
+ * It extends OMRSRepositoryEventMapperProviderBase which in turn extends the OCF ConnectorProviderBase.
+ * ConnectorProviderBase supports the creation of connector instances.
+ *
+ * The OMRSRESTRepositoryConnectorProvider must initialize ConnectorProviderBase with the Java class
+ * name of the OMRS Connector implementation (by calling super.setConnectorClassName(className)).
+ * Then the connector provider will work.
+ */
+public class IGCOMRSRepositoryEventMapperProvider extends OMRSRepositoryConnectorProviderBase
+{
+ /**
+ * Constructor used to initialize the ConnectorProviderBase with the Java class name of the specific
+ * OMRS Connector implementation.
+ */
+ public IGCOMRSRepositoryEventMapperProvider()
+ {
+ Class connectorClass = IGCOMRSRepositoryEventMapper.class;
+
+ super.setConnectorClassName(connectorClass.getName());
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/adapters/igc/v1/repositoryconnector/IGCOMRSMetadataCollection.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/adapters/igc/v1/repositoryconnector/IGCOMRSMetadataCollection.java b/omrs/src/main/java/org/apache/atlas/omrs/adapters/igc/v1/repositoryconnector/IGCOMRSMetadataCollection.java
new file mode 100644
index 0000000..77afe02
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/adapters/igc/v1/repositoryconnector/IGCOMRSMetadataCollection.java
@@ -0,0 +1,60 @@
+/*
+ * 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.adapters.igc.v1.repositoryconnector;
+
+import org.apache.atlas.omrs.ffdc.exception.NotImplementedRuntimeException;
+import org.apache.atlas.omrs.metadatacollection.OMRSMetadataCollectionBase;
+
+/**
+ * The IGCOMRSMetadataCollection represents a remote IBM Information Governance Catalog (IGC)
+ * metadata repository. IGC supports its own native REST APIs.
+ * Requests to this metadata collection are translated to the IGC REST API calls and the results are
+ * transformed to OMRS objects before returning to the caller.
+ */
+public class IGCOMRSMetadataCollection extends OMRSMetadataCollectionBase
+{
+ private IGCOMRSRepositoryConnector parentConnector = null;
+
+ /**
+ * Default constructor.
+ *
+ * @param parentConnector - connector that this metadata collection supports. The connector has the information
+ * to call the metadata repository.
+ * @param metadataCollectionId - unique identifier for the repository.
+ */
+ public IGCOMRSMetadataCollection(IGCOMRSRepositoryConnector parentConnector,
+ String metadataCollectionId)
+ {
+ /*
+ * The metadata collection Id is the unique Id for the metadata collection. It is managed by the super class.
+ */
+ super(metadataCollectionId);
+ this.metadataCollectionId = metadataCollectionId;
+
+ /*
+ * Save parentConnector since this has the connection information.
+ */
+ this.parentConnector = parentConnector;
+
+ /*
+ * This is a temporary implementation to allow the structural implementation of the connectors to
+ * be committed before the metadata collection implementation is complete.
+ */
+ throw new NotImplementedRuntimeException("IGCOMRSMetadataCollection", "constructor", "ATLAS-1774");
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/adapters/igc/v1/repositoryconnector/IGCOMRSRepositoryConnector.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/adapters/igc/v1/repositoryconnector/IGCOMRSRepositoryConnector.java b/omrs/src/main/java/org/apache/atlas/omrs/adapters/igc/v1/repositoryconnector/IGCOMRSRepositoryConnector.java
new file mode 100644
index 0000000..89a2c95
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/adapters/igc/v1/repositoryconnector/IGCOMRSRepositoryConnector.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.adapters.igc.v1.repositoryconnector;
+
+import org.apache.atlas.ocf.ffdc.ConnectorCheckedException;
+import org.apache.atlas.omrs.metadatacollection.OMRSMetadataCollection;
+import org.apache.atlas.omrs.metadatacollection.repositoryconnector.OMRSRepositoryConnector;
+
+
+/**
+ * The IGCOMRSRepositoryConnector is a connector to a remote IBM Information Governance Catalog (IGC) repository.
+ */
+public class IGCOMRSRepositoryConnector extends OMRSRepositoryConnector
+{
+ private IGCOMRSMetadataCollection metadataCollection = null;
+ private String metadataCollectionId = null;
+
+ /**
+ * Default constructor used by the OCF Connector Provider.
+ */
+ public IGCOMRSRepositoryConnector()
+ {
+ /*
+ * Nothing to do (yet !)
+ */
+ }
+
+
+ /**
+ * Set up the unique Id for this metadata collection.
+ *
+ * @param metadataCollectionId - String unique Id
+ */
+ public void setMetadataCollectionId(String metadataCollectionId)
+ {
+ this.metadataCollectionId = metadataCollectionId;
+
+ /*
+ * Initialize the metadata collection only once the connector is properly set up.
+ */
+ metadataCollection = new IGCOMRSMetadataCollection(this, metadataCollectionId);
+ }
+
+
+ /**
+ * Returns the metadata collection object that provides an OMRS abstraction of the metadata within
+ * a metadata repository.
+ *
+ * @return OMRSMetadataCollection - metadata information retrieved from the metadata repository.
+ */
+ public OMRSMetadataCollection getMetadataCollection()
+ {
+ if (metadataCollection == null)
+ {
+ // TODO Throw exception since it means the local metadata collection id is not set up.
+ }
+ return metadataCollection;
+ }
+
+
+ /**
+ * Free up any resources held since the connector is no longer needed.
+ *
+ * @throws ConnectorCheckedException - there is a problem disconnecting the connector.
+ */
+ public void disconnect() throws ConnectorCheckedException
+ {
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/adapters/igc/v1/repositoryconnector/IGCOMRSRepositoryConnectorProvider.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/adapters/igc/v1/repositoryconnector/IGCOMRSRepositoryConnectorProvider.java b/omrs/src/main/java/org/apache/atlas/omrs/adapters/igc/v1/repositoryconnector/IGCOMRSRepositoryConnectorProvider.java
new file mode 100644
index 0000000..00aed67
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/adapters/igc/v1/repositoryconnector/IGCOMRSRepositoryConnectorProvider.java
@@ -0,0 +1,44 @@
+/*
+ * 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.adapters.igc.v1.repositoryconnector;
+
+import org.apache.atlas.omrs.metadatacollection.repositoryconnector.OMRSRepositoryConnectorProviderBase;
+
+/**
+ * In the Open Connector Framework (OCF), a ConnectorProvider is a factory for a specific type of connector.
+ * The IGCOMRSRepositoryConnectorProvider is the connector provider for the IGCOMRSRepositoryConnector.
+ * It extends OMRSRepositoryConnectorProviderBase which in turn extends the OCF ConnectorProviderBase.
+ * ConnectorProviderBase supports the creation of connector instances.
+ *
+ * The IGCOMRSRepositoryConnectorProvider must initialize ConnectorProviderBase with the Java class
+ * name of the OMRS Connector implementation (by calling super.setConnectorClassName(className)).
+ * Then the connector provider will work.
+ */
+public class IGCOMRSRepositoryConnectorProvider extends OMRSRepositoryConnectorProviderBase
+{
+ /**
+ * Constructor used to initialize the ConnectorProviderBase with the Java class name of the specific
+ * OMRS Connector implementation.
+ */
+ public IGCOMRSRepositoryConnectorProvider()
+ {
+ Class connectorClass = IGCOMRSRepositoryConnector.class;
+
+ super.setConnectorClassName(connectorClass.getName());
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/adapters/igc/v2/eventmapper/IGCV2OMRSRepositoryEventMapper.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/adapters/igc/v2/eventmapper/IGCV2OMRSRepositoryEventMapper.java b/omrs/src/main/java/org/apache/atlas/omrs/adapters/igc/v2/eventmapper/IGCV2OMRSRepositoryEventMapper.java
new file mode 100644
index 0000000..d72aec9
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/adapters/igc/v2/eventmapper/IGCV2OMRSRepositoryEventMapper.java
@@ -0,0 +1,44 @@
+/*
+ * 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.adapters.igc.v2.eventmapper;
+
+import org.apache.atlas.omrs.eventmanagement.repositoryeventmapper.OMRSRepositoryEventMapperBase;
+
+
+/**
+ * IGCOMRSRepositoryEventMapper provides an implementation of a repository event mapper for the
+ * IBM Governance Catalog (IGC) for relaeave following 11.7.
+ */
+public class IGCV2OMRSRepositoryEventMapper extends OMRSRepositoryEventMapperBase
+{
+ /**
+ * Default constructor
+ */
+ public IGCV2OMRSRepositoryEventMapper()
+ {
+ }
+
+
+ /**
+ * Free up any resources held since the connector is no longer needed.
+ */
+ public void disconnect()
+ {
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/adapters/igc/v2/eventmapper/IGCV2OMRSRepositoryEventMapperProvider.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/adapters/igc/v2/eventmapper/IGCV2OMRSRepositoryEventMapperProvider.java b/omrs/src/main/java/org/apache/atlas/omrs/adapters/igc/v2/eventmapper/IGCV2OMRSRepositoryEventMapperProvider.java
new file mode 100644
index 0000000..730f5aa
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/adapters/igc/v2/eventmapper/IGCV2OMRSRepositoryEventMapperProvider.java
@@ -0,0 +1,45 @@
+/*
+ * 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.adapters.igc.v2.eventmapper;
+
+import org.apache.atlas.omrs.adapters.igc.v1.eventmapper.IGCOMRSRepositoryEventMapper;
+import org.apache.atlas.omrs.metadatacollection.repositoryconnector.OMRSRepositoryConnectorProviderBase;
+
+/**
+ * In the Open Connector Framework (OCF), a ConnectorProvider is a factory for a specific type of connector.
+ * The IGCOMRSRepositoryEventMapperProvider is the connector provider for the IGCOMRSRepositoryEventMapper.
+ * It extends OMRSRepositoryEventMapperProviderBase which in turn extends the OCF ConnectorProviderBase.
+ * ConnectorProviderBase supports the creation of connector instances.
+ *
+ * The IGCV2OMRSRepositoryEventMapperProvider must initialize ConnectorProviderBase with the Java class
+ * name of the OMRS Connector implementation (by calling super.setConnectorClassName(className)).
+ * Then the connector provider will work.
+ */
+public class IGCV2OMRSRepositoryEventMapperProvider extends OMRSRepositoryConnectorProviderBase
+{
+ /**
+ * Constructor used to initialize the ConnectorProviderBase with the Java class name of the specific
+ * OMRS Connector implementation.
+ */
+ public IGCV2OMRSRepositoryEventMapperProvider()
+ {
+ Class connectorClass = IGCV2OMRSRepositoryEventMapper.class;
+
+ super.setConnectorClassName(connectorClass.getName());
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/adapters/igc/v2/repositoryconnector/IGCV2OMRSMetadataCollection.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/adapters/igc/v2/repositoryconnector/IGCV2OMRSMetadataCollection.java b/omrs/src/main/java/org/apache/atlas/omrs/adapters/igc/v2/repositoryconnector/IGCV2OMRSMetadataCollection.java
new file mode 100644
index 0000000..4fe1330
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/adapters/igc/v2/repositoryconnector/IGCV2OMRSMetadataCollection.java
@@ -0,0 +1,60 @@
+/*
+ * 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.adapters.igc.v2.repositoryconnector;
+
+import org.apache.atlas.omrs.ffdc.exception.NotImplementedRuntimeException;
+import org.apache.atlas.omrs.metadatacollection.OMRSMetadataCollectionBase;
+
+/**
+ * The IGCV2OMRSMetadataCollection represents a remote IBM Information Governance Catalog (IGC)
+ * metadata repository. IGC supports its own native REST APIs.
+ * Requests to this metadata collection are translated to the IGC REST API calls and the results are
+ * transformed to OMRS objects before returning to the caller.
+ */
+public class IGCV2OMRSMetadataCollection extends OMRSMetadataCollectionBase
+{
+ private IGCV2OMRSRepositoryConnector parentConnector = null;
+
+ /**
+ * Default constructor.
+ *
+ * @param parentConnector - connector that this metadata collection supports. The connector has the information
+ * to call the metadata repository.
+ * @param metadataCollectionId - unique identifier for the repository.
+ */
+ public IGCV2OMRSMetadataCollection(IGCV2OMRSRepositoryConnector parentConnector,
+ String metadataCollectionId)
+ {
+ /*
+ * The metadata collection Id is the unique Id for the metadata collection. It is managed by the super class.
+ */
+ super(metadataCollectionId);
+ this.metadataCollectionId = metadataCollectionId;
+
+ /*
+ * Save parentConnector since this has the connection information.
+ */
+ this.parentConnector = parentConnector;
+
+ /*
+ * This is a temporary implementation to allow the structural implementation of the connectors to
+ * be committed before the metadata collection implementation is complete.
+ */
+ throw new NotImplementedRuntimeException("IGCV2OMRSMetadataCollection", "constructor", "ATLAS-1774");
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/adapters/igc/v2/repositoryconnector/IGCV2OMRSRepositoryConnector.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/adapters/igc/v2/repositoryconnector/IGCV2OMRSRepositoryConnector.java b/omrs/src/main/java/org/apache/atlas/omrs/adapters/igc/v2/repositoryconnector/IGCV2OMRSRepositoryConnector.java
new file mode 100644
index 0000000..5b68cb4
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/adapters/igc/v2/repositoryconnector/IGCV2OMRSRepositoryConnector.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.adapters.igc.v2.repositoryconnector;
+
+import org.apache.atlas.ocf.ffdc.ConnectorCheckedException;
+import org.apache.atlas.omrs.adapters.igc.v1.repositoryconnector.IGCOMRSMetadataCollection;
+import org.apache.atlas.omrs.metadatacollection.OMRSMetadataCollection;
+import org.apache.atlas.omrs.metadatacollection.repositoryconnector.OMRSRepositoryConnector;
+
+
+/**
+ * The IGCV2OMRSRepositoryConnector is a connector to a remote IBM Information Governance Catalog (IGC) repository
+ * for releases after 11.7.
+ */
+public class IGCV2OMRSRepositoryConnector extends OMRSRepositoryConnector
+{
+ private IGCV2OMRSMetadataCollection metadataCollection = null;
+ private String metadataCollectionId = null;
+
+ /**
+ * Default constructor used by the OCF Connector Provider.
+ */
+ public IGCV2OMRSRepositoryConnector()
+ {
+ /*
+ * Nothing to do (yet !)
+ */
+ }
+
+
+ /**
+ * Set up the unique Id for this metadata collection.
+ *
+ * @param metadataCollectionId - String unique Id
+ */
+ public void setMetadataCollectionId(String metadataCollectionId)
+ {
+ this.metadataCollectionId = metadataCollectionId;
+
+ /*
+ * Initialize the metadata collection only once the connector is properly set up.
+ */
+ metadataCollection = new IGCV2OMRSMetadataCollection(this, metadataCollectionId);
+ }
+
+
+ /**
+ * Returns the metadata collection object that provides an OMRS abstraction of the metadata within
+ * a metadata repository.
+ *
+ * @return OMRSMetadataCollection - metadata information retrieved from the metadata repository.
+ */
+ public OMRSMetadataCollection getMetadataCollection()
+ {
+ if (metadataCollection == null)
+ {
+ // TODO Throw exception since it means the local metadata collection id is not set up.
+ }
+ return metadataCollection;
+ }
+
+
+ /**
+ * Free up any resources held since the connector is no longer needed.
+ *
+ * @throws ConnectorCheckedException - there is a problem disconnecting the connector.
+ */
+ public void disconnect() throws ConnectorCheckedException
+ {
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/adapters/igc/v2/repositoryconnector/IGCV2OMRSRepositoryConnectorProvider.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/adapters/igc/v2/repositoryconnector/IGCV2OMRSRepositoryConnectorProvider.java b/omrs/src/main/java/org/apache/atlas/omrs/adapters/igc/v2/repositoryconnector/IGCV2OMRSRepositoryConnectorProvider.java
new file mode 100644
index 0000000..717f99d
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/adapters/igc/v2/repositoryconnector/IGCV2OMRSRepositoryConnectorProvider.java
@@ -0,0 +1,45 @@
+/*
+ * 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.adapters.igc.v2.repositoryconnector;
+
+import org.apache.atlas.omrs.adapters.igc.v1.repositoryconnector.IGCOMRSRepositoryConnector;
+import org.apache.atlas.omrs.metadatacollection.repositoryconnector.OMRSRepositoryConnectorProviderBase;
+
+/**
+ * In the Open Connector Framework (OCF), a ConnectorProvider is a factory for a specific type of connector.
+ * The IGCV2OMRSRepositoryConnectorProvider is the connector provider for the IGCV2OMRSRepositoryConnector.
+ * It extends OMRSRepositoryConnectorProviderBase which in turn extends the OCF ConnectorProviderBase.
+ * ConnectorProviderBase supports the creation of connector instances.
+ *
+ * The IGCV2OMRSRepositoryConnectorProvider must initialize ConnectorProviderBase with the Java class
+ * name of the OMRS Connector implementation (by calling super.setConnectorClassName(className)).
+ * Then the connector provider will work.
+ */
+public class IGCV2OMRSRepositoryConnectorProvider extends OMRSRepositoryConnectorProviderBase
+{
+ /**
+ * Constructor used to initialize the ConnectorProviderBase with the Java class name of the specific
+ * OMRS Connector implementation.
+ */
+ public IGCV2OMRSRepositoryConnectorProvider()
+ {
+ Class connectorClass = IGCV2OMRSRepositoryConnector.class;
+
+ super.setConnectorClassName(connectorClass.getName());
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/admin/OMRSConfigurationFactory.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/admin/OMRSConfigurationFactory.java b/omrs/src/main/java/org/apache/atlas/omrs/admin/OMRSConfigurationFactory.java
new file mode 100644
index 0000000..c626fa0
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/admin/OMRSConfigurationFactory.java
@@ -0,0 +1,228 @@
+/*
+ * 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.admin;
+
+import org.apache.atlas.ocf.properties.*;
+import org.apache.atlas.omrs.admin.properties.*;
+import org.apache.atlas.omrs.metadatahighway.cohortregistry.store.file.FileBasedRegistryStoreProvider;
+import org.apache.atlas.omrs.metadatacollection.properties.typedefs.TypeDefSummary;
+import org.apache.atlas.omrs.topicconnectors.kafka.KafkaOMRSTopicProvider;
+
+import java.util.ArrayList;
+import java.util.UUID;
+
+
+/**
+ * OMRSConfigurationFactory sets up default configuration for the OMRS components and manages the changes made
+ * by the server administrator.
+ */
+public class OMRSConfigurationFactory
+{
+ /*
+ * Default property fillers
+ */
+ private static final String defaultEnterpriseMetadataCollectionName = "Enterprise Metadata Collection";
+
+ private static final String defaultTopicRootName = "omag";
+ private static final String defaultTopicLeafName = "OMRSTopic";
+
+ private static final String defaultTopicConnectorLeafName = "OMRS Topic Connector";
+ private static final String defaultEnterpriseTopicConnectorRootName = "Enterprise";
+
+ private static final String defaultTopicConnectorName = "OMRS Kafka Topic Connector";
+ private static final String defaultTopicConnectorDescription = "Kafka Topic used to exchange event between members of an open metadata repository cluster.";
+ private static final String defaultTopicConnectorProviderClassName = KafkaOMRSTopicProvider.class.getName();
+
+ private static final String defaultCohortName = "defaultCohort";
+
+ private static final String defaultRegistryStoreFQName = "OMRS Cohort Registry Store: cohort.registry";
+ private static final String defaultRegistryStoreDisplayName = "Cohort Registry Store";
+ private static final String defaultRegistryStoreDescription = "File-based Store use by the cohort registry to store information about the members of the open metadata repository cluster.";
+ private static final String defaultRegistryStoreAddress = "cohort.registry";
+ private static final String defaultRegistryStoreProviderClassName = FileBasedRegistryStoreProvider.class.getName();
+
+
+
+ private String localServerName = null;
+ private String localServerType = null;
+ private String localServerURL = null;
+ private String localOrganizationName = null;
+ private RepositoryServicesConfig repositoryServicesConfig = null;
+
+
+ /**
+ * Constructor used when the server is being configured. Any parameter may be null.
+ *
+ * @param localServerName - name of the local server
+ * @param localServerType - type of the local server
+ * @param localServerURL - URL of the local server
+ * @param localOrganizationName - name of the organization that owns the local server
+ */
+ public OMRSConfigurationFactory(String localServerName,
+ String localServerType,
+ String localServerURL,
+ String localOrganizationName)
+ {
+ this.localServerName = localServerName;
+ this.localServerType = localServerType;
+ this.localServerURL = localServerURL;
+ this.localOrganizationName = localOrganizationName;
+ }
+
+ public Connection getGenericConnection()
+ {
+ return null;
+ }
+
+ public Connection getDefaultAuditLogConnection()
+ {
+ return null;
+ }
+
+ public Connection getDefaultOpenMetadataTypesArchiveConnection()
+ {
+ return null;
+ }
+
+ private Connection getGenericArchiveConnection()
+ {
+ return null;
+ }
+
+ private Connection getGenericRepositoryConnection()
+ {
+ return null;
+ }
+
+ private Connection getDefaultLocalRepositoryLocalConnection()
+ {
+ return null;
+ }
+
+ private Connection getAtlasLocalRepositoryLocalConnection()
+ {
+ return null;
+ }
+
+ private Connection getDefaultLocalRepositoryRemoteConnection(String localServerURL)
+ {
+ return null;
+ }
+
+ private Connection getDefaultEventMapperConnection()
+ {
+ return null;
+ }
+
+ public Connection getGenericEventMapperConnection()
+ {
+ return null;
+ }
+
+ private Connection getDefaultEnterpriseOMRSTopicConnection() { return null; }
+
+ private Connection getDefaultCohortOMRSTopicConnection () { return null; }
+
+ private Connection getDefaultCohortRegistryConnection ()
+ {
+ return null;
+ }
+
+ private OpenMetadataEventProtocolVersion getDefaultEnterpriseOMRSTopicProtocolVersion() { return OpenMetadataEventProtocolVersion.V1; }
+
+ private OpenMetadataEventProtocolVersion getDefaultCohortOMRSTopicProtocolVersion() { return OpenMetadataEventProtocolVersion.V1; }
+
+ private OpenMetadataExchangeRule getDefaultEventsToSendRule()
+ {
+ return OpenMetadataExchangeRule.ALL;
+ }
+
+ private ArrayList<TypeDefSummary> getDefaultSelectedTypesToSend() { return null; }
+
+ private OpenMetadataExchangeRule getDefaultEventsToSaveRule()
+ {
+ return OpenMetadataExchangeRule.ALL;
+ }
+
+ private ArrayList<TypeDefSummary> getDefaultSelectedTypesToSave() { return null; }
+
+ private OpenMetadataExchangeRule getDefaultEventsToProcessRule()
+ {
+ return OpenMetadataExchangeRule.ALL;
+ }
+
+ private ArrayList<TypeDefSummary> getDefaultSelectedTypesToProcess() { return null; }
+
+ private ArrayList<Connection> getDefaultOpenMetadataArchiveList()
+ {
+ ArrayList<Connection> openMetadataArchiveList = new ArrayList<>();
+
+ openMetadataArchiveList.add(this.getDefaultOpenMetadataTypesArchiveConnection());
+
+ return openMetadataArchiveList;
+ }
+
+ public LocalRepositoryConfig getDefaultLocalRepositoryConfig(String localServerURL)
+ {
+ LocalRepositoryConfig localRepositoryConfig = new LocalRepositoryConfig();
+
+ localRepositoryConfig.setMetadataCollectionId(UUID.randomUUID().toString());
+ localRepositoryConfig.setLocalRepositoryLocalConnection(this.getDefaultLocalRepositoryLocalConnection());
+ localRepositoryConfig.setLocalRepositoryRemoteConnection(this.getDefaultLocalRepositoryRemoteConnection(localServerURL));
+ localRepositoryConfig.setEventsToSaveRule(this.getDefaultEventsToSaveRule());
+ localRepositoryConfig.setSelectedTypesToSave(this.getDefaultSelectedTypesToSave());
+ localRepositoryConfig.setEventsToSendRule(this.getDefaultEventsToSendRule());
+ localRepositoryConfig.setSelectedTypesToSend(this.getDefaultSelectedTypesToSend());
+ localRepositoryConfig.setEventMapperConnection(this.getDefaultEventMapperConnection());
+
+ return localRepositoryConfig;
+ }
+
+ public EnterpriseAccessConfig getDefaultEnterpriseAccessConfig()
+ {
+ EnterpriseAccessConfig enterpriseAccessConfig = new EnterpriseAccessConfig();
+
+ enterpriseAccessConfig.setEnterpriseMetadataCollectionId(UUID.randomUUID().toString());
+ enterpriseAccessConfig.setEnterpriseMetadataCollectionName(defaultEnterpriseMetadataCollectionName);
+ enterpriseAccessConfig.setEnterpriseOMRSTopicConnection(this.getDefaultEnterpriseOMRSTopicConnection());
+ enterpriseAccessConfig.setEnterpriseOMRSTopicProtocolVersion(this.getDefaultEnterpriseOMRSTopicProtocolVersion());
+
+ return enterpriseAccessConfig;
+ }
+
+
+ /**
+ * Return a CohortConfig object that is pre-configured with default values.
+ *
+ * @return default values in a CohortConfig object
+ */
+ public CohortConfig getDefaultCohortConfig()
+ {
+ CohortConfig cohortConfig = new CohortConfig();
+
+ cohortConfig.setCohortName(defaultCohortName);
+ cohortConfig.setCohortRegistryConnection(this.getDefaultCohortRegistryConnection());
+ cohortConfig.setCohortOMRSTopicConnection(this.getDefaultCohortOMRSTopicConnection());
+ cohortConfig.setCohortOMRSTopicProtocolVersion(this.getDefaultCohortOMRSTopicProtocolVersion());
+ cohortConfig.setEventsToProcessRule(this.getDefaultEventsToProcessRule());
+ cohortConfig.setSelectedTypesToProcess(this.getDefaultSelectedTypesToProcess());
+
+ return cohortConfig;
+ }
+
+}
[17/30] atlas git commit: ATLAS-2246: OMRS Connector API plus REST
and IGC Connector skeleton - 15th February 2018
Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSInstanceEventProcessor.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSInstanceEventProcessor.java b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSInstanceEventProcessor.java
new file mode 100644
index 0000000..b2f0ceb
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSInstanceEventProcessor.java
@@ -0,0 +1,667 @@
+/*
+ * 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.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.TypeDefSummary;
+
+/**
+ * OMRSInstanceEventProcessor is an interface implemented by a component that is able to process incoming
+ * metadata instance events for an Open Metadata Repository. Instance events are used to replicate metadata
+ * instances across an Open Metadata Repository Cohort.
+ */
+public interface OMRSInstanceEventProcessor
+{
+ /**
+ * A new entity has been created.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param entity - details of the new entity
+ */
+ void processNewEntityEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ EntityDetail entity);
+
+
+ /**
+ * An existing entity has been updated.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param entity - details of the new version of the entity.
+ */
+ void processUpdatedEntityEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ EntityDetail entity);
+
+
+ /**
+ * An update to an entity has been undone.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param entity - details of the version of the entity that has been restored.
+ */
+ void processUndoneEntityEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ EntityDetail entity);
+
+
+ /**
+ * A new classification has been added to an entity.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param entity - details of the entity with the new classification added.
+ */
+ void processClassifiedEntityEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ EntityDetail entity);
+
+
+ /**
+ * A classification has been removed from an entity.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param entity - details of the entity after the classification has been removed.
+ */
+ void processDeclassifiedEntityEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ EntityDetail entity);
+
+
+ /**
+ * An existing classification has been changed on an entity.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param entity - details of the entity after the classification has been changed.
+ */
+ void processReclassifiedEntityEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ EntityDetail entity);
+
+
+ /**
+ * An existing entity has been deleted. This is a soft delete. This means it is still in the repository
+ * but it is no longer returned on queries.
+ *
+ * All relationships to the entity are also soft-deleted and will no longer be usable. These deleted relationships
+ * will be notified through separate events.
+ *
+ * Details of the TypeDef are included with the entity's unique id (guid) to ensure the right entity is deleted in
+ * the remote repositories.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param typeDefGUID - unique identifier for this entity's TypeDef
+ * @param typeDefName - name of this entity's TypeDef
+ * @param instanceGUID - unique identifier for the entity
+ */
+ void processDeletedEntityEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ String typeDefGUID,
+ String typeDefName,
+ String instanceGUID);
+
+
+ /**
+ * A deleted entity has been permanently removed from the repository. This request can not be undone.
+ *
+ * Details of the TypeDef are included with the entity's unique id (guid) to ensure the right entity is purged in
+ * the remote repositories.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param typeDefGUID - unique identifier for this entity's TypeDef
+ * @param typeDefName - name of this entity's TypeDef
+ * @param instanceGUID - unique identifier for the entity
+ */
+ void processPurgedEntityEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ String typeDefGUID,
+ String typeDefName,
+ String instanceGUID);
+
+
+ /**
+ * A deleted entity has been restored to the state it was before it was deleted.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param entity - details of the version of the entity that has been restored.
+ */
+ void processRestoredEntityEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ EntityDetail entity);
+
+
+ /**
+ * An existing entity has had its type changed. Typically this action is taken to move an entity's
+ * type to either a super type (so the subtype can be deleted) or a new subtype (so additional properties can be
+ * added.) However, the type can be changed to any compatible type.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param originalTypeDef - description of this entity's original TypeDef.
+ * @param entity - new values for this entity, including the new type information.
+ */
+ void processReTypedEntityEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ TypeDefSummary originalTypeDef,
+ EntityDetail entity);
+
+
+ /**
+ * An existing entity has changed home repository. This action is taken for example, if a repository
+ * becomes permanently unavailable, or if the user community updating this entity move to working
+ * from a different repository in the open metadata repository cluster.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param originalHomeMetadataCollectionId - unique identifier for the original home metadata collection/repository.
+ * @param entity - new values for this entity, including the new home information.
+ */
+ void processReHomedEntityEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ String originalHomeMetadataCollectionId,
+ EntityDetail entity);
+
+ /**
+ * The guid of an existing entity has been changed to a new value. This is used if two different
+ * entities are discovered to have the same guid. This is extremely unlikely but not impossible so
+ * the open metadata protocol has provision for this.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param originalEntityGUID - the existing identifier for the entity.
+ * @param entity - new values for this entity, including the new guid.
+ */
+ void processReIdentifiedEntityEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ String originalEntityGUID,
+ EntityDetail entity);
+
+
+ /**
+ * The local repository is requesting that an entity from another repository's metadata collection is
+ * refreshed so the local repository can create a reference copy.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param typeDefGUID - - unique identifier for this entity's TypeDef
+ * @param typeDefName - name of this entity's TypeDef
+ * @param instanceGUID - unique identifier for the entity
+ * @param homeMetadataCollectionId - metadata collection id for the home of this instance.
+ */
+ void processRefreshEntityRequested(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ String typeDefGUID,
+ String typeDefName,
+ String instanceGUID,
+ String homeMetadataCollectionId);
+
+
+ /**
+ * A remote repository in the cohort has sent entity details in response to a refresh request.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param entity - details of the requested entity
+ */
+ void processRefreshEntityEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ EntityDetail entity);
+
+ /**
+ * A new relationship has been created.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param relationship - details of the new relationship
+ */
+ void processNewRelationshipEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ Relationship relationship);
+
+
+ /**
+ * An existing relationship has been updated.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param relationship - details of the new version of the relationship.
+ */
+ void processUpdatedRelationshipEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ Relationship relationship);
+
+
+ /**
+ * An update to a relationship has been undone.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param relationship - details of the version of the relationship that has been restored.
+ */
+ void processUndoneRelationshipEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ Relationship relationship);
+
+
+ /**
+ * An existing relationship has been deleted. This is a soft delete. This means it is still in the repository
+ * but it is no longer returned on queries.
+ *
+ * Details of the TypeDef are included with the relationship's unique id (guid) to ensure the right
+ * relationship is deleted in the remote repositories.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param typeDefGUID - unique identifier for this relationship's TypeDef
+ * @param typeDefName - name of this relationship's TypeDef
+ * @param instanceGUID - unique identifier for the relationship
+ */
+ void processDeletedRelationshipEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ String typeDefGUID,
+ String typeDefName,
+ String instanceGUID);
+
+
+ /**
+ * A deleted relationship has been permanently removed from the repository. This request can not be undone.
+ *
+ * Details of the TypeDef are included with the relationship's unique id (guid) to ensure the right
+ * relationship is purged in the remote repositories.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param typeDefGUID - unique identifier for this relationship's TypeDef.
+ * @param typeDefName - name of this relationship's TypeDef.
+ * @param instanceGUID - unique identifier for the relationship.
+ */
+ void processPurgedRelationshipEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ String typeDefGUID,
+ String typeDefName,
+ String instanceGUID);
+
+
+ /**
+ * A deleted relationship has been restored to the state it was before it was deleted.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param relationship - details of the version of the relationship that has been restored.
+ */
+ void processRestoredRelationshipEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ Relationship relationship);
+
+
+ /**
+ * An existing relationship has had its type changed. Typically this action is taken to move a relationship's
+ * type to either a super type (so the subtype can be deleted) or a new subtype (so additional properties can be
+ * added.) However, the type can be changed to any compatible type.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param originalTypeDef - description of this relationship's original TypeDef.
+ * @param relationship - new values for this relationship, including the new type information.
+ */
+ void processReTypedRelationshipEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ TypeDefSummary originalTypeDef,
+ Relationship relationship);
+
+
+ /**
+ * An existing relationship has changed home repository. This action is taken for example, if a repository
+ * becomes permanently unavailable, or if the user community updating this relationship move to working
+ * from a different repository in the open metadata repository cluster.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param originalHomeMetadataCollectionId - unique identifier for the original home repository.
+ * @param relationship - new values for this relationship, including the new home information.
+ */
+ void processReHomedRelationshipEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ String originalHomeMetadataCollectionId,
+ Relationship relationship);
+
+
+ /**
+ * The guid of an existing relationship has changed. This is used if two different
+ * relationships are discovered to have the same guid. This is extremely unlikely but not impossible so
+ * the open metadata protocol has provision for this.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param originalRelationshipGUID - the existing identifier for the relationship.
+ * @param relationship - new values for this relationship, including the new guid.
+ */
+ void processReIdentifiedRelationshipEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ String originalRelationshipGUID,
+ Relationship relationship);
+
+
+
+ /**
+ * An open metadata repository has requested the home repository of a relationship send details of the relationship so
+ * its local metadata collection can create a reference copy of the instance.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param typeDefGUID - unique identifier for this instance's TypeDef
+ * @param typeDefName - name of this relationship's TypeDef
+ * @param instanceGUID - unique identifier for the instance
+ * @param homeMetadataCollectionId - metadata collection id for the home of this instance.
+ */
+ void processRefreshRelationshipRequest(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ String typeDefGUID,
+ String typeDefName,
+ String instanceGUID,
+ String homeMetadataCollectionId);
+
+
+ /**
+ * An open metadata repository is refreshing the information about a relationship for the other
+ * repositories in the cohort.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param relationship - relationship details
+ */
+ void processRefreshRelationshipEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ Relationship relationship);
+
+
+ /**
+ * An open metadata repository has detected two metadata instances with the same identifier (guid).
+ * This is a serious error because it could lead to corruption of the metadata collections within the cohort.
+ * When this occurs, all repositories in the cohort delete their reference copies of the metadata instances and
+ * at least one of the instances has its GUID changed in its respective home repository. The updated instance(s)
+ * are redistributed around the cohort.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - metadata collection id of the repository reporting the conflicting instance
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param targetMetadataCollectionId - metadata collection id of other repository with the conflicting instance
+ * @param targetTypeDef - details 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 otherTypeDef - details of the other (older) instance's TypeDef
+ * @param otherInstanceGUID - unique identifier for the other (older) instance
+ * @param errorMessage - description of the error.
+ */
+ void processConflictingInstancesEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ String targetMetadataCollectionId,
+ TypeDefSummary targetTypeDef,
+ String targetInstanceGUID,
+ String otherMetadataCollectionId,
+ InstanceProvenanceType otherOrigin,
+ TypeDefSummary otherTypeDef,
+ String otherInstanceGUID,
+ String errorMessage);
+
+
+ /**
+ * An open metadata repository has detected an inconsistency in the version number of the type used in an updated metadata
+ * instance compared to its stored version.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - metadata collection id of the repository reporting the conflicting instance
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param targetMetadataCollectionId - metadata collection id of other repository with the conflicting instance
+ * @param targetTypeDef - description of the target instance's TypeDef
+ * @param targetInstanceGUID - unique identifier for the source instance
+ * @param otherTypeDef - details of the other (older) instance's TypeDef
+ * @param errorMessage - description of the error.
+ */
+ void processConflictingTypeEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ String targetMetadataCollectionId,
+ TypeDefSummary targetTypeDef,
+ String targetInstanceGUID,
+ TypeDefSummary otherTypeDef,
+ String errorMessage);
+}
+
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSInstanceEventType.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSInstanceEventType.java b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSInstanceEventType.java
new file mode 100644
index 0000000..8d94980
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSInstanceEventType.java
@@ -0,0 +1,148 @@
+/*
+ * 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;
+
+/**
+ * OMRSInstanceEventType defines the different types of instance events in the open metadata repository services
+ * protocol.
+ */
+public enum OMRSInstanceEventType
+{
+ UNKNOWN_INSTANCE_EVENT (0, "UnknownInstanceEvent",
+ "An event that is not recognized by the local server."),
+ NEW_ENTITY_EVENT (1, "NewEntityEvent",
+ "A new entity has been created."),
+ UPDATED_ENTITY_EVENT (2, "UpdatedEntityEvent",
+ "An existing entity has been updated."),
+ UNDONE_ENTITY_EVENT (3, "UndoneEntityEvent",
+ "An update to an entity has been undone."),
+ CLASSIFIED_ENTITY_EVENT (4, "ClassifiedEntityEvent",
+ "A new classification has been added to an entity."),
+ DECLASSIFIED_ENTITY_EVENT (5, "DeclassifiedEntityEvent",
+ "A classification has been removed from an entity."),
+ RECLASSIFIED_ENTITY_EVENT (6, "ReclassifiedEntityEvent",
+ "An existing classification has been changed on an entity."),
+ DELETED_ENTITY_EVENT (7, "DeletedEntityEvent",
+ "An existing entity has been deleted. This is a soft delete. " +
+ "This means it is still in the repository " +
+ "but it is no longer returned on queries."),
+ PURGED_ENTITY_EVENT (8, "PurgedEntityEvent",
+ "A deleted entity has been permanently removed from the repository. " +
+ "This request can not be undone."),
+ RESTORED_ENTITY_EVENT (9, "RestoredEntityEvent",
+ "A deleted entity has been restored to the state it was before it was deleted."),
+ RE_IDENTIFIED_ENTITY_EVENT (10, "ReIdentifiedEntityEvent",
+ "The guid of an existing entity has been changed to a new value."),
+ RETYPED_ENTITY_EVENT (11, "ReTypedEntityEvent",
+ "An existing entity has had its type changed."),
+ RE_HOMED_ENTITY_EVENT (12, "ReHomedEntityEvent",
+ "An existing entity has changed home repository."),
+ REFRESH_ENTITY_REQUEST (13, "RefreshEntityRequestEvent",
+ "The local repository is requesting that an entity from another repository's " +
+ "metadata collection is " +
+ "refreshed so the local repository can create a reference copy."),
+ REFRESHED_ENTITY_EVENT (14, "RefreshedEntityEvent",
+ "A remote repository in the cohort has sent entity details in response " +
+ "to a refresh request."),
+ NEW_RELATIONSHIP_EVENT (15, "NewRelationshipEvent",
+ "A new relationship has been created."),
+ UPDATED_RELATIONSHIP_EVENT (16, "UpdateRelationshipEvent",
+ "An existing relationship has been updated."),
+ UNDONE_RELATIONSHIP_EVENT (17, "UndoneRelationshipEvent",
+ "An earlier change to a relationship has been undone."),
+ DELETED_RELATIONSHIP_EVENT (18, "DeletedRelationshipEvent",
+ "An existing relationship has been deleted. This is a soft delete. " +
+ "This means it is still in the repository " +
+ "but it is no longer returned on queries."),
+ PURGED_RELATIONSHIP_EVENT (19, "PurgedRelationshipEvent",
+ "A deleted relationship has been permanently removed from the repository. " +
+ "This request can not be undone."),
+ RESTORED_RELATIONSHIP_EVENT (20, "RestoredRelationshipEvent",
+ "A deleted relationship has been restored to the state it was before it was deleted."),
+ RE_IDENTIFIED_RELATIONSHIP_EVENT(21, "ReIdentifiedRelationshipEvent",
+ "The guid of an existing relationship has changed."),
+ RETYPED_RELATIONSHIP_EVENT (22, "ReTypedRelationshipEvent",
+ "An existing relationship has had its type changed."),
+ RE_HOMED_RELATIONSHIP_EVENT (23, "ReHomedRelationshipEvent",
+ "An existing relationship has changed home repository."),
+ REFRESH_RELATIONSHIP_REQUEST (24, "RefreshRelationshipRequestEvent",
+ "A repository has requested the home repository of a relationship send " +
+ "details of hte relationship so " +
+ "the local repository can create a reference copy of the instance."),
+ REFRESHED_RELATIONSHIP_EVENT (25, "RefreshedRelationshipEvent",
+ "The local repository is refreshing the information about a relationship for the " +
+ "other repositories in the cohort."),
+ INSTANCE_ERROR_EVENT (99, "InstanceErrorEvent",
+ "An error has been detected in the exchange of instances between members of the cohort.")
+ ;
+
+
+ private int eventTypeCode;
+ private String eventTypeName;
+ private String eventTypeDescription;
+
+
+ /**
+ * Default Constructor - sets up the specific values for this instance of the enum.
+ *
+ * @param eventTypeCode - int identifier used for indexing based on the enum.
+ * @param eventTypeName - string name used for messages that include the enum.
+ * @param eventTypeDescription - default description for the enum value - used when natural resource
+ * bundle is not available.
+ */
+ OMRSInstanceEventType(int eventTypeCode, String eventTypeName, String eventTypeDescription)
+ {
+ this.eventTypeCode = eventTypeCode;
+ this.eventTypeName = eventTypeName;
+ this.eventTypeDescription = eventTypeDescription;
+ }
+
+
+ /**
+ * Return the int identifier used for indexing based on the enum.
+ *
+ * @return int identifier code
+ */
+ public int getInstanceEventTypeCode()
+ {
+ return eventTypeCode;
+ }
+
+
+ /**
+ * Return the string name used for messages that include the enum.
+ *
+ * @return String name
+ */
+ public String getInstanceEventTypeName()
+ {
+ return eventTypeName;
+ }
+
+
+ /**
+ * Return the default description for the enum value - used when natural resource
+ * bundle is not available.
+ *
+ * @return String default description
+ */
+ public String getInstanceEventTypeDescription()
+ {
+ return eventTypeDescription;
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSRegistryEvent.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSRegistryEvent.java b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSRegistryEvent.java
new file mode 100644
index 0000000..6db78a0
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSRegistryEvent.java
@@ -0,0 +1,289 @@
+/*
+ * 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.OMRSEventV1RegistrySection;
+import org.apache.atlas.omrs.metadatacollection.properties.typedefs.TypeDefSummary;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.Date;
+
+
+/**
+ * OMRSRegistryEvent provides the conversion between the properties of a registry event and the serialized event body.
+ * It supports conversion in either direction through its inner class called OMRSRegistryEventPayload:
+ * <ul>
+ * <li>
+ * Converting from registry event properties to an OMRSEvent body for sending outbound events.
+ * </li>
+ * <li>
+ * Converting from an event body to registry event properties for inbound events.
+ * </li>
+ * </ul>
+ * OMRSRegistryEvent also provides a specialized interface to allow the cohort registry to work effectively
+ * with registry events.
+ */
+public class OMRSRegistryEvent extends OMRSEvent
+{
+ /*
+ * The type of the registry event that defines how the rest of the values should be interpreted.
+ */
+ private OMRSRegistryEventType registryEventType = OMRSRegistryEventType.UNKNOWN_REGISTRY_EVENT;
+
+ /*
+ * Registration information describing a specific repository.
+ */
+ private Date registrationTimestamp = null;
+ private Connection remoteConnection = null;
+
+ /*
+ * Used in the registration process to enable the repositories to detect incompatible TypeDefs.
+ */
+ private ArrayList<TypeDefSummary> typeDefSummaries = null;
+
+ /*
+ * Specific variables only used in error reporting. It defines the subset of error codes from OMRSEvent
+ * that are specific to registry events.
+ */
+ private OMRSRegistryEventErrorCode errorCode = OMRSRegistryEventErrorCode.NOT_IN_USE;
+
+
+ private static final Logger log = LoggerFactory.getLogger(OMRSRegistryEvent.class);
+
+
+ /**
+ * Inbound event constructor that takes the object created by the Jackson JSON mapper and unpacks the
+ * properties into the registry event.
+ *
+ * @param inboundEvent - incoming Event.
+ */
+ public OMRSRegistryEvent(OMRSEventV1 inboundEvent)
+ {
+ super(inboundEvent);
+
+ OMRSEventV1RegistrySection registrySection = inboundEvent.getRegistryEventSection();
+
+ if (registrySection != null)
+ {
+ this.registryEventType = registrySection.getRegistryEventType();
+ this.registrationTimestamp = registrySection.getRegistrationTimestamp();
+ this.remoteConnection = registrySection.getRemoteConnection();
+ this.typeDefSummaries = registrySection.getTypeDefList();
+ }
+
+ if (super.genericErrorCode != null)
+ {
+ switch (errorCode)
+ {
+ case BAD_REMOTE_CONNECTION:
+ this.errorCode = OMRSRegistryEventErrorCode.BAD_REMOTE_CONNECTION;
+ break;
+
+ case CONFLICTING_COLLECTION_ID:
+ this.errorCode = OMRSRegistryEventErrorCode.CONFLICTING_COLLECTION_ID;
+ break;
+
+ default:
+ this.errorCode = OMRSRegistryEventErrorCode.UNKNOWN_ERROR_CODE;
+ }
+ }
+ }
+
+
+ /**
+ * Constructor for a normal outbound event. It sets the event type and the other parameters
+ * used in a registry event payload.
+ *
+ * @param registryEventType - type of event (REGISTRATION_EVENT, REFRESH_REGISTRATION_REQUEST, RE_REGISTRATION_EVENT)
+ * @param registrationTimestamp - time that the local repository registered.
+ * @param remoteConnection - remote connection to this local repository.
+ * @param typeDefSummaries - Summary list of supported TypeDefs
+ */
+ public OMRSRegistryEvent(OMRSRegistryEventType registryEventType,
+ Date registrationTimestamp,
+ Connection remoteConnection,
+ ArrayList<TypeDefSummary> typeDefSummaries)
+ {
+ super(OMRSEventCategory.REGISTRY);
+
+ this.registryEventType = registryEventType;
+ this.registrationTimestamp = registrationTimestamp;
+ this.remoteConnection = remoteConnection;
+ this.typeDefSummaries = typeDefSummaries;
+ }
+
+
+ /**
+ * Constructor for an UnRegistration Event.
+ *
+ * @param registryEventType - the type of event
+ */
+ public OMRSRegistryEvent(OMRSRegistryEventType registryEventType)
+ {
+ super(OMRSEventCategory.REGISTRY);
+
+ this.registryEventType = registryEventType;
+ }
+
+
+ /**
+ * Constructor for the REGISTRATION_ERROR_EVENT outbound event.
+ *
+ * @param errorCode - detailed error code
+ * @param errorMessage - Optional error message
+ * @param targetMetadataCollectionId - the identifier of the server that sent bad information.
+ * @param remoteConnection - remote connection to the target repository. (Optional - only supplied if
+ * relevant to the reported error; otherwise null.)
+ */
+ public OMRSRegistryEvent(OMRSRegistryEventErrorCode errorCode,
+ String errorMessage,
+ String targetMetadataCollectionId,
+ Connection remoteConnection)
+ {
+ super(OMRSEventCategory.REGISTRY,
+ errorCode.getErrorCodeEncoding(),
+ errorMessage,
+ targetMetadataCollectionId,
+ remoteConnection);
+
+ this.registryEventType = OMRSRegistryEventType.REGISTRATION_ERROR_EVENT;
+ }
+
+
+ /**
+ * Return the specific registry event type.
+ *
+ * @return registry event type enum
+ */
+ public OMRSRegistryEventType getRegistryEventType()
+ {
+ return registryEventType;
+ }
+
+
+ /**
+ * Return the date/time that the repository registered with the open metadata repository cohort.
+ * If this is a normal registry event then this timestamp is the registration time for the local repository.
+ * If this an error event, then this is the registration time for the target repository.
+ *
+ * @return Date object for timestamp
+ */
+ public Date getRegistrationTimestamp()
+ {
+ return registrationTimestamp;
+ }
+
+
+ /**
+ * Return the remote connection used to create a connector used to call the repository across the network.
+ * If this is a normal registry event then this connection is for the local repository.
+ * If this an error event, then this is the connection for the target repository.
+ *
+ * @return Connection object
+ */
+ public Connection getRemoteConnection()
+ {
+ return remoteConnection;
+ }
+
+
+ /**
+ * Return the list of TypeDef summaries included in the event.
+ * If this is a normal registry event then these TypeDefs are from the local repository.
+ * If this an error event, then these TypeDefs are from the targeted repository.
+ *
+ * @return TypeDefSummaries object
+ */
+ public ArrayList<TypeDefSummary> getTypeDefSummaries()
+ {
+ return typeDefSummaries;
+ }
+
+
+ /**
+ * Return the error code for the event. This property is only used for error events.
+ *
+ * @return OMRSRegistryEventErrorCode enum
+ */
+ public OMRSRegistryEventErrorCode getErrorCode()
+ {
+ return errorCode;
+ }
+
+
+ /**
+ * Returns an OMRSEvent populated with details from this RegistryEvent
+ *
+ * @return OMRSEvent (Version 1) object
+ */
+ public OMRSEventV1 getOMRSEventV1()
+ {
+ OMRSEventV1 omrsEvent = super.getOMRSEventV1();
+
+ OMRSEventV1RegistrySection registrySection = new OMRSEventV1RegistrySection();
+
+ registrySection.setRegistryEventType(this.registryEventType);
+ registrySection.setRegistrationTimestamp(this.registrationTimestamp);
+ registrySection.setRemoteConnection(this.remoteConnection);
+ registrySection.setTypeDefList(this.typeDefSummaries);
+
+ omrsEvent.setRegistryEventSection(registrySection);
+
+ return omrsEvent;
+ }
+
+
+ /**
+ * Standard toString method.
+ *
+ * @return JSON style description of variables.
+ */
+ @Override
+ public String toString()
+ {
+ return "OMRSRegistryEvent{" +
+ "registryEventType=" + registryEventType +
+ ", registrationTimestamp=" + registrationTimestamp +
+ ", remoteConnection=" + remoteConnection +
+ ", typeDefSummaries=" + typeDefSummaries +
+ ", 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/OMRSRegistryEventErrorCode.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSRegistryEventErrorCode.java b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSRegistryEventErrorCode.java
new file mode 100644
index 0000000..95022cd
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSRegistryEventErrorCode.java
@@ -0,0 +1,126 @@
+/*
+ * 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;
+
+/**
+ * OMRSRegistryEventErrorCode defines the list of error codes that are used to record errors in the registration
+ * process that is used by the cluster registries when managing the membership of 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>
+ * <li>
+ * CONFLICTING_REPOSITORY_ID - Remote server/repository is using the same metadata collection id as the local server.
+ * </li>
+ * <li>
+ * CONFLICTING_TYPEDEFS - There are conflicting type definitions (TypeDefs) detected between two repositories
+ * in the open metadata repository cluster.
+ * </li>
+ * </ul>
+ */
+public enum OMRSRegistryEventErrorCode
+{
+ NOT_IN_USE (0, "No Error",
+ "There has been no error detected and so the error code is not in use.",
+ null),
+ CONFLICTING_COLLECTION_ID (1, "Conflicting metadata collection Id",
+ "Remote server/repository is using the same metadata collection id as the local server.",
+ OMRSEventErrorCode.CONFLICTING_COLLECTION_ID),
+ BAD_REMOTE_CONNECTION (2, "Unusable Remote Connection to Repository",
+ "The remote connection send by one of the member of the cohort is resulting in errors " +
+ "when it is used to create an OMRS Connector to the repository.",
+ OMRSEventErrorCode.BAD_REMOTE_CONNECTION),
+ 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 ;
+
+
+ /**
+ * Typical 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
+ */
+ OMRSRegistryEventErrorCode(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
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSRegistryEventProcessor.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSRegistryEventProcessor.java b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSRegistryEventProcessor.java
new file mode 100644
index 0000000..91ae433
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSRegistryEventProcessor.java
@@ -0,0 +1,159 @@
+/*
+ * 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.metadatacollection.properties.typedefs.TypeDefSummary;
+
+import java.util.ArrayList;
+import java.util.Date;
+
+/**
+ * OMRSRegistryEventProcessor is an interface implemented by a component that is able to process
+ * registry events for an Open Metadata Repository's membership of an Open Metadata Repository Cohort.
+ */
+public interface OMRSRegistryEventProcessor
+{
+ /**
+ * Introduces a new server/repository to the metadata repository cohort.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection that is registering with the cohort.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param registrationTimestamp - the time that the server/repository issued the registration request.
+ * @param remoteConnection - the Connection properties for the connector used to call the registering server.
+ * @param typeDefList - the list of TypeDefs supported by the registering server/repository.
+ * @return flag indicating if the event was sent or not.
+ */
+ boolean processRegistrationEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ Date registrationTimestamp,
+ Connection remoteConnection,
+ ArrayList<TypeDefSummary> typeDefList);
+
+
+ /**
+ * Requests that the other servers in the cohort send re-registration events.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @return flag indicating if the event was sent or not.
+ */
+ boolean processRegistrationRefreshRequest(String sourceName,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName);
+
+
+ /**
+ * Refreshes the other servers in the cohort with the originating server's registration.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection that is registering with the cohort.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param registrationTimestamp - the time that the server/repository first registered with the cohort.
+ * @param remoteConnection - the Connection properties for the connector used to call the registering server.
+ * @param typeDefList - the list of TypeDefs supported by the registering server/repository.
+ * @return flag indicating if the event was sent or not.
+ */
+ boolean processReRegistrationEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ Date registrationTimestamp,
+ Connection remoteConnection,
+ ArrayList<TypeDefSummary> typeDefList);
+
+
+ /**
+ * A server/repository is being removed from the metadata repository cohort.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - metadata collectionId of originator.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @return flag indicating if the event was sent or not.
+ */
+ boolean processUnRegistrationEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName);
+
+
+ /**
+ * There is more than one member of the open metadata repository cohort that is using the same metadata
+ * collection Id. This means that their metadata instances can be updated in more than one server and their
+ * is a potential for data integrity issues.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - metadata collectionId of originator.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param conflictingMetadataCollectionId - unique identifier for the metadata collection that is registering with the cohort.
+ * @param errorMessage - details of the conflict
+ */
+ void processConflictingCollectionIdEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ String conflictingMetadataCollectionId,
+ String errorMessage);
+
+
+ /**
+ * A connection to one of the members of the open metadata repository cohort is not usable by one of the members.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - metadata collectionId of originator.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param targetMetadataCollectionId - Id for the repository with the bad remote connection.
+ * @param remoteConnection - the Connection properties for the connector used to call the registering server.
+ * @param errorMessage - details of the error that occurs when the connection is used.
+ */
+ void processBadConnectionEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ String targetMetadataCollectionId,
+ Connection remoteConnection,
+ String errorMessage);
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSRegistryEventType.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSRegistryEventType.java b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSRegistryEventType.java
new file mode 100644
index 0000000..5dcd411
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSRegistryEventType.java
@@ -0,0 +1,128 @@
+/*
+ * 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;
+
+/**
+ * OMRSRegistryEventType defines the different types of registry events in the open metadata repository services
+ * protocol. There are 4 basic values.
+ * <ul>
+ * <li>
+ * UNKNOWN_REGISTRY_EVENT - the event is not recognized by this local server, probably because it is back-level
+ * from other servers in the cohort. It is logged in the audit log and then ignored. The registration
+ * protocol should evolve so that new message types can be ignored by back-level servers without damage
+ * to the cohort's integrity.
+ * </li>
+ * <li>
+ * REGISTRATION_EVENT - this event is a server's first contact with the cohort. It publicises the id of the
+ * local repository, the connection information needed to connect remotely to this local server's
+ * repository (localServerRemoteConnection) plus a list of typedef names and GUIDs. Other servers in the
+ * cohort will respond either with a RE_REGISTRATION_EVENT if all is ok or REGISTRATION_ERROR if there
+ * is a problem with any information in the REGISTRATION_EVENT.
+ * </li>
+ * <li>
+ * REFRESH_REGISTRATION_EVENT - this event is used after a local server has experienced configuration issues
+ * and needs to receive the registration information from other members of the cohort again.
+ * </li>
+ * <li>
+ * RE_REGISTRATION_EVENT - this event is used by a previously registered server to broadcast its current
+ * configuration. It is used in response to a REGISTRATION_EVENT and a REFRESH_REGISTRATION_EVENT to
+ * let the other servers know about its configuration, or whenever its configuration may have changed
+ * (such as after a server restart or administrator action).
+ * </li>
+ * <li>
+ * UN_REGISTRATION_EVENT - this event is used when a server is being removed from the cohort. The other
+ * servers can choose whether to remove its replicated metadata from their repository, or mark it as
+ * deregistered repository's metadata.
+ * </li>
+ * <li>
+ * REGISTRATION_ERROR_EVENT - ths event is used to report anomalies in the registration information being
+ * passed between the repositories and the actions taken. Each of these errors should be investigated
+ * since they should not occur.
+ * </li>
+ * </ul>
+ */
+public enum OMRSRegistryEventType
+{
+ UNKNOWN_REGISTRY_EVENT (0, "UnknownRegistryEvent",
+ "An event that is not recognized by the local server."),
+ REGISTRATION_EVENT (1, "RegistrationEvent",
+ "Introduces a new server/repository to the metadata repository cohort."),
+ REFRESH_REGISTRATION_REQUEST (2, "RefreshRegistrationRequest",
+ "Requests that the other servers in the cohort send re-registration events."),
+ RE_REGISTRATION_EVENT (3, "ReRegistrationEvent",
+ "Refreshes the other servers in the cohort with the local server's configuration."),
+ UN_REGISTRATION_EVENT (4, "UnRegistrationEvent",
+ "A server/repository is being removed from the metadata repository cohort."),
+ REGISTRATION_ERROR_EVENT (99, "RegistrationErrorEvent",
+ "An anomaly has been detected in the information received from a member in the metadata repository cohort.");
+
+
+ private int registryEventTypeCode;
+ private String registryEventTypeName;
+ private String registryEventTypeDescription;
+
+
+ /**
+ * Default Constructor - sets up the specific values for this instance of the enum.
+ *
+ * @param registryEventTypeCode - int identifier used for indexing based on the enum.
+ * @param registryEventTypeName - string name used for messages that include the enum.
+ * @param registryEventTypeDescription - default description for the enum value - used when natural resource
+ * bundle is not available.
+ */
+ OMRSRegistryEventType(int registryEventTypeCode, String registryEventTypeName, String registryEventTypeDescription)
+ {
+ this.registryEventTypeCode = registryEventTypeCode;
+ this.registryEventTypeName = registryEventTypeName;
+ this.registryEventTypeDescription = registryEventTypeDescription;
+ }
+
+
+ /**
+ * Return the int identifier used for indexing based on the enum.
+ *
+ * @return int identifier code
+ */
+ public int getRegistryEventTypeCode()
+ {
+ return registryEventTypeCode;
+ }
+
+
+ /**
+ * Return the string name used for messages that include the enum.
+ *
+ * @return String name
+ */
+ public String getRegistryEventTypeName()
+ {
+ return registryEventTypeName;
+ }
+
+
+ /**
+ * Return the default description for the enum value - used when natural resource
+ * bundle is not available.
+ *
+ * @return String default description
+ */
+ public String getRegistryEventTypeDescription()
+ {
+ return registryEventTypeDescription;
+ }
+}
[05/30] atlas git commit: ATLAS-2246: OMRS Connector API plus REST
and IGC Connector skeleton - 15th February 2018
Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/InstancePropertyValue.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/InstancePropertyValue.java b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/InstancePropertyValue.java
new file mode 100644
index 0000000..08ec988
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/InstancePropertyValue.java
@@ -0,0 +1,114 @@
+/*
+ * 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.metadatacollection.properties.instances;
+
+public class InstancePropertyValue extends InstanceElementHeader
+{
+ /*
+ * Common type information - this is augmented by the subclasses
+ */
+ private InstancePropertyCategory instancePropertyCategory = InstancePropertyCategory.UNKNOWN;
+ private String typeGUID = null;
+ private String typeName = null;
+
+
+ /**
+ * Default constructor initializes the instance property value to nulls.
+ *
+ * @param instancePropertyCategory - InstancePropertyCategory Enum
+ */
+ public InstancePropertyValue(InstancePropertyCategory instancePropertyCategory)
+ {
+ super();
+ this.instancePropertyCategory = instancePropertyCategory;
+ }
+
+
+ /**
+ * Copy/clone constructor - initializes the instance property value from the supplied template.
+ *
+ * @param template InstancePropertyValue
+ */
+ public InstancePropertyValue(InstancePropertyValue template)
+ {
+ super(template);
+
+ if (template != null)
+ {
+ this.instancePropertyCategory = template.getInstancePropertyCategory();
+ this.typeGUID = template.getTypeGUID();
+ this.typeName = template.getTypeName();
+ }
+ }
+
+
+ /**
+ * Return the category of this instance property's type.
+ *
+ * @return TypeDefCategory enum value
+ */
+ public InstancePropertyCategory getInstancePropertyCategory() { return instancePropertyCategory; }
+
+
+ /**
+ * Return the unique GUID for the type.
+ *
+ * @return String unique identifier
+ */
+ public String getTypeGUID() { return typeGUID; }
+
+
+ /**
+ * Set up the unique GUID of the type.
+ *
+ * @param typeGUID - String unique identifier
+ */
+ public void setTypeGUID(String typeGUID) { this.typeGUID = typeGUID; }
+
+
+ /**
+ * Return the name of the type.
+ *
+ * @return String type name
+ */
+ public String getTypeName() { return typeName; }
+
+
+ /**
+ * Set up the name of the type.
+ *
+ * @param typeName - String type name
+ */
+ public void setTypeName(String typeName) { this.typeName = typeName; }
+
+
+ /**
+ * Standard toString method.
+ *
+ * @return JSON style description of variables.
+ */
+ @Override
+ public String toString()
+ {
+ return "InstancePropertyValue{" +
+ "instancePropertyCategory=" + instancePropertyCategory +
+ ", typeGUID='" + typeGUID + '\'' +
+ ", typeName='" + typeName + '\'' +
+ '}';
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/InstanceProvenanceType.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/InstanceProvenanceType.java b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/InstanceProvenanceType.java
new file mode 100644
index 0000000..1715cbf
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/InstanceProvenanceType.java
@@ -0,0 +1,109 @@
+/*
+ * 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.metadatacollection.properties.instances;
+
+import java.io.Serializable;
+
+/**
+ * InstanceProvenanceType defines where the metadata comes from and, hence if it can be updated.
+ * <ul>
+ * <li>
+ * UNKNOWN - uninitialized provenance value.
+ * </li>
+ * <li>
+ * LOCAL_COHORT - the element is being maintained within the local cohort.
+ * The metadata collection id is for one of the repositories in the cohort.
+ * This metadata collection id identifies the home repository for this element.
+ * </li>
+ * <li>
+ * EXPORT_ARCHIVE - the element was created from an export archive.
+ * The metadata collection id for the element is the metadata collection id of the originating server.
+ * If the originating server later joins the cohort with the same metadata collection Id then these
+ * elements will be refreshed from the originating server’s current repository.
+ * </li>
+ * <li>
+ * CONTENT_PACK - the element comes from an open metadata content pack.
+ * The metadata collection id of the elements is set to the GUID of the pack.
+ * </li>
+ * <li>
+ * DEREGISTERED_REPOSITORY - the element comes from a metadata repository that used to be a part
+ * of the repository cohort but has been deregistered. The metadata collection id remains the same.
+ * If the repository rejoins the cohort then these elements can be refreshed from the rejoining repository.
+ * </li>
+ * </ul>
+ */
+public enum InstanceProvenanceType implements Serializable
+{
+ UNKNOWN (0, "<Unknown>", "Unknown provenance"),
+ LOCAL_COHORT (1, "Local Cohort", "The instance is managed by one of the members of a cohort " +
+ "that the local server belongs to"),
+ EXPORT_ARCHIVE (2, "Export Archive", "The instance comes from an open metadata archive that was " +
+ "created from a metadata export from an open " +
+ "metadata repository"),
+ CONTENT_PACK (3, "Content Pack", "The instance comes from an open metadata archive that was " +
+ "created as a content pack"),
+ DEREGISTERED_REPOSITORY (4, "Deregistered Repository", "The instance is a cached copy of a metadata instance " +
+ "that is owned by a repository that is no longer " +
+ "connected to one of the cohorts that the " +
+ "local server belongs to; it may be out-of-date");
+
+ private static final long serialVersionUID = 1L;
+
+ private int ordinal;
+ private String name;
+ private String description;
+
+
+ /**
+ * Default constructor for the instance provenance type.
+ *
+ * @param ordinal - numerical representation of the instance provenance type
+ * @param name - default string name of the instance provenance type
+ * @param description - default string description of the instance provenance type
+ */
+ InstanceProvenanceType(int ordinal, String name, String description)
+ {
+ this.ordinal = ordinal;
+ this.name = name;
+ this.description = description;
+ }
+
+
+ /**
+ * Return the numeric representation of the instance provenance type.
+ *
+ * @return int ordinal
+ */
+ public int getOrdinal() { return ordinal; }
+
+
+ /**
+ * Return the default name of the instance provenance type.
+ *
+ * @return String name
+ */
+ public String getName() { return name; }
+
+
+ /**
+ * Return the default description of the instance provenance type.
+ *
+ * @return String description
+ */
+ public String getDescription() { return description; }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/InstanceStatus.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/InstanceStatus.java b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/InstanceStatus.java
new file mode 100644
index 0000000..645bd4c
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/InstanceStatus.java
@@ -0,0 +1,91 @@
+/*
+ * 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.metadatacollection.properties.instances;
+
+import java.io.Serializable;
+
+/**
+ * The InstanceStatus defines the status of a relationship or an entity in the metadata collection. It effectively
+ * defines its visibility to different types of queries. Most queries by default will only return instances in the
+ * active status.
+ * <ul>
+ * <li>UNKNOWN - the instance has not been initialized.</li>
+ * <li>PROPOSED - the instance has not yet been stored in the metadata collection.</li>
+ * <li>DRAFT - the instance is stored but not fully filled out so should not be used for normal queries.</li>
+ * <li>PREPARED - the instance is stored and complete - it is ready to be moved to active status.</li>
+ * <li>ACTIVE - the instance is in active use.</li>
+ * <li>DELETED - the instance has been deleted and is waiting to be purged. It is kept in the metadata collection
+ * to support a restore request. It is not returned on normal queries.</li>
+ * </ul>
+ */
+public enum InstanceStatus implements Serializable
+{
+ UNKNOWN (0, "<Unknown>", "Unknown instance status."),
+ PROPOSED(1, "Proposed", "Proposed instance to store in the metadata collection."),
+ DRAFT (2, "Draft", "Potentially incomplete draft of instance still being developed."),
+ PREPARED(3, "Prepared", "Complete draft of instance waiting for approval."),
+ ACTIVE (10, "Active", "Active instance in use."),
+ DELETED(99, "Deleted", "Instance that has been deleted and is no longer in use.");
+
+ private static final long serialVersionUID = 1L;
+
+ private int ordinal;
+ private String statusName;
+ private String statusDescription;
+
+
+ /**
+ * Default constructor sets up the specific values for an enum instance.
+ *
+ * @param ordinal - int enum value ordinal
+ * @param statusName - String name
+ * @param statusDescription - String description
+ */
+ InstanceStatus(int ordinal,
+ String statusName,
+ String statusDescription)
+ {
+ this.ordinal = ordinal;
+ this.statusName = statusName;
+ this.statusDescription = statusDescription;
+ }
+
+
+ /**
+ * Return the numerical value for the enum.
+ *
+ * @return int enum value ordinal
+ */
+ public int getOrdinal() { return ordinal; }
+
+
+ /**
+ * Return the descriptive name for the enum.
+ *
+ * @return String name
+ */
+ public String getStatusName() { return statusName; }
+
+
+ /**
+ * Return the description for the enum.
+ *
+ * @return String description
+ */
+ public String getStatusDescription() { return statusDescription; }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/InstanceType.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/InstanceType.java b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/InstanceType.java
new file mode 100644
index 0000000..edd786a
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/InstanceType.java
@@ -0,0 +1,311 @@
+/*
+ * 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.metadatacollection.properties.instances;
+
+import org.apache.atlas.omrs.metadatacollection.properties.typedefs.TypeDefCategory;
+import org.apache.atlas.omrs.metadatacollection.properties.typedefs.TypeDefLink;
+
+import java.util.ArrayList;
+
+/**
+ * InstanceType contains information from the instance's TypeDef that are useful for processing the instance.
+ */
+public class InstanceType extends InstanceElementHeader
+{
+ private TypeDefCategory typeDefCategory = TypeDefCategory.UNKNOWN_DEF;
+ private String typeDefGUID = null;
+ private String typeDefName = null;
+ private long typeDefVersion = 0L;
+ private String typeDefDescription = null;
+ private String typeDefDescriptionGUID = null;
+ private ArrayList<TypeDefLink> typeDefSuperTypes = null;
+ private ArrayList<InstanceStatus> validStatusList = null;
+ private ArrayList<String> validInstanceProperties = null;
+
+ /**
+ * Default constructor relies on initialization of variables in the declaration.
+ */
+ public InstanceType()
+ {
+ }
+
+
+ /**
+ * Typical constructor that set all of the properties at once.
+ *
+ * @param typeDefCategory - the category of the type
+ * @param typeDefGUID - unique identifier of the type
+ * @param typeDefName - unique name of the type
+ * @param typeDefVersion - version number of the type
+ * @param typeDefDescription - short description of the type
+ * @param typeDefDescriptionGUID - unique identifier of the glossary term describing this type.
+ * @param typeDefSuperTypes - full list of super types for this type
+ * @param validStatusList - list of statuses that this instance can have
+ * @param validInstanceProperties - full list of valid property names that can be put in the instance (including
+ * properties from the super types)
+ */
+ public InstanceType(TypeDefCategory typeDefCategory,
+ String typeDefGUID,
+ String typeDefName,
+ long typeDefVersion,
+ String typeDefDescription,
+ String typeDefDescriptionGUID,
+ ArrayList<TypeDefLink> typeDefSuperTypes,
+ ArrayList<InstanceStatus> validStatusList,
+ ArrayList<String> validInstanceProperties)
+ {
+ this.typeDefCategory = typeDefCategory;
+ this.typeDefGUID = typeDefGUID;
+ this.typeDefName = typeDefName;
+ this.typeDefVersion = typeDefVersion;
+ this.typeDefDescription = typeDefDescription;
+ this.typeDefDescriptionGUID = typeDefDescriptionGUID;
+ this.typeDefSuperTypes = typeDefSuperTypes;
+ this.validStatusList = validStatusList;
+ this.validInstanceProperties = validInstanceProperties;
+ }
+
+
+ /**
+ * Copy/clone constructor
+ *
+ * @param template - instance type to copy
+ */
+ public InstanceType(InstanceType template)
+ {
+ if (template != null)
+ {
+ typeDefCategory = template.getTypeDefCategory();
+ typeDefGUID = template.getTypeDefGUID();
+ typeDefName = template.getTypeDefName();
+ typeDefVersion = template.getTypeDefVersion();
+ typeDefDescription = template.getTypeDefDescription();
+ typeDefDescriptionGUID = template.getTypeDefDescriptionGUID();
+ typeDefSuperTypes = template.getTypeDefSuperTypes();
+ validStatusList = template.getValidStatusList();
+ validInstanceProperties = template.getValidInstanceProperties();
+ }
+ }
+
+
+ /**
+ * Return the category of this instance. This defines the category of the TypeDef that determines its properties.
+ *
+ * @return TypeDefCategory enum
+ */
+ public TypeDefCategory getTypeDefCategory() { return typeDefCategory; }
+
+
+ /**
+ * Set up the category of this instance. This defines the category of the TypeDef that determines its properties.
+ *
+ * @param typeDefCategory enum
+ */
+ public void setTypeDefCategory(TypeDefCategory typeDefCategory)
+ {
+ this.typeDefCategory = typeDefCategory;
+ }
+
+ /**
+ * Return the unique identifier for the type of this instance.
+ *
+ * @return String unique identifier
+ */
+ public String getTypeDefGUID() { return typeDefGUID; }
+
+
+ /**
+ * Set up the unique identifier for the type of this instance.
+ *
+ * @param typeDefGUID - String unique identifier
+ */
+ public void setTypeDefGUID(String typeDefGUID) { this.typeDefGUID = typeDefGUID; }
+
+
+ /**
+ * Return the name of this instance's type.
+ *
+ * @return String type name
+ */
+ public String getTypeDefName() { return typeDefName; }
+
+
+ /**
+ * Set up the name of this instance's type.
+ *
+ * @param typeDefName - String type name
+ */
+ public void setTypeDefName(String typeDefName) { this.typeDefName = typeDefName; }
+
+
+ /**
+ * Return the version number of this instance's TypeDef.
+ *
+ * @return long version number
+ */
+ public long getTypeDefVersion()
+ {
+ return typeDefVersion;
+ }
+
+
+ /**
+ * Set up the versionName for the TypeDef.
+ *
+ * @param typeDefVersion - long version number
+ */
+ public void setTypeDefVersion(long typeDefVersion)
+ {
+ this.typeDefVersion = typeDefVersion;
+ }
+
+
+ /**
+ * Return the full list of defined super-types for this TypeDef working up the type hierarchy.
+ *
+ * @return list of types
+ */
+ public ArrayList<TypeDefLink> getTypeDefSuperTypes()
+ {
+ return typeDefSuperTypes;
+ }
+
+
+ /**
+ * Set up the full list of defined super-types for this TypeDef working up the type hierarchy.
+ *
+ * @param typeDefSuperTypes - list of type names
+ */
+ public void setTypeDefSuperTypes(ArrayList<TypeDefLink> typeDefSuperTypes)
+ {
+ this.typeDefSuperTypes = typeDefSuperTypes;
+ }
+
+ /**
+ * Return the description for the TypeDef.
+ *
+ * @return - String description
+ */
+ public String getTypeDefDescription()
+ {
+ return typeDefDescription;
+ }
+
+
+ /**
+ * Set up the description for the TypeDef.
+ *
+ * @param typeDefDescription - String description
+ */
+ public void setTypeDefDescription(String typeDefDescription)
+ {
+ this.typeDefDescription = typeDefDescription;
+ }
+
+
+ /**
+ * Return the unique identifier of the glossary term that describes this TypeDef (null if no term defined).
+ *
+ * @return String unique identifier
+ */
+ public String getTypeDefDescriptionGUID()
+ {
+ return typeDefDescriptionGUID;
+ }
+
+
+ /**
+ * Set up the unique identifier of the glossary term that describes this TypeDef (null if no term defined).
+ *
+ * @param typeDefDescriptionGUID - String unique identifier
+ */
+ public void setTypeDefDescriptionGUID(String typeDefDescriptionGUID)
+ {
+ this.typeDefDescriptionGUID = typeDefDescriptionGUID;
+ }
+
+
+ /**
+ * Return the list of valid instance statuses supported by this instance.
+ *
+ * @return InstanceStatus array of supported status.
+ */
+ public ArrayList<InstanceStatus> getValidStatusList()
+ {
+ if ( validStatusList == null)
+ {
+ return validStatusList;
+ }
+ else
+ {
+ return new ArrayList<>(validStatusList);
+ }
+ }
+
+
+ /**
+ * Set up the list of valid instance statuses supported by this instance.
+ *
+ * @param validStatusList - InstanceStatus Array
+ */
+ public void setValidStatusList(ArrayList<InstanceStatus> validStatusList) { this.validStatusList = validStatusList; }
+
+
+ /**
+ * Return the list of valid property names that can be stored in this instance.
+ *
+ * @return array of property names.
+ */
+ public ArrayList<String> getValidInstanceProperties()
+ {
+ return validInstanceProperties;
+ }
+
+
+ /**
+ * Set up the set of valid property names that can be stored in this instance.
+ *
+ * @param validInstanceProperties - array of property names.
+ */
+ public void setValidInstanceProperties(ArrayList<String> validInstanceProperties)
+ {
+ this.validInstanceProperties = validInstanceProperties;
+ }
+
+
+ /**
+ * Standard toString method.
+ *
+ * @return JSON style description of variables.
+ */
+ @Override
+ public String toString()
+ {
+ return "InstanceType{" +
+ "typeDefCategory=" + typeDefCategory +
+ ", typeDefGUID='" + typeDefGUID + '\'' +
+ ", typeDefName='" + typeDefName + '\'' +
+ ", typeDefVersion=" + typeDefVersion +
+ ", typeDefDescription='" + typeDefDescription + '\'' +
+ ", typeDefDescriptionGUID='" + typeDefDescriptionGUID + '\'' +
+ ", typeDefSuperTypes=" + typeDefSuperTypes +
+ ", validStatusList=" + validStatusList +
+ ", validInstanceProperties=" + validInstanceProperties +
+ '}';
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/MapPropertyValue.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/MapPropertyValue.java b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/MapPropertyValue.java
new file mode 100644
index 0000000..4bebb02
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/MapPropertyValue.java
@@ -0,0 +1,133 @@
+/*
+ * 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.metadatacollection.properties.instances;
+
+
+/**
+ * MapPropertyValue stores the values of a map within an entity, struct or relationship properties.
+ * The elements of the map are stored in an InstanceProperties map.
+ */
+public class MapPropertyValue extends InstancePropertyValue
+{
+ private InstanceProperties mapValues = null;
+
+
+ /**
+ * Default constructor sets the map to empty.
+ */
+ public MapPropertyValue()
+ {
+ super(InstancePropertyCategory.MAP);
+ }
+
+
+ /**
+ * Copy/clone constructor set up the map using the supplied template.
+ *
+ * @param template - ArrayPropertyValue
+ */
+ public MapPropertyValue(MapPropertyValue template)
+ {
+ super(template);
+
+ if (template !=null)
+ {
+ mapValues = template.getMapValues();
+ }
+ }
+
+
+ /**
+ * Return the number of elements in the map.
+ *
+ * @return int - map size
+ */
+ public int getMapElementCount()
+ {
+ if (mapValues == null)
+ {
+ return 0;
+ }
+ else
+ {
+ return mapValues.getPropertyCount();
+ }
+ }
+
+
+ /**
+ * Return a copy of the map elements.
+ *
+ * @return InstanceProperties containing the map elements
+ */
+ public InstanceProperties getMapValues()
+ {
+ if (mapValues == null)
+ {
+ return mapValues;
+ }
+ else
+ {
+ return new InstanceProperties(mapValues);
+ }
+ }
+
+
+ /**
+ * Add or update an element in the map.
+ * If a null is supplied for the property name, an OMRS runtime exception is thrown.
+ * If a null is supplied for the property value, the property is removed.
+ *
+ * @param propertyName - String name
+ * @param propertyValue - InstancePropertyValue - value to store
+ */
+ public void setMapValue(String propertyName, InstancePropertyValue propertyValue)
+ {
+ if (mapValues == null)
+ {
+ mapValues = new InstanceProperties();
+ }
+ mapValues.setProperty(propertyName, propertyValue);
+ }
+
+
+ /**
+ * Set up the map elements in one call.
+ *
+ * @param mapValues - InstanceProperties containing the array elements
+ */
+ public void setMapValues(InstanceProperties mapValues) { this.mapValues = mapValues; }
+
+
+ /**
+ * Standard toString method.
+ *
+ * @return JSON style description of variables.
+ */
+ @Override
+ public String toString()
+ {
+ return "MapPropertyValue{" +
+ "mapValues=" + mapValues +
+ ", mapElementCount=" + getMapElementCount() +
+ ", instancePropertyCategory=" + getInstancePropertyCategory() +
+ ", typeGUID='" + getTypeGUID() + '\'' +
+ ", typeName='" + getTypeName() + '\'' +
+ '}';
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/PrimitivePropertyValue.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/PrimitivePropertyValue.java b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/PrimitivePropertyValue.java
new file mode 100644
index 0000000..fb40758
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/PrimitivePropertyValue.java
@@ -0,0 +1,172 @@
+/*
+ * 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.metadatacollection.properties.instances;
+
+import org.apache.atlas.omrs.ffdc.OMRSErrorCode;
+import org.apache.atlas.omrs.ffdc.exception.OMRSRuntimeException;
+import org.apache.atlas.omrs.metadatacollection.properties.typedefs.PrimitiveDefCategory;
+
+
+/**
+ * PrimitivePropertyValue stores a single primitive property. This is stored in the specific Java class
+ * for the property value's type although it is stored as an object.
+ */
+public class PrimitivePropertyValue extends InstancePropertyValue
+{
+ private PrimitiveDefCategory primitiveDefCategory = PrimitiveDefCategory.OM_PRIMITIVE_TYPE_UNKNOWN;
+ private Object primitiveValue = null;
+
+
+ /**
+ * Default constructor sets the primitive property value to null.
+ */
+ public PrimitivePropertyValue()
+ {
+ super(InstancePropertyCategory.PRIMITIVE);
+ }
+
+
+ /**
+ * Copy/clone constructor - copies the values from the supplied template.
+ *
+ * @param template - PrimitivePropertyValue
+ */
+ public PrimitivePropertyValue(PrimitivePropertyValue template)
+ {
+ super(template);
+
+ if (template != null)
+ {
+ this.primitiveDefCategory = template.getPrimitiveDefCategory();
+ this.primitiveValue = template.getPrimitiveValue();
+ }
+ }
+
+
+ /**
+ * Return the the category of the primitive's type. This sets the name and Java Class used for
+ * the primitive value.
+ *
+ * @return PrimitiveDefCategory
+ */
+ public PrimitiveDefCategory getPrimitiveDefCategory() { return primitiveDefCategory; }
+
+
+ /**
+ * Set up the category of the primitive typ. This sets the name and Java Class used for
+ * the primitive value.
+ *
+ * @param primitiveDefCategory - PrimitiveDefCategory enum
+ */
+ public void setPrimitiveDefCategory(PrimitiveDefCategory primitiveDefCategory)
+ {
+ this.primitiveDefCategory = primitiveDefCategory;
+ }
+
+
+ /**
+ * Return the primitive value. It is already set up to be the appropriate type for the primitive
+ * as defined in the PrimitiveDefCategory.
+ *
+ * @return Object containing the primitive value.
+ */
+ public Object getPrimitiveValue() { return primitiveValue; }
+
+
+ /**
+ * Set up the primitive value. Although it is passed in as a java.lang.Object, it should be the correct
+ * type as defined by the PrimitiveDefCategory. This is validated in this method so it is important to call
+ * setPrimitiveDefCategory() before setPrimitiveValue().
+ *
+ * @param primitiveValue - object contain the primitive value
+ */
+ public void setPrimitiveValue(Object primitiveValue)
+ {
+ try
+ {
+ Class testJavaClass = Class.forName(primitiveDefCategory.getJavaClassName());
+
+ if (!testJavaClass.isInstance(primitiveValue))
+ {
+ /*
+ * The primitive value supplied is the wrong type. Throw an exception.
+ */
+ }
+ }
+ catch (ClassNotFoundException unknownPrimitiveClass)
+ {
+ /*
+ * The java class defined in the primitiveDefCategory is not known. This is an internal error
+ * that needs a code fix in PrimitiveDefCategory.
+ */
+ OMRSErrorCode errorCode = OMRSErrorCode.INVALID_PRIMITIVE_CLASS_NAME;
+ String errorMessage = errorCode.getErrorMessageId()
+ + errorCode.getFormattedErrorMessage(primitiveDefCategory.getJavaClassName(),
+ primitiveDefCategory.getName());
+
+ throw new OMRSRuntimeException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ "setPrimitiveValue",
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction(),
+ unknownPrimitiveClass);
+ }
+ catch (Error invalidPrimitiveValue)
+ {
+ /*
+ * Some unexpected exception occurred when manipulating the Java Classes. Probably a coding error.
+ */
+ OMRSErrorCode errorCode = OMRSErrorCode.INVALID_PRIMITIVE_VALUE;
+ String errorMessage = errorCode.getErrorMessageId()
+ + errorCode.getFormattedErrorMessage(primitiveDefCategory.getJavaClassName(),
+ primitiveDefCategory.getName());
+
+ throw new OMRSRuntimeException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ "setPrimitiveValue",
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction(),
+ invalidPrimitiveValue);
+ }
+
+ /*
+ * The primitive value is of the correct type so save it.
+ */
+ this.primitiveValue = primitiveValue;
+ }
+
+
+ /**
+ * Standard toString method.
+ *
+ * @return JSON style description of variables.
+ */
+ @Override
+ public String toString()
+ {
+ return "PrimitivePropertyValue{" +
+ "primitiveDefCategory=" + primitiveDefCategory +
+ ", primitiveValue=" + primitiveValue +
+ ", instancePropertyCategory=" + getInstancePropertyCategory() +
+ ", typeGUID='" + getTypeGUID() + '\'' +
+ ", typeName='" + getTypeName() + '\'' +
+ '}';
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/Relationship.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/Relationship.java b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/Relationship.java
new file mode 100644
index 0000000..cd56bbd
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/Relationship.java
@@ -0,0 +1,320 @@
+/*
+ * 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.metadatacollection.properties.instances;
+
+
+/**
+ * Relationship is a POJO that manages the properties of an open metadata relationship. This includes information
+ * about the relationship type, the two entities it connects and the properties it holds.
+ */
+public class Relationship extends InstanceHeader
+{
+ private InstanceProperties relationshipProperties = null;
+
+ private String entityOnePropertyName = null;
+ private EntityProxy entityOneProxy = null;
+
+ private String entityTwoPropertyName = null;
+ private EntityProxy entityTwoProxy = null;
+
+
+ /**
+ * Default constructor - empty relationship linked to nothing.
+ */
+ public Relationship()
+ {
+ super();
+
+ /*
+ * Nothing else to do - already initialized to null.
+ */
+
+ }
+
+
+ /**
+ * Copy/clone constructor - builds a relationship from the supplied template.
+ *
+ * @param templateElement - template relationship to copy
+ */
+ public Relationship(Relationship templateElement)
+ {
+ super(templateElement);
+
+ if (templateElement != null)
+ {
+ relationshipProperties = templateElement.getProperties();
+ entityOnePropertyName = templateElement.getEntityOnePropertyName();
+ entityOneProxy = templateElement.getEntityOneProxy();
+ entityTwoPropertyName = templateElement.getEntityTwoPropertyName();
+ entityTwoProxy = templateElement.getEntityTwoProxy();
+ }
+ }
+
+
+ /**
+ * Test to determine if the supplied entity is linked by this relationship.
+ *
+ * @param entityGUID - unique identifier for the entity to test.
+ * @return boolean indicate whether the supplied entity is linked by this relationship
+ */
+ public boolean relatedToEntity(String entityGUID)
+ {
+ if (entityGUID == null)
+ {
+ return false;
+ }
+
+ if (entityOneProxy != null)
+ {
+ if (entityOneProxy.getGUID().equals(entityGUID))
+ {
+ return true;
+ }
+ }
+
+ if (entityTwoProxy != null)
+ {
+ if (entityTwoProxy.getGUID().equals(entityGUID))
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+
+ /**
+ * Return the GUID at the other end of the relationship to the supplied entity.
+ *
+ * @param entityGUID - unique identifier for the entity to test.
+ * @return String guid for the entity at the other end of the relationship. Null if no matching entity found.
+ */
+ public String getLinkedEntity(String entityGUID)
+ {
+ if ((entityGUID == null) || (entityOneProxy == null) || (entityTwoProxy == null))
+ {
+ return null;
+ }
+
+ String entityOneGUID = entityOneProxy.getGUID();
+ String entityTwoGUID = entityTwoProxy.getGUID();
+
+ if ((entityOneGUID == null) || entityTwoGUID == null)
+ {
+ return null;
+ }
+
+ if (entityOneGUID.equals(entityGUID))
+ {
+ return entityTwoGUID;
+ }
+
+ if (entityTwoGUID.equals(entityGUID))
+ {
+ return entityOneGUID;
+ }
+
+ return null;
+ }
+
+
+ /**
+ * Return an array of the unique identifiers for the entities at either end of the relationship.
+ *
+ * @return String array
+ */
+ public String [] getLinkedEntities()
+ {
+ String[] linkedEntityGUIDs = new String[2];
+
+ if (entityOneProxy == null)
+ {
+ linkedEntityGUIDs[0] = null;
+ }
+ else
+ {
+ linkedEntityGUIDs[0] = entityOneProxy.getGUID();
+ }
+
+ if (entityTwoProxy == null)
+ {
+ linkedEntityGUIDs[1] = null;
+ }
+ else
+ {
+ linkedEntityGUIDs[1] = entityTwoProxy.getGUID();
+ }
+
+ return linkedEntityGUIDs;
+ }
+
+
+ /**
+ * Return a copy of all of the properties for this relationship. Null means no properties exist.
+ *
+ * @return InstanceProperties
+ */
+ public InstanceProperties getProperties()
+ {
+ if (relationshipProperties == null)
+ {
+ return relationshipProperties;
+ }
+ else
+ {
+ return new InstanceProperties(relationshipProperties);
+ }
+ }
+
+
+ /**
+ * Set up the properties for this relationship.
+ *
+ * @param newProperties - InstanceProperties object
+ */
+ public void setProperties(InstanceProperties newProperties)
+ {
+ relationshipProperties = newProperties;
+ }
+
+
+ /**
+ * Return the name of the property for the relationship from the perspective of the entity at the first end of the
+ * relationship.
+ *
+ * @return entityOnePropertyName - String property name
+ */
+ public String getEntityOnePropertyName() {
+ return entityOnePropertyName;
+ }
+
+
+ /**
+ * Set up the property name for the relationship from the perspective of the entity at the first end of the
+ * relationship.
+ *
+ * @param entityOnePropertyName - String property name
+ */
+ public void setEntityOnePropertyName(String entityOnePropertyName)
+ {
+ this.entityOnePropertyName = entityOnePropertyName;
+ }
+
+
+ /**
+ * Return details of the entity at the first end of the relationship.
+ *
+ * @return entityOneProxy - EntityProxy object for the first end of the relationship.
+ */
+ public EntityProxy getEntityOneProxy()
+ {
+ if (entityOneProxy == null)
+ {
+ return entityOneProxy;
+ }
+ else
+ {
+ return new EntityProxy(entityOneProxy);
+ }
+ }
+
+
+ /**
+ * Set up details of the entity at the first end of the relationship.
+ *
+ * @param entityOneProxy - EntityProxy object for the first end of the relationship.
+ */
+ public void setEntityOneProxy(EntityProxy entityOneProxy) { this.entityOneProxy = entityOneProxy; }
+
+
+ /**
+ * Return the property name for the relationship from the perspective of the entity at the second end of the
+ * relationship.
+ *
+ * @return String property name
+ */
+ public String getEntityTwoPropertyName() { return entityTwoPropertyName; }
+
+
+ /**
+ * Set up the property name for the relationship from the perspective of the entity at the second end of the
+ * relationship.
+ *
+ * @param entityTwoPropertyName - String property name
+ */
+ public void setEntityTwoPropertyName(String entityTwoPropertyName) { this.entityTwoPropertyName = entityTwoPropertyName; }
+
+
+ /**
+ * Return details of the entity at second end of the relationship.
+ *
+ * @return EntityProxy object for the second end of the relationship
+ */
+ public EntityProxy getEntityTwoProxy()
+ {
+ if (entityTwoProxy == null)
+ {
+ return entityTwoProxy;
+ }
+ else
+ {
+ return new EntityProxy(entityTwoProxy);
+ }
+ }
+
+
+ /**
+ * Set up the identity of the proxy at the other end of the relationship.
+ *
+ * @param entityTwoProxy - EntityProxy
+ */
+ public void setEntityTwoProxy(EntityProxy entityTwoProxy) { this.entityTwoProxy = entityTwoProxy; }
+
+
+ /**
+ * Standard toString method.
+ *
+ * @return JSON style description of variables.
+ */
+ @Override
+ public String toString()
+ {
+ return "Relationship{" +
+ "relationshipProperties=" + relationshipProperties +
+ ", entityOneLabel='" + entityOnePropertyName + '\'' +
+ ", entityOneProxy=" + entityOneProxy +
+ ", entityTwoLabel='" + entityTwoPropertyName + '\'' +
+ ", entityTwoProxy=" + entityTwoProxy +
+ ", properties=" + getProperties() +
+ ", type=" + getType() +
+ ", instanceProvenanceType=" + getInstanceProvenanceType() +
+ ", metadataCollectionId='" + getMetadataCollectionId() + '\'' +
+ ", instanceURL='" + getInstanceURL() + '\'' +
+ ", GUID='" + getGUID() + '\'' +
+ ", status=" + getStatus() +
+ ", createdBy='" + getCreatedBy() + '\'' +
+ ", updatedBy='" + getUpdatedBy() + '\'' +
+ ", createTime=" + getCreateTime() +
+ ", updateTime=" + getUpdateTime() +
+ ", versionName=" + getVersion() +
+ ", statusOnDelete=" + getStatusOnDelete() +
+ '}';
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/StructPropertyValue.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/StructPropertyValue.java b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/StructPropertyValue.java
new file mode 100644
index 0000000..cd8bff9
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/StructPropertyValue.java
@@ -0,0 +1,95 @@
+/*
+ * 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.metadatacollection.properties.instances;
+
+
+/**
+ * StructPropertyValue supports the value part of property that is defined as a complex structure.
+ * It manages a list of properties that cover the fields in the structure.
+ */
+public class StructPropertyValue extends InstancePropertyValue
+{
+ private InstanceProperties attributes = null;
+
+
+ /**
+ * Default constructor set StructProperyValue to null.
+ */
+ public StructPropertyValue()
+ {
+ super(InstancePropertyCategory.STRUCT);
+ }
+
+
+ /**
+ * Copy/clone constructor sets up the values based on the template.
+ *
+ * @param template - StructPropertyValue to copy.
+ */
+ public StructPropertyValue(StructPropertyValue template)
+ {
+ super(template);
+
+ if (template != null)
+ {
+ attributes = template.getAttributes();
+ }
+ }
+
+
+ /**
+ * Return the attributes that make up the fields of the struct.
+ *
+ * @return attributes - InstanceProperties iterator
+ */
+ public InstanceProperties getAttributes()
+ {
+ if (attributes == null)
+ {
+ return attributes;
+ }
+ else
+ {
+ return new InstanceProperties(attributes);
+ }
+ }
+
+ /**
+ * Set up the attributes that make up the fields of the struct.
+ *
+ * @param attributes - InstanceProperties iterator
+ */
+ public void setAttributes(InstanceProperties attributes) { this.attributes = attributes; }
+
+
+ /**
+ * Standard toString method.
+ *
+ * @return JSON style description of variables.
+ */
+ @Override
+ public String toString()
+ {
+ return "StructPropertyValue{" +
+ "attributes=" + attributes +
+ ", instancePropertyCategory=" + getInstancePropertyCategory() +
+ ", typeGUID='" + getTypeGUID() + '\'' +
+ ", typeName='" + getTypeName() + '\'' +
+ '}';
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/AttributeCardinality.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/AttributeCardinality.java b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/AttributeCardinality.java
new file mode 100644
index 0000000..9ca7b80
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/AttributeCardinality.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.metadatacollection.properties.typedefs;
+
+import java.io.Serializable;
+
+/**
+ * AttributeCardinality is used on a association from one TypeDef to another. It defines how many instances the "linked to" TypeDef
+ * are permitted to be connected to the "linked from" TypeDef:
+ * <ul>
+ * <li>
+ * UNKNOWN - uninitialized cardinality
+ * </li>
+ * <li>
+ * AT_MOST_ONE - means there can be zero or one instances connected to an instance of this TypeDef. This
+ * relationship is often written as 0..1.</li>
+ * <li>
+ * ONE_ONLY - means there must be one instance, no more and no less.
+ * </li>
+ * <li>
+ * AT_LEAST_ONE_ORDERED - means there must be one or more instances connected to an instance of this TypeDef.
+ * This relationship is often written as 1..*. The linked instances are maintained
+ * in an ordered list/array.
+ * </li>
+ * <li>
+ * AT_LEAST_ONE_UNORDERED - means there must be one or more instances connected to an instance of this TypeDef.
+ * This relationship is often written as 1..*. The linked instances are maintained
+ * in an unordered set.
+ * </li>
+ * <li>
+ * ANY_NUMBER_ORDERED - means there can be none, one or many instances connected an instance of this TypeDef.
+ * This relationship is often written as 0..*. The linked instances are maintained
+ * in an ordered list/array.
+ * </li>
+ * <li>
+ * ANY_NUMBER_UNORDERED - means there can be none, one or many instances connected an instance of this TypeDef.
+ * This relationship is often written as 0..*. The linked instances are maintained
+ * in an unordered set.
+ * </li>
+ * </ul>
+ */
+public enum AttributeCardinality implements Serializable
+{
+ UNKNOWN (0, "<Unknown>", "Unknown or uninitialized cardinality"),
+ AT_MOST_ONE (1, "At Most One", "0..1 - Zero or one instances. 0..1."),
+ ONE_ONLY (2, "One Only", "1 - One instance, no more and no less"),
+ AT_LEAST_ONE_ORDERED (3, "At Least One (Ordered)", "1..* - One or more instances (stored in specific order)"),
+ AT_LEAST_ONE_UNORDERED (4, "At Least One (Unordered)", "1..* - One or more instances (stored in any order)"),
+ ANY_NUMBER_ORDERED (5, "Any Number (Ordered)", "0..* - Any number of instances (stored in a specific order)"),
+ ANY_NUMBER_UNORDERED (6, "Any Number (Unordered)", "0..* - Any number of instances (stored in any order)");
+
+ private static final long serialVersionUID = 1L;
+
+ private int ordinal;
+ private String name;
+ private String description;
+
+
+ /**
+ * Constructor to set up a single instances of the enum.
+ *
+ * @param ordinal - numerical representation of the cardinality
+ * @param name - default string name of the cardinality
+ * @param description - default string description of the cardinality
+ */
+ AttributeCardinality(int ordinal, String name, String description)
+ {
+ this.ordinal = ordinal;
+ this.name = name;
+ this.description = description;
+ }
+
+
+ /**
+ * Return the numeric representation of the cardinality.
+ *
+ * @return int ordinal
+ */
+ public int getOrdinal() { return ordinal; }
+
+
+ /**
+ * Return the default name of the cardinality.
+ *
+ * @return String name
+ */
+ public String getName() { return name; }
+
+
+ /**
+ * Return the default description of the cardinality.
+ *
+ * @return String description
+ */
+ public String getDescription() { return description; }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/AttributeTypeDef.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/AttributeTypeDef.java b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/AttributeTypeDef.java
new file mode 100644
index 0000000..d68d233
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/AttributeTypeDef.java
@@ -0,0 +1,215 @@
+/*
+ * 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.metadatacollection.properties.typedefs;
+
+
+import java.util.Objects;
+
+/**
+ * The AttributeTypeDef class is used to identify the type of an attribute. These can be:
+ * <ul>
+ * <li>PrimitiveDef</li>
+ * <li>CollectionDef</li>
+ * <li>EnumDef</li>
+ * </ul>
+ */
+public abstract class AttributeTypeDef extends TypeDefElementHeader
+{
+ protected AttributeTypeDefCategory category = AttributeTypeDefCategory.UNKNOWN_DEF;
+ protected String guid = null;
+ protected String name = null;
+ protected String description = null;
+ protected String descriptionGUID = null;
+
+
+ /**
+ * Minimal constructor is passed the category of the attribute type
+ *
+ * @param category - category of this TypeDef
+ */
+ public AttributeTypeDef(AttributeTypeDefCategory category)
+ {
+ this.category = category;
+ }
+
+
+ /**
+ * Typical constructor is passed the values that describe the type.
+ *
+ * @param category - category of this TypeDef
+ * @param guid - unique id for the TypeDef
+ * @param name - unique name for the TypeDef
+ */
+ public AttributeTypeDef(AttributeTypeDefCategory category,
+ String guid,
+ String name)
+ {
+ super();
+
+ this.category = category;
+ this.guid = guid;
+ this.name = name;
+ }
+
+
+ /**
+ * Copy/clone constructor copies the values from the supplied template.
+ *
+ * @param template AttributeTypeDef
+ */
+ public AttributeTypeDef(AttributeTypeDef template)
+ {
+ super(template);
+
+ if (template != null)
+ {
+ this.category = template.getCategory();
+ this.guid = template.getGUID();
+ this.name = template.getName();
+ this.description = template.getDescription();
+ this.descriptionGUID = template.getDescriptionGUID();
+ }
+ }
+
+
+ /**
+ * Return the category of the TypeDef.
+ *
+ * @return AttributeTypeDefCategory enum
+ */
+ public AttributeTypeDefCategory getCategory() { return category; }
+
+
+ /**
+ * Set up the category of the TypeDef.
+ *
+ * @param category - AttributeTypeDefCategory enum
+ */
+ public void setCategory(AttributeTypeDefCategory category) { this.category = category; }
+
+
+ /**
+ * Return the unique identifier for this TypeDef.
+ *
+ * @return String guid
+ */
+ public String getGUID() { return guid; }
+
+
+ /**
+ * Set up the unique identifier for this TypeDef.
+ *
+ * @param guid - String guid
+ */
+ public void setGUID(String guid) { this.guid = guid; }
+
+
+ /**
+ * Return the type name for this TypeDef. In simple environments, the type name is unique but where metadata
+ * repositories from different vendors are in operation it is possible that 2 types may have a name clash. The
+ * GUID is the reliable unique identifier.
+ *
+ * @return String name
+ */
+ public String getName() { return name; }
+
+
+ /**
+ * Set up the type name for this TypeDef. In simple environments, the type name is unique but where metadata
+ * repositories from different vendors are in operation it is possible that 2 types may have a name clash. The
+ * GUID is the reliable unique identifier.
+ *
+ * @param name - String name
+ */
+ public void setName(String name) { this.name = name; }
+
+
+ public String getDescription()
+ {
+ return description;
+ }
+
+ public void setDescription(String description)
+ {
+ this.description = description;
+ }
+
+ public String getDescriptionGUID()
+ {
+ return descriptionGUID;
+ }
+
+ public void setDescriptionGUID(String descriptionGUID)
+ {
+ this.descriptionGUID = descriptionGUID;
+ }
+
+ /**
+ * Standard toString method.
+ *
+ * @return JSON style description of variables.
+ */
+ @Override
+ public String toString()
+ {
+ return "AttributeTypeDef{" +
+ "category=" + category +
+ ", guid='" + guid + '\'' +
+ ", name='" + name + '\'' +
+ ", description='" + description + '\'' +
+ ", descriptionGUID='" + descriptionGUID + '\'' +
+ '}';
+ }
+
+
+ /**
+ * Validated that the GUID, name and version number of a TypeDef are equal.
+ *
+ * @param object to test
+ * @return boolean flag to say object is the same TypeDefSummary
+ */
+ @Override
+ public boolean equals(Object object)
+ {
+ if (this == object)
+ {
+ return true;
+ }
+ if (object == null || getClass() != object.getClass())
+ {
+ return false;
+ }
+ AttributeTypeDef that = (AttributeTypeDef) object;
+ return category == that.category &&
+ Objects.equals(guid, that.guid) &&
+ Objects.equals(name, that.name);
+ }
+
+
+ /**
+ * Using the GUID as a hashcode - it should be unique if all connected metadata repositories are behaving properly.
+ *
+ * @return int hash code
+ */
+ @Override
+ public int hashCode()
+ {
+ return guid != null ? guid.hashCode() : 0;
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/AttributeTypeDefCategory.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/AttributeTypeDefCategory.java b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/AttributeTypeDefCategory.java
new file mode 100644
index 0000000..22ddf42
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/AttributeTypeDefCategory.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.metadatacollection.properties.typedefs;
+
+import java.io.Serializable;
+
+/**
+ * The AttributeTypeDefCategory defines the list of valid types of a attribute (property) for an open metadata instance.
+ */
+public enum AttributeTypeDefCategory implements Serializable
+{
+ UNKNOWN_DEF (0, "<Unknown>", "Uninitialized AttributeTypeDef object."),
+ PRIMITIVE (1, "Primitive", "A primitive type."),
+ COLLECTION (2, "Collection", "A collection object."),
+ ENUM_DEF (4, "EnumDef", "A pre-defined list of valid values.");
+
+ private static final long serialVersionUID = 1L;
+
+ private int typeCode;
+ private String typeName;
+ private String typeDescription;
+
+
+ /**
+ * Constructor to set up a single instances of the enum.
+ */
+ AttributeTypeDefCategory(int typeCode, String typeName, String typeDescription)
+ {
+ /*
+ * Save the values supplied
+ */
+ this.typeCode = typeCode;
+ this.typeName = typeName;
+ this.typeDescription = typeDescription;
+ }
+
+
+ /**
+ * Return the code for this enum instance
+ *
+ * @return int - type code
+ */
+ public int getTypeCode()
+ {
+ return typeCode;
+ }
+
+
+ /**
+ * Return the default name for this enum instance.
+ *
+ * @return String - default name
+ */
+ public String getTypeName()
+ {
+ return typeName;
+ }
+
+
+ /**
+ * Return the default description for the type for this enum instance.
+ *
+ * @return String - default description
+ */
+ public String getTypeDescription()
+ {
+ return typeDescription;
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/ClassificationDef.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/ClassificationDef.java b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/ClassificationDef.java
new file mode 100644
index 0000000..cfb2143
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/ClassificationDef.java
@@ -0,0 +1,162 @@
+/*
+ * 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.metadatacollection.properties.typedefs;
+
+
+import java.util.ArrayList;
+
+/**
+ * ClassificationDef stores the properties for the definition of a type of classification. Many of the properties
+ * are inherited from TypeDef. ClassificationDef adds a list of Entity Types that this Classification can be
+ * connected to and a boolean to indicate if this classification is propagatable.
+ */
+public class ClassificationDef extends TypeDef
+{
+ private ArrayList<TypeDefLink> validEntityDefs = null;
+ private boolean propagatable = false;
+
+
+ /**
+ * Minimal constructor - sets up an empty ClassificationDef.
+ */
+ public ClassificationDef()
+ {
+ super(TypeDefCategory.CLASSIFICATION_DEF);
+ }
+
+
+ /**
+ * Typical constructor is passed the properties of the typedef's super class being constructed.
+ *
+ * @param category - category of this TypeDef
+ * @param guid - unique id for the TypeDef
+ * @param name - unique name for the TypeDef
+ * @param version - active version number for the TypeDef
+ * @param versionName - unique name for the TypeDef
+ */
+ public ClassificationDef(TypeDefCategory category,
+ String guid,
+ String name,
+ long version,
+ String versionName)
+ {
+ super(category, guid, name, version, versionName);
+ }
+
+
+ /**
+ * Copy/clone constructor copies values from the supplied template.
+ *
+ * @param template - template to copy
+ */
+ public ClassificationDef(ClassificationDef template)
+ {
+ super(template);
+
+ if (template != null)
+ {
+ validEntityDefs = template.getValidEntityDefs();
+ propagatable = template.isPropagatable();
+ }
+ }
+
+
+ /**
+ * Return the list of identifiers for the types of entities that this type of Classification can be connected to.
+ *
+ * @return List of entity type identifiers
+ */
+ public ArrayList<TypeDefLink> getValidEntityDefs()
+ {
+ if (validEntityDefs == null)
+ {
+ return validEntityDefs;
+ }
+ else
+ {
+ return new ArrayList<>(validEntityDefs);
+ }
+ }
+
+
+ /**
+ * Set up the list of identifiers for the types of entities that this type of Classification can be connected to.
+ *
+ * @param validEntityDefs - List of entity type identifiers
+ */
+ public void setValidEntityDefs(ArrayList<TypeDefLink> validEntityDefs)
+ {
+ this.validEntityDefs = validEntityDefs;
+ }
+
+
+ /**
+ * Return whether this classification should propagate to other entities if the relationship linking them
+ * allows classification propagation.
+ *
+ * @return boolean flag
+ */
+ public boolean isPropagatable()
+ {
+ return propagatable;
+ }
+
+
+ /**
+ * Sets up whether this classification should propagate to other entities if the relationship linking them
+ * allows classification propagation.
+ *
+ * @param propagatable - boolean flag
+ */
+ public void setPropagatable(boolean propagatable)
+ {
+ this.propagatable = propagatable;
+ }
+
+ /**
+ * Standard toString method.
+ *
+ * @return JSON style description of variables.
+ */
+ @Override
+ public String toString()
+ {
+ return "ClassificationDef{" +
+ "validEntityDefs=" + validEntityDefs +
+ ", propagatable=" + propagatable +
+ ", superType=" + superType +
+ ", description='" + description + '\'' +
+ ", descriptionGUID='" + descriptionGUID + '\'' +
+ ", origin='" + origin + '\'' +
+ ", createdBy='" + createdBy + '\'' +
+ ", updatedBy='" + updatedBy + '\'' +
+ ", createTime=" + createTime +
+ ", updateTime=" + updateTime +
+ ", options=" + options +
+ ", externalStandardMappings=" + externalStandardMappings +
+ ", validInstanceStatusList=" + validInstanceStatusList +
+ ", initialStatus=" + initialStatus +
+ ", propertiesDefinition=" + propertiesDefinition +
+ ", version=" + version +
+ ", versionName='" + versionName + '\'' +
+ ", category=" + category +
+ ", guid='" + guid + '\'' +
+ ", name='" + name + '\'' +
+ '}';
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/ClassificationPropagationRule.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/ClassificationPropagationRule.java b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/ClassificationPropagationRule.java
new file mode 100644
index 0000000..71d6f91
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/ClassificationPropagationRule.java
@@ -0,0 +1,87 @@
+/*
+ * 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.metadatacollection.properties.typedefs;
+
+import java.io.Serializable;
+
+/**
+ * ClassificationPropagationRule is part of a relationship definition (RelationshipDef).
+ * It indicates whether classifications from one entity should propagate across a relationship instance.
+ * It allows classification for, say confidentiality to be propagated to related entities.
+ * <p>
+ * The propagation rule defines the direction of propagation:
+ * </p>
+ * <ul>
+ * <li>NONE - no propagation of classifications across the relationship.</li>
+ * <li>ONE_TO_TWO - from entity at end 1 of the relationship to the entity at end 2 of the relationship.</li>
+ * <li>TWO_TO_ONE - from entity at end 2 of the relationship to the entity at end 1 of the relationship.</li>
+ * <li>BOTH - two way propagation.</li>
+ * </ul>
+ */
+public enum ClassificationPropagationRule implements Serializable
+{
+ NONE (0, "NONE", "No classification propagation"),
+ ONE_TO_TWO (1, "ONE_TO_TWO", "Classification propagation direction is one way from entity one to entity two"),
+ TWO_TO_ONE (2, "TWO_TO_ONE", "Classification propagation direction is one way from entity two to entity one"),
+ BOTH (3, "BOTH", "Classification propagation in both directions");
+
+ private static final long serialVersionUID = 1L;
+
+ private int ordinal;
+ private String name;
+ private String description;
+
+
+ /**
+ * Constructor to set up a single instances of the enum.
+ *
+ * @param ordinal - numerical representation of the propagation rule
+ * @param name - default string name of the propagation rule
+ * @param description - default string description of the propagation rule
+ */
+ ClassificationPropagationRule(int ordinal, String name, String description)
+ {
+ this.ordinal = ordinal;
+ this.name = name;
+ this.description = description;
+ }
+
+
+ /**
+ * Return the numeric representation of the propagation rule.
+ *
+ * @return int ordinal
+ */
+ public int getOrdinal() { return ordinal; }
+
+
+ /**
+ * Return the default name of the propagation rule.
+ *
+ * @return String name
+ */
+ public String getName() { return name; }
+
+
+ /**
+ * Return the default description of the propagation rule.
+ *
+ * @return String description
+ */
+ public String getDescription() { return description; }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/CollectionDef.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/CollectionDef.java b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/CollectionDef.java
new file mode 100644
index 0000000..cca95f7
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/CollectionDef.java
@@ -0,0 +1,143 @@
+/*
+ * 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.metadatacollection.properties.typedefs;
+
+
+import java.util.ArrayList;
+
+/**
+ * CollectionDef supports the definition of a collection type. This information about the generic
+ * collection type is managed in the CollectionDefCategory. It is instantiated with specific primitive
+ * types when it is linked to a specific TypeDefAttribute.
+ */
+public class CollectionDef extends AttributeTypeDef
+{
+ private CollectionDefCategory collectionDefCategory = null;
+ private int argumentCount = 0;
+ private ArrayList<PrimitiveDefCategory> argumentTypes = null;
+
+
+ /**
+ * Typical constructor initializes the CollectionDef based on the supplied category.
+ *
+ * @param collectionDefCategory - CollectionDefCategory Enum
+ */
+ public CollectionDef(CollectionDefCategory collectionDefCategory)
+ {
+ super(AttributeTypeDefCategory.COLLECTION);
+
+ this.collectionDefCategory = collectionDefCategory;
+ this.argumentCount = collectionDefCategory.getArgumentCount();
+ this.argumentTypes = new ArrayList<>();
+
+ /*
+ * Set up the type of the elements stored in the collection as "unknown" - like an initialized Java generic.
+ */
+ for (int i=0; i<argumentCount; i++)
+ {
+ argumentTypes.add(PrimitiveDefCategory.OM_PRIMITIVE_TYPE_UNKNOWN);
+ }
+ }
+
+
+ /**
+ * Copy/clone constructor creates a copy of the supplied template.
+ *
+ * @param template CollectionDef to copy
+ */
+ public CollectionDef(CollectionDef template)
+ {
+ super(template);
+
+ if (template != null)
+ {
+ this.collectionDefCategory = template.getCollectionDefCategory();
+ this.argumentCount = template.getArgumentCount();
+ this.argumentTypes = template.getArgumentTypes();
+ }
+ }
+
+
+ /**
+ * Return the type category for this collection type.
+ *
+ * @return CollectionDefCategory Enum
+ */
+ public CollectionDefCategory getCollectionDefCategory() { return collectionDefCategory; }
+
+
+ /**
+ * Return the number of arguments needed to set up the collection type name.
+ *
+ * @return int count
+ */
+ public int getArgumentCount()
+ {
+ return argumentCount;
+ }
+
+
+ /**
+ * Return the list of argument types set up for this collection.
+ *
+ * @return list of argument type
+ */
+ public ArrayList<PrimitiveDefCategory> getArgumentTypes()
+ {
+ if (argumentTypes == null)
+ {
+ return argumentTypes;
+ }
+ else
+ {
+ return new ArrayList<>(argumentTypes);
+ }
+ }
+
+
+ /**
+ * Set up the list of argument types.
+ *
+ * @param argumentTypes - list of argument types
+ */
+ public void setArgumentTypes(ArrayList<PrimitiveDefCategory> argumentTypes)
+ {
+ this.argumentTypes = argumentTypes;
+ }
+
+
+ /**
+ * Standard toString method.
+ *
+ * @return JSON style description of variables.
+ */
+ @Override
+ public String toString()
+ {
+ return "CollectionDef{" +
+ "collectionDefCategory=" + collectionDefCategory +
+ ", argumentCount=" + argumentCount +
+ ", argumentTypes=" + argumentTypes +
+ ", category=" + category +
+ ", guid='" + guid + '\'' +
+ ", name='" + name + '\'' +
+ ", description='" + description + '\'' +
+ ", descriptionGUID='" + descriptionGUID + '\'' +
+ '}';
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/CollectionDefCategory.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/CollectionDefCategory.java b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/CollectionDefCategory.java
new file mode 100644
index 0000000..d077a66
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/CollectionDefCategory.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.metadatacollection.properties.typedefs;
+
+import org.apache.atlas.omrs.metadatacollection.properties.instances.ArrayPropertyValue;
+import org.apache.atlas.omrs.metadatacollection.properties.instances.MapPropertyValue;
+import org.apache.atlas.omrs.metadatacollection.properties.instances.StructPropertyValue;
+
+import java.io.Serializable;
+
+/**
+ * This enum defines the list of open metadata collection types. These types are generic types that need to
+ * be configured with specific primitive types before they can be used as an attribute type.
+ *
+ * The enum includes a code value, a string name for the type (used in self describing structures such as JSON or XML)
+ * and the name of the Java Class that supports this type.
+ */
+public enum CollectionDefCategory implements Serializable
+{
+ OM_COLLECTION_UNKNOWN (0, "<>", 0, null),
+ OM_COLLECTION_MAP (1, "map<{$0}, {$1}>", 2, MapPropertyValue.class.getName()),
+ OM_COLLECTION_ARRAY (2, "array<{$0}>", 1, ArrayPropertyValue.class.getName()),
+ OM_COLLECTION_STRUCT (3, "struct<>", 0, StructPropertyValue.class.getName());
+
+ private static final long serialVersionUID = 1L;
+
+ private int code;
+ private String name;
+ private int argumentCount;
+ private String javaClassName;
+
+
+ /**
+ * Constructor to set up a single instances of the enum.
+ *
+ * @param code - code for the enum
+ * @param name - String name for the enum before it is configured with primitive types
+ * @param argumentCount - number of arguments needed to configure the collection type
+ * @param javaClassName - Java class used to manage this type of collection
+ */
+ CollectionDefCategory(int code, String name, int argumentCount, String javaClassName)
+ {
+ this.code = code;
+ this.name = name;
+ this.argumentCount = argumentCount;
+ this.javaClassName = javaClassName;
+ }
+
+
+ /**
+ * Return the numeric code for the primitive type which can be used in optimized data flows.
+ *
+ * @return int type code
+ */
+ public int getCode() {
+ return code;
+ }
+
+
+ /**
+ * Return the name of type - which can be used for text-based interchange formats such as JSON or XML.
+ *
+ * @return String type name
+ */
+ public String getName() {
+ return name;
+ }
+
+
+ /**
+ * Return the number of arguments for this collection type.
+ *
+ * @return int number of elements
+ */
+ public int getArgumentCount() { return argumentCount; }
+
+
+ /**
+ * Return the name of the java class that can be used to store properties of this type.
+ *
+ * @return String java class name.
+ */
+ public String getJavaClassName() {
+ return javaClassName;
+ }
+}
[20/30] atlas git commit: ATLAS-2246: OMRS Connector API plus REST
and IGC Connector skeleton - 15th February 2018
Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/OMRSRepositoryEventExchangeRule.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/OMRSRepositoryEventExchangeRule.java b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/OMRSRepositoryEventExchangeRule.java
new file mode 100644
index 0000000..66072ed
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/OMRSRepositoryEventExchangeRule.java
@@ -0,0 +1,166 @@
+/*
+ * 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.admin.properties.OpenMetadataExchangeRule;
+import org.apache.atlas.omrs.metadatacollection.properties.instances.EntityDetail;
+import org.apache.atlas.omrs.metadatacollection.properties.instances.Relationship;
+import org.apache.atlas.omrs.metadatacollection.properties.typedefs.TypeDefSummary;
+import org.apache.atlas.omrs.localrepository.repositorycontentmanager.OMRSTypeDefValidator;
+
+import java.util.ArrayList;
+
+/**
+ * OMRSRepositoryEventExchangeRule determines if particular types of events should be exchanged on the OMRS Topic.
+ */
+public class OMRSRepositoryEventExchangeRule
+{
+ private String sourceName;
+ private OMRSTypeDefValidator typeDefValidator;
+ private OpenMetadataExchangeRule exchangeRule;
+ private ArrayList<TypeDefSummary> selectedTypesToProcess;
+
+
+ /**
+ * Constructor provides all of the objects used in the event exchange decision.
+ *
+ * @param sourceName - name of the caller
+ * @param typeDefValidator - local manager of the type definitions (TypeDefs) used by the local repository.
+ * @param exchangeRule - enum detailing the types of events to process.
+ * @param selectedTypesToProcess - supplementary list to support selective processing of events.
+ */
+ public OMRSRepositoryEventExchangeRule(String sourceName,
+ OMRSTypeDefValidator typeDefValidator,
+ OpenMetadataExchangeRule exchangeRule,
+ ArrayList<TypeDefSummary> selectedTypesToProcess)
+ {
+ this.sourceName = sourceName;
+ this.typeDefValidator = typeDefValidator;
+ this.exchangeRule = exchangeRule;
+ this.selectedTypesToProcess = selectedTypesToProcess;
+ }
+
+
+ /**
+ * Determine if TypeDef events should be processed.
+ *
+ * @return boolean flag
+ */
+ public boolean processTypeDefEvents()
+ {
+ if (exchangeRule != OpenMetadataExchangeRule.REGISTRATION_ONLY)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+
+ /**
+ * Determine from the type of the instance if an instance event should be processed.
+ *
+ * @param typeDefGUID - unique identifier of the type
+ * @param typeDefName - unique name of the type
+ * @return boolean flag
+ */
+ public boolean processInstanceEvent(String typeDefGUID, String typeDefName)
+ {
+ if (typeDefValidator == null)
+ {
+ return false;
+ }
+ else
+ {
+ return typeDefValidator.isActiveType(sourceName, typeDefGUID, typeDefName);
+ }
+ }
+
+
+ /**
+ * Determine from the type of the instance if an instance event should be processed.
+ *
+ * @param typeDefSummary - details of the type
+ * @return boolean flag
+ */
+ public boolean processInstanceEvent(TypeDefSummary typeDefSummary)
+ {
+ if (typeDefValidator == null)
+ {
+ return false;
+ }
+ if (typeDefSummary == null)
+ {
+ return false;
+ }
+ else
+ {
+ return typeDefValidator.isActiveType(sourceName, typeDefSummary.getGUID(), typeDefSummary.getName());
+ }
+ }
+
+
+ /**
+ * Determine from the type of the instance if an instance event should be processed.
+ *
+ * @param entity - details of the instance to test
+ * @return boolean flag
+ */
+ public boolean processInstanceEvent(EntityDetail entity)
+ {
+ if (typeDefValidator == null)
+ {
+ return false;
+ }
+ else if (entity == null)
+ {
+ return false;
+ }
+ else
+ {
+ // TODO
+ return true;
+ }
+ }
+
+
+ /**
+ * Determine from the type of the instance if an instance event should be processed.
+ *
+ * @param relationship - details of the instance to test
+ * @return boolean flag
+ */
+ public boolean processInstanceEvent(Relationship relationship)
+ {
+ if (typeDefValidator == null)
+ {
+ return false;
+ }
+ else if (relationship == null)
+ {
+ return false;
+ }
+ else
+ {
+ // TODO
+ return true;
+ }
+ }
+}
[25/30] atlas git commit: ATLAS-2246: OMRS Connector API plus REST
and IGC Connector skeleton - 15th February 2018
Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/auditlog/OMRSAuditingComponent.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/auditlog/OMRSAuditingComponent.java b/omrs/src/main/java/org/apache/atlas/omrs/auditlog/OMRSAuditingComponent.java
new file mode 100644
index 0000000..5e1e33b
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/auditlog/OMRSAuditingComponent.java
@@ -0,0 +1,261 @@
+/*
+ * 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.admin.OMRSConfigurationFactory;
+import org.apache.atlas.omrs.admin.OMRSOperationalServices;
+import org.apache.atlas.omrs.archivemanager.OMRSArchiveManager;
+import org.apache.atlas.omrs.enterprise.connectormanager.OMRSEnterpriseConnectorManager;
+import org.apache.atlas.omrs.enterprise.repositoryconnector.EnterpriseOMRSRepositoryConnector;
+import org.apache.atlas.omrs.eventmanagement.OMRSRepositoryEventManager;
+import org.apache.atlas.omrs.localrepository.repositoryconnector.LocalOMRSInstanceEventProcessor;
+import org.apache.atlas.omrs.localrepository.repositoryconnector.LocalOMRSRepositoryConnector;
+import org.apache.atlas.omrs.localrepository.repositorycontentmanager.OMRSRepositoryContentManager;
+import org.apache.atlas.omrs.metadatahighway.OMRSMetadataHighwayManager;
+import org.apache.atlas.omrs.metadatahighway.cohortregistry.OMRSCohortRegistry;
+import org.apache.atlas.omrs.metadatahighway.cohortregistry.store.OMRSCohortRegistryStore;
+import org.apache.atlas.omrs.eventmanagement.OMRSEventListener;
+import org.apache.atlas.omrs.eventmanagement.OMRSEventPublisher;
+import org.apache.atlas.omrs.metadatahighway.OMRSCohortManager;
+import org.apache.atlas.omrs.rest.repositoryconnector.OMRSRESTRepositoryConnector;
+import org.apache.atlas.omrs.rest.server.OMRSRepositoryRESTServices;
+import org.apache.atlas.omrs.topicconnectors.OMRSTopicConnector;
+
+
+/**
+ * OMRSAuditingComponent provides identifying and background information about the components writing log records
+ * to the OMRS Audit log. This is to help someone reading the OMRS Audit Log understand the records.
+ */
+public enum OMRSAuditingComponent
+{
+ UNKNOWN (0,
+ "<Unknown>", "Uninitialized component name", null, null),
+
+ AUDIT_LOG (1,
+ "Audit Log",
+ "Reads and writes records to the Open Metadata Repository Services (OMRS) audit log.",
+ OMRSAuditLog.class.getName(),
+ "https://cwiki.apache.org/confluence/display/ATLAS/OMRS+Audit+Log"),
+
+ CONFIGURATION_FACTORY (2,
+ "Configuration Factory",
+ "Generates default values for the Open Metadata Repository Services (OMRS) configuration.",
+ OMRSConfigurationFactory.class.getName(),
+ "https://cwiki.apache.org/confluence/display/ATLAS/OMRS+Configuration+Factory"),
+
+ OPERATIONAL_SERVICES (3,
+ "Operational Services",
+ "Supports the administration services for the Open Metadata Repository Services (OMRS).",
+ OMRSOperationalServices.class.getName(),
+ "https://cwiki.apache.org/confluence/display/ATLAS/OMRS+Operational+Services"),
+
+ ARCHIVE_MANAGER (4,
+ "Archive Manager",
+ "Manages the loading of Open Metadata Archives into an open metadata repository.",
+ OMRSArchiveManager.class.getName(),
+ "https://cwiki.apache.org/confluence/display/ATLAS/OMRS+Archive+Manager"),
+
+ ENTERPRISE_CONNECTOR_MANAGER (5,
+ "Enterprise Connector Manager",
+ "Manages the list of open metadata repositories that the Enterprise OMRS Repository Connector " +
+ "should call to retrieve an enterprise view of the metadata collections " +
+ "supported by these repositories",
+ OMRSEnterpriseConnectorManager.class.getName(),
+ "https://cwiki.apache.org/confluence/display/ATLAS/OMRS+Enterprise+Connector+Manager"),
+
+ ENTERPRISE_REPOSITORY_CONNECTOR (6,
+ "Enterprise Repository Connector",
+ "Supports enterprise access to the list of open metadata repositories registered " +
+ "with the OMRS Enterprise Connector Manager.",
+ EnterpriseOMRSRepositoryConnector.class.getName(),
+ "https://cwiki.apache.org/confluence/display/ATLAS/Enterprise+OMRS+Repository+Connector"),
+
+ LOCAL_REPOSITORY_CONNECTOR (7,
+ "Local Repository Connector",
+ "Supports access to metadata stored in the local server's repository and ensures " +
+ "repository events are generated when metadata changes in the local repository",
+ LocalOMRSRepositoryConnector.class.getName(),
+ "https://cwiki.apache.org/confluence/display/ATLAS/Local+OMRS+Repository+Connector"),
+
+ TYPEDEF_MANAGER (8,
+ "Local TypeDef Manager",
+ "Supports an in-memory cache for open metadata type definitions (TypeDefs) used for " +
+ "verifying TypeDefs in use in other open metadata repositories and for " +
+ "constructing new metadata instances.",
+ OMRSRepositoryContentManager.class.getName(),
+ "https://cwiki.apache.org/confluence/display/ATLAS/Local+OMRS+TypeDef+Manager"),
+
+ INSTANCE_EVENT_PROCESSOR (8,
+ "Local Inbound Instance Event Processor",
+ "Supports the loading of reference metadata into the local repository that has come from other members of the local server's cohorts and open metadata archives.",
+ LocalOMRSInstanceEventProcessor.class.getName(),
+ "https://cwiki.apache.org/confluence/display/ATLAS/Local+OMRS+Instance+Event+Processor"),
+
+ REPOSITORY_EVENT_MANAGER (9,
+ "Repository Event Manager",
+ "Distribute repository events (TypeDefs, Entity and Instance events) between internal OMRS components within a server.",
+ OMRSRepositoryEventManager.class.getName(),
+ "https://cwiki.apache.org/confluence/display/ATLAS/OMRS+Repository+Event+Manager"),
+
+ REST_SERVICES (10,
+ "Repository REST Services",
+ "Provides the server-side support the the OMRS Repository Services REST API.",
+ OMRSRepositoryRESTServices.class.getName(),
+ "https://cwiki.apache.org/confluence/display/ATLAS/OMRS+Repository+REST+Services"),
+
+ REST_REPOSITORY_CONNECTOR (11,
+ "REST Repository Connector",
+ "Supports an OMRS Repository Connector for calling the OMRS Repository REST API in a remote " +
+ "open metadata repository.",
+ OMRSRESTRepositoryConnector.class.getName(),
+ "https://cwiki.apache.org/confluence/display/ATLAS/OMRS+REST+Repository+Connector"),
+
+ METADATA_HIGHWAY_MANAGER (12,
+ "Metadata Highway Manager",
+ "Manages the initialization and shutdown of the components that connector to each of the cohorts that the local server is a member of.",
+ OMRSMetadataHighwayManager.class.getName(),
+ "https://cwiki.apache.org/confluence/display/ATLAS/OMRS+Metadata+Highway+Manager"),
+
+ COHORT_MANAGER (13,
+ "Cohort Manager",
+ "Manages the initialization and shutdown of the server's connectivity to a cohort.",
+ OMRSCohortManager.class.getName(),
+ "https://cwiki.apache.org/confluence/display/ATLAS/OMRS+Cohort+Manager"),
+
+ COHORT_REGISTRY(14,
+ "Cohort Registry",
+ "Manages the registration requests send and received from this local repository.",
+ OMRSCohortRegistry.class.getName(),
+ "https://cwiki.apache.org/confluence/display/ATLAS/OMRS+Cohort+Registry"),
+
+ REGISTRY_STORE (15,
+ "Registry Store",
+ "Stores information about the repositories registered in the open metadata repository cohort.",
+ OMRSCohortRegistryStore.class.getName(),
+ "https://cwiki.apache.org/confluence/display/ATLAS/OMRS+Cohort+Registry+Store"),
+
+ EVENT_PUBLISHER (16,
+ "Event Publisher",
+ "Manages the publishing of events that this repository sends to the OMRS topic.",
+ OMRSEventPublisher.class.getName(),
+ "https://cwiki.apache.org/confluence/display/ATLAS/OMRS+Event+Publisher"),
+
+ EVENT_LISTENER (17,
+ "Event Listener",
+ "Manages the receipt of incoming OMRS events.",
+ OMRSEventListener.class.getName(),
+ "https://cwiki.apache.org/confluence/display/ATLAS/OMRS+Event+Listener"),
+
+ OMRS_TOPIC_CONNECTOR(18,
+ "OMRS Topic Connector",
+ "Provides access to the OMRS Topic that is used to exchange events between members of a cohort, " +
+ "or to notify Open Metadata Access Services (OMASs) of changes to " +
+ "metadata in the enterprise.",
+ OMRSTopicConnector.class.getName(),
+ "https://cwiki.apache.org/confluence/display/ATLAS/OMRS+Topic+Connector")
+ ;
+
+
+ private int componentId;
+ private String componentName;
+ private String componentDescription;
+ private String componentJavaClass;
+ private String componentWikiURL;
+
+
+ /**
+ * Set up the values of the enum.
+ *
+ * @param componentId - code number for the component.
+ * @param componentName - name of the component used in the audit log record.
+ * @param componentDescription - short description of the component.
+ * @param componentJavaClass - name of java class for the component - if logic errors need to be investigated.
+ * @param componentWikiURL - URL link to the description of the component.
+ */
+ OMRSAuditingComponent(int componentId,
+ String componentName,
+ String componentDescription,
+ String componentJavaClass,
+ String componentWikiURL)
+ {
+ this.componentId = componentId;
+ this.componentName = componentName;
+ this.componentDescription = componentDescription;
+ this.componentJavaClass = componentJavaClass;
+ this.componentWikiURL = componentWikiURL;
+ }
+
+
+ /**
+ * Return the numerical code for this enum.
+ *
+ * @return int componentId
+ */
+ public int getComponentId()
+ {
+ return componentId;
+ }
+
+
+ /**
+ * Return the name of the component. This is the name used in the audit log records.
+ *
+ * @return String component name
+ */
+ public String getComponentName()
+ {
+ return componentName;
+ }
+
+
+ /**
+ * Return the short description of the component. This is an English description. Natural language support for
+ * these values can be added to UIs using a resource bundle indexed with the component Id. This value is
+ * provided as a default if the resource bundle is not available.
+ *
+ * @return String description
+ */
+ public String getComponentDescription()
+ {
+ return componentDescription;
+ }
+
+
+ /**
+ * Name of the java class supporting this component. This value is provided for debug and not normally make
+ * available on end user UIs for security reasons.
+ *
+ * @return String fully-qualified java class name
+ */
+ public String getComponentJavaClass()
+ {
+ return componentJavaClass;
+ }
+
+
+ /**
+ * URL link to the wiki page that describes this component. This provides more information to the log reader
+ * on the operation of the component.
+ *
+ * @return String URL
+ */
+ public String getComponentWikiURL()
+ {
+ return componentWikiURL;
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/auditlog/store/OMRSAuditLogRecord.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/auditlog/store/OMRSAuditLogRecord.java b/omrs/src/main/java/org/apache/atlas/omrs/auditlog/store/OMRSAuditLogRecord.java
new file mode 100644
index 0000000..90aa7ac
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/auditlog/store/OMRSAuditLogRecord.java
@@ -0,0 +1,243 @@
+/*
+ * 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.store;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.UUID;
+
+/**
+ * OMRSAuditLogRecord provides a carrier for details about a single log record in the OMRS audit log.
+ */
+public class OMRSAuditLogRecord
+{
+ private String guid = null;
+ private Date timeStamp = new Date();
+ private OMRSAuditLogRecordOriginator originator = null;
+ private String severity = null;
+ private OMRSAuditLogReportingComponent reportingComponent = null;
+ private String messageId = null;
+ private String messageText = null;
+ private ArrayList<String> additionalInformation = null;
+ private String systemAction = null;
+ private String userAction = null;
+
+
+ /**
+ * Audit log records are immutable so the only way to update the values is through the constructor.
+ *
+ * @param originator - details of the originating server
+ * @param reportingComponent - details of the component making the audit log entry.
+ * @param severity - OMRSAuditLogRecordSeverity enum that indicates the severity of log record.
+ * @param messageId - id of the message in the audit log record.
+ * @param messageText - description of the message for the audit log record.
+ * @param additionalInformation - additional properties that help to describe the situation.
+ * @param systemAction - action taken by the system.
+ * @param userAction - followup action that should be taken by the target end user (typically the server
+ * administrator).
+ */
+ public OMRSAuditLogRecord(OMRSAuditLogRecordOriginator originator,
+ OMRSAuditLogReportingComponent reportingComponent,
+ String severity,
+ String messageId,
+ String messageText,
+ ArrayList<String> additionalInformation,
+ String systemAction,
+ String userAction)
+ {
+ this.guid = UUID.randomUUID().toString();
+ this.originator = originator;
+ this.severity = severity;
+ this.reportingComponent = reportingComponent;
+ this.messageId = messageId;
+ this.messageText = messageText;
+ this.additionalInformation = additionalInformation;
+ this.systemAction = systemAction;
+ this.userAction = userAction;
+ }
+
+ /**
+ * Return the unique Id of the audit log record
+ *
+ * @return String guid
+ */
+ public String getGUID()
+ {
+ return guid;
+ }
+
+
+ /**
+ * Return the time stamp for when the audit log record was created.
+ *
+ * @return Date object
+ */
+ public Date getTimeStamp()
+ {
+ return timeStamp;
+ }
+
+
+ /**
+ * Return details of the originator of the log record.
+ *
+ * @return OMRSAuditLogRecordOriginator object
+ */
+ public OMRSAuditLogRecordOriginator getOriginator()
+ {
+ return originator;
+ }
+
+
+ /**
+ * Return the severity of the situation recorded in the log record.
+ *
+ * @return String severity
+ */
+ public String getSeverity()
+ {
+ return severity;
+ }
+
+
+ /**
+ * Return the name of the component that reported the situation recorded in the log record.
+ *
+ * @return OMRSAuditLogReportingComponent object
+ */
+ public OMRSAuditLogReportingComponent getReportingComponent()
+ {
+ return reportingComponent;
+ }
+
+
+ /**
+ * Return the identifier of the message within the log record.
+ *
+ * @return String message Id
+ */
+ public String getMessageId()
+ {
+ return messageId;
+ }
+
+
+ /**
+ * Return the text of the message within the log record.
+ *
+ * @return String message text
+ */
+ public String getMessageText()
+ {
+ return messageText;
+ }
+
+
+ /**
+ * Return any additional information in the audit log record.
+ *
+ * @return String additional information
+ */
+ public ArrayList<String> getAdditionalInformation()
+ {
+ return additionalInformation;
+ }
+
+
+ public String getSystemAction()
+ {
+ return systemAction;
+ }
+
+ public String getUserAction()
+ {
+ return userAction;
+ }
+
+ @Override
+ public String toString()
+ {
+ String originatorString = null;
+ if (this.originator != null)
+ {
+ originatorString = this.originator.toString();
+ }
+
+ String reportingComponentString = null;
+ if (this.reportingComponent != null)
+ {
+ reportingComponentString = this.reportingComponent.toString();
+ }
+
+ String additionalInformationString = null;
+ if (this.additionalInformation != null)
+ {
+ boolean notFirst = false;
+
+ additionalInformationString = "[ ";
+
+ for (String nugget : additionalInformation)
+ {
+ if (notFirst)
+ {
+ additionalInformationString = additionalInformationString + ", ";
+ notFirst = true;
+ }
+
+ additionalInformationString = additionalInformationString + nugget;
+ }
+
+ additionalInformationString = additionalInformationString + " ]";
+ }
+
+ return "AuditLogRecord { " +
+ "timestamp : " + timeStamp.toString() + ", " +
+ "guid : " + guid + ", " +
+ "originator : " + originatorString + ", " +
+ "severity : " + severity + ", " +
+ "reportingComponent : " + reportingComponentString + ", " +
+ "messageId : " + messageId + ", " +
+ "messageText : " + messageText + ", " +
+ "additionalInformation : " + additionalInformationString + ", " +
+ "systemAction : " + systemAction + ", " +
+ "userAction : " + userAction + " }";
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return super.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object object)
+ {
+ if (this == object)
+ {
+ return true;
+ }
+ if (object == null || getClass() != object.getClass())
+ {
+ return false;
+ }
+
+ OMRSAuditLogRecord that = (OMRSAuditLogRecord) object;
+
+ return guid.equals(that.guid);
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/auditlog/store/OMRSAuditLogRecordOriginator.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/auditlog/store/OMRSAuditLogRecordOriginator.java b/omrs/src/main/java/org/apache/atlas/omrs/auditlog/store/OMRSAuditLogRecordOriginator.java
new file mode 100644
index 0000000..e69e5b1
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/auditlog/store/OMRSAuditLogRecordOriginator.java
@@ -0,0 +1,179 @@
+/*
+ * 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.store;
+
+/**
+ * OMRSAuditLogRecordOriginator describes the server that originated an audit log record. This is useful if
+ * an organization is aggregating messages from different servers together.
+ */
+public class OMRSAuditLogRecordOriginator
+{
+ 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 OMRSAuditLogRecordOriginator()
+ {
+ }
+
+
+ /**
+ * 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;
+ }
+
+
+ @Override
+ public String toString()
+ {
+ return "Originator { " +
+ "metadataCollectionId : " + this.metadataCollectionId + ", " +
+ "serverName : " + this.serverName + ", " +
+ "serverType : " + this.serverType + ", " +
+ "organizationName : " + this.organizationName + " }";
+ }
+
+ @Override
+ public boolean equals(Object o)
+ {
+ if (this == o)
+ {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass())
+ {
+ return false;
+ }
+
+ OMRSAuditLogRecordOriginator that = (OMRSAuditLogRecordOriginator) o;
+
+ if (metadataCollectionId != null ? !metadataCollectionId.equals(that.metadataCollectionId) : that.metadataCollectionId != null)
+ {
+ return false;
+ }
+ if (serverName != null ? !serverName.equals(that.serverName) : that.serverName != null)
+ {
+ return false;
+ }
+ if (serverType != null ? !serverType.equals(that.serverType) : that.serverType != null)
+ {
+ return false;
+ }
+ return organizationName != null ? organizationName.equals(that.organizationName) : that.organizationName == null;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ int result = metadataCollectionId != null ? metadataCollectionId.hashCode() : 0;
+ result = 31 * result + (serverName != null ? serverName.hashCode() : 0);
+ result = 31 * result + (serverType != null ? serverType.hashCode() : 0);
+ result = 31 * result + (organizationName != null ? organizationName.hashCode() : 0);
+ return result;
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/auditlog/store/OMRSAuditLogReportingComponent.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/auditlog/store/OMRSAuditLogReportingComponent.java b/omrs/src/main/java/org/apache/atlas/omrs/auditlog/store/OMRSAuditLogReportingComponent.java
new file mode 100644
index 0000000..a5077ab
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/auditlog/store/OMRSAuditLogReportingComponent.java
@@ -0,0 +1,145 @@
+/*
+ * 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.store;
+
+/**
+ * OMRSAuditLogReportingComponent describes the component issuing the audit log record.
+ */
+public class OMRSAuditLogReportingComponent
+{
+ private int componentId = 0;
+ private String componentName = null;
+ private String componentDescription = null;
+ private String componentWikiURL = null;
+
+
+ /**
+ * Construct the description of the reporting component.
+ *
+ * @param componentId - numerical identifier for the component.
+ * @param componentName - display name for the component.
+ * @param componentDescription - description of the component.
+ * @param componentWikiURL - link to more information.
+ */
+ public OMRSAuditLogReportingComponent(int componentId,
+ String componentName,
+ String componentDescription,
+ String componentWikiURL)
+ {
+ this.componentId = componentId;
+ this.componentName = componentName;
+ this.componentDescription = componentDescription;
+ this.componentWikiURL = componentWikiURL;
+ }
+
+ /**
+ * Return the numerical code for this enum.
+ *
+ * @return int componentId
+ */
+ public int getComponentId()
+ {
+ return componentId;
+ }
+
+
+ /**
+ * Return the name of the component. This is the name used in the audit log records.
+ *
+ * @return String component name
+ */
+ public String getComponentName()
+ {
+ return componentName;
+ }
+
+
+ /**
+ * Return the short description of the component. This is an English description. Natural language support for
+ * these values can be added to UIs using a resource bundle indexed with the component Id. This value is
+ * provided as a default if the resource bundle is not available.
+ *
+ * @return String description
+ */
+ public String getComponentDescription()
+ {
+ return componentDescription;
+ }
+
+
+ /**
+ * URL link to the wiki page that describes this component. This provides more information to the log reader
+ * on the operation of the component.
+ *
+ * @return String URL
+ */
+ public String getComponentWikiURL()
+ {
+ return componentWikiURL;
+ }
+
+
+ @Override
+ public String toString()
+ {
+ return "ReportingComponent { " +
+ "id : " + this.componentId + ", " +
+ "name : " + this.componentName + ", " +
+ "description : " + this.componentDescription + ", " +
+ "url : " + this.componentWikiURL + " }";
+ }
+
+ @Override
+ public boolean equals(Object o)
+ {
+ if (this == o)
+ {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass())
+ {
+ return false;
+ }
+
+ OMRSAuditLogReportingComponent that = (OMRSAuditLogReportingComponent) o;
+
+ if (componentId != that.componentId)
+ {
+ return false;
+ }
+ if (componentName != null ? !componentName.equals(that.componentName) : that.componentName != null)
+ {
+ return false;
+ }
+ if (componentDescription != null ? !componentDescription.equals(that.componentDescription) : that.componentDescription != null)
+ {
+ return false;
+ }
+ return componentWikiURL != null ? componentWikiURL.equals(that.componentWikiURL) : that.componentWikiURL == null;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ int result = componentId;
+ result = 31 * result + (componentName != null ? componentName.hashCode() : 0);
+ result = 31 * result + (componentDescription != null ? componentDescription.hashCode() : 0);
+ result = 31 * result + (componentWikiURL != null ? componentWikiURL.hashCode() : 0);
+ return result;
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/auditlog/store/OMRSAuditLogStore.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/auditlog/store/OMRSAuditLogStore.java b/omrs/src/main/java/org/apache/atlas/omrs/auditlog/store/OMRSAuditLogStore.java
new file mode 100644
index 0000000..650cd74
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/auditlog/store/OMRSAuditLogStore.java
@@ -0,0 +1,108 @@
+/*
+ * 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.store;
+
+import org.apache.atlas.omrs.ffdc.exception.PagingErrorException;
+import org.apache.atlas.omrs.ffdc.exception.PropertyErrorException;
+
+import java.util.ArrayList;
+import java.util.Date;
+
+/**
+ * OMRSAuditLogStore is the specialized data API for an Audit Log connector.
+ */
+public interface OMRSAuditLogStore
+{
+ /**
+ * Store the audit log record in the audit log store.
+ *
+ * @param logRecord - log record to store
+ * @return unique identifier assigned to the log record
+ * @throws PropertyErrorException - indicates that the logRecord parameter is invalid.
+ */
+ String storeLogRecord(OMRSAuditLogRecord logRecord) throws PropertyErrorException;
+
+
+ /**
+ * Retrieve a specific audit log record.
+ *
+ * @param logRecordId - unique identifier for the log record
+ * @return requested audit log record
+ * @throws PropertyErrorException - indicates that the logRecordId parameter is invalid.
+ */
+ OMRSAuditLogRecord getAuditLogRecord(String logRecordId) throws PropertyErrorException;
+
+
+ /**
+ * Retrieve a list of log records written in a specified time period. The offset and maximumRecords
+ * parameters support a paging
+ *
+ * @param startDate - start of time period
+ * @param endDate - end of time period
+ * @param offset - offset of full collection to begin the return results
+ * @param maximumRecords - maximum number of log records to return
+ * @return list of log records from the specified time period
+ * @throws PropertyErrorException - indicates that the start and/or end date parameters are invalid.
+ * @throws PagingErrorException - indicates that the offset or the maximumRecords parameters are invalid.
+ */
+ ArrayList<OMRSAuditLogRecord> getAuditLogRecordsByTimeStamp(Date startDate,
+ Date endDate,
+ int offset,
+ int maximumRecords) throws PropertyErrorException,
+ PagingErrorException;
+
+ /**
+ * Retrieve a list of log records that have specific severity. The offset and maximumRecords
+ * parameters support a paging model.
+ *
+ * @param severity - the severity value of messages to return
+ * @param startDate - start of time period
+ * @param endDate - end of time period
+ * @param offset - offset of full collection to begin the return results
+ * @param maximumRecords - maximum number of log records to return
+ * @return list of log records from the specified time period
+ * @throws PropertyErrorException - indicates that the severity, start and/or end date parameters are invalid.
+ * @throws PagingErrorException - indicates that the offset or the maximumRecords parameters are invalid.
+ */
+ ArrayList<OMRSAuditLogRecord> getAuditLogRecordsBySeverity(String severity,
+ Date startDate,
+ Date endDate,
+ int offset,
+ int maximumRecords) throws PropertyErrorException,
+ PagingErrorException;
+
+ /**
+ * Retrieve a list of log records written by a specific component. The offset and maximumRecords
+ * parameters support a paging model.
+ *
+ * @param component - name of the component to retrieve events from
+ * @param startDate - start of time period
+ * @param endDate - end of time period
+ * @param offset - offset of full collection to begin the return results
+ * @param maximumRecords - maximum number of log records to return
+ * @return list of log records from the specified time period
+ * @throws PropertyErrorException - indicates that the component, start and/or end date parameters are invalid.
+ * @throws PagingErrorException - indicates that the offset or the maximumRecords parameters are invalid.
+ */
+ ArrayList<OMRSAuditLogRecord> getAuditLogRecordsByComponent(String component,
+ Date startDate,
+ Date endDate,
+ int offset,
+ int maximumRecords) throws PropertyErrorException,
+ PagingErrorException;
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/auditlog/store/OMRSAuditLogStoreConnectorBase.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/auditlog/store/OMRSAuditLogStoreConnectorBase.java b/omrs/src/main/java/org/apache/atlas/omrs/auditlog/store/OMRSAuditLogStoreConnectorBase.java
new file mode 100644
index 0000000..6e30716
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/auditlog/store/OMRSAuditLogStoreConnectorBase.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.auditlog.store;
+
+import org.apache.atlas.ocf.ConnectorBase;
+
+/**
+ * OMRSAuditLogStoreConnectorBase is the base calss for connectors that support the OMRSAuditLog
+ */
+public abstract class OMRSAuditLogStoreConnectorBase extends ConnectorBase implements OMRSAuditLogStore
+{
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/auditlog/store/OMRSAuditLogStoreProviderBase.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/auditlog/store/OMRSAuditLogStoreProviderBase.java b/omrs/src/main/java/org/apache/atlas/omrs/auditlog/store/OMRSAuditLogStoreProviderBase.java
new file mode 100644
index 0000000..4f27767
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/auditlog/store/OMRSAuditLogStoreProviderBase.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.auditlog.store;
+
+import org.apache.atlas.ocf.ConnectorProviderBase;
+
+/**
+ * The OMRSAuditLogStoreProviderBase provides a base class for the connector provider supporting OMRS
+ * audit log stores. It extends ConnectorProviderBase which does the creation of connector instances.
+ * The subclasses of OMRSAuditLogStoreProviderBase 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 OMRSAuditLogStoreProviderBase extends ConnectorProviderBase
+{
+ /**
+ * Default Constructor
+ */
+ public OMRSAuditLogStoreProviderBase()
+ {
+ /*
+ * Nothing to do
+ */
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/auditlog/store/file/FileBasedAuditLogStoreConnector.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/auditlog/store/file/FileBasedAuditLogStoreConnector.java b/omrs/src/main/java/org/apache/atlas/omrs/auditlog/store/file/FileBasedAuditLogStoreConnector.java
new file mode 100644
index 0000000..ede85bb
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/auditlog/store/file/FileBasedAuditLogStoreConnector.java
@@ -0,0 +1,164 @@
+/*
+ * 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.store.file;
+
+import org.apache.atlas.omrs.auditlog.store.OMRSAuditLogRecord;
+import org.apache.atlas.omrs.auditlog.store.OMRSAuditLogStoreConnectorBase;
+import org.apache.atlas.omrs.ffdc.exception.PagingErrorException;
+import org.apache.atlas.omrs.ffdc.exception.PropertyErrorException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.Date;
+
+/**
+ * FileBasedAuditLogStoreConnector provides a connector implementation for a file based audit log.
+ * The audit log is stored in a directory and each audit log record is stored as a file with a filename build
+ * from the record's unique identifier (guid).
+ */
+public class FileBasedAuditLogStoreConnector extends OMRSAuditLogStoreConnectorBase
+{
+ private static final Logger log = LoggerFactory.getLogger(FileBasedAuditLogStoreConnector.class);
+
+
+ /**
+ * Default constructor used by the connector provider.
+ */
+ public FileBasedAuditLogStoreConnector()
+ {
+ }
+
+
+ /**
+ * Store the audit log record in the audit log store.
+ *
+ * @param logRecord - log record to store
+ * @return unique identifier assigned to the log record
+ * @throws PropertyErrorException - indicates that the logRecord parameter is invalid.
+ */
+ public String storeLogRecord(OMRSAuditLogRecord logRecord) throws PropertyErrorException
+ {
+ if (logRecord == null)
+ {
+ // TODO Throw PropertyErrorException
+ }
+
+ if (log.isDebugEnabled())
+ {
+ log.debug("AuditLogRecord: ", logRecord.toString());
+ }
+
+ return null;
+ }
+
+
+ /**
+ * Retrieve a specific audit log record.
+ *
+ * @param logRecordId - unique identifier for the log record
+ * @return requested audit log record
+ * @throws PropertyErrorException - indicates that the logRecordId parameter is invalid.
+ */
+ public OMRSAuditLogRecord getAuditLogRecord(String logRecordId) throws PropertyErrorException
+ {
+ if (logRecordId == null)
+ {
+ // TODO Throw PropertyErrorException
+ }
+
+ return null;
+ }
+
+
+ /**
+ * Retrieve a list of log records written in a specified time period. The offset and maximumRecords
+ * parameters support a paging
+ *
+ * @param startDate - start of time period
+ * @param endDate - end of time period
+ * @param offset - offset of full collection to begin the return results
+ * @param maximumRecords - maximum number of log records to return
+ * @return list of log records from the specified time period
+ * @throws PropertyErrorException - indicates that the start and/or end date parameters are invalid.
+ * @throws PagingErrorException - indicates that the offset or the maximumRecords parameters are invalid.
+ */
+ public ArrayList<OMRSAuditLogRecord> getAuditLogRecordsByTimeStamp(Date startDate,
+ Date endDate,
+ int offset,
+ int maximumRecords) throws PropertyErrorException,
+ PagingErrorException
+ {
+ return null;
+ }
+
+ /**
+ * Retrieve a list of log records of a specific severity. The offset and maximumRecords
+ * parameters support a paging model.
+ *
+ * @param severity - the severity value of messages to return
+ * @param startDate - start of time period
+ * @param endDate - end of time period
+ * @param offset - offset of full collection to begin the return results
+ * @param maximumRecords - maximum number of log records to return
+ * @return list of log records from the specified time period
+ * @throws PropertyErrorException - indicates that the severity, start and/or end date parameters are invalid.
+ * @throws PagingErrorException - indicates that the offset or the maximumRecords parameters are invalid.
+ */
+ public ArrayList<OMRSAuditLogRecord> getAuditLogRecordsBySeverity(String severity,
+ Date startDate,
+ Date endDate,
+ int offset,
+ int maximumRecords) throws PropertyErrorException,
+ PagingErrorException
+ {
+ return null;
+ }
+
+
+ /**
+ * Retrieve a list of log records written by a specific component. The offset and maximumRecords
+ * parameters support a paging model.
+ *
+ * @param component - name of the component to retrieve events from
+ * @param startDate - start of time period
+ * @param endDate - end of time period
+ * @param offset - offset of full collection to begin the return results
+ * @param maximumRecords - maximum number of log records to return
+ * @return list of log records from the specified time period
+ * @throws PropertyErrorException - indicates that the component, start and/or end date parameters are invalid.
+ * @throws PagingErrorException - indicates that the offset or the maximumRecords parameters are invalid.
+ */
+ public ArrayList<OMRSAuditLogRecord> getAuditLogRecordsByComponent(String component,
+ Date startDate,
+ Date endDate,
+ int offset,
+ int maximumRecords) throws PropertyErrorException,
+ PagingErrorException
+ {
+ return null;
+ }
+
+
+ /**
+ * Free up any resources held since the connector is no longer needed.
+ */
+ public void disconnect()
+ {
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/auditlog/store/file/FileBasedAuditLogStoreProvider.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/auditlog/store/file/FileBasedAuditLogStoreProvider.java b/omrs/src/main/java/org/apache/atlas/omrs/auditlog/store/file/FileBasedAuditLogStoreProvider.java
new file mode 100644
index 0000000..d49045d
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/auditlog/store/file/FileBasedAuditLogStoreProvider.java
@@ -0,0 +1,37 @@
+/*
+ * 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.store.file;
+
+import org.apache.atlas.omrs.auditlog.store.OMRSAuditLogStoreProviderBase;
+
+/**
+ * FileBasedRegistryStoreProvider is the OCF connector provider for the file based cohort registry store.
+ */
+public class FileBasedAuditLogStoreProvider extends OMRSAuditLogStoreProviderBase
+{
+ /**
+ * Constructor used to initialize the ConnectorProviderBase with the Java class name of the specific
+ * audit log store implementation.
+ */
+ public FileBasedAuditLogStoreProvider()
+ {
+ Class connectorClass = FileBasedAuditLogStoreConnector.class;
+
+ super.setConnectorClassName(connectorClass.getName());
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/enterprise/connectormanager/OMRSConnectionConsumer.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/enterprise/connectormanager/OMRSConnectionConsumer.java b/omrs/src/main/java/org/apache/atlas/omrs/enterprise/connectormanager/OMRSConnectionConsumer.java
new file mode 100644
index 0000000..7ef18bd
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/enterprise/connectormanager/OMRSConnectionConsumer.java
@@ -0,0 +1,62 @@
+/*
+ * 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.enterprise.connectormanager;
+
+import org.apache.atlas.ocf.ffdc.ConnectionCheckedException;
+import org.apache.atlas.ocf.ffdc.ConnectorCheckedException;
+import org.apache.atlas.ocf.properties.Connection;
+
+/**
+ * OMRSConnectionConsumer provides the interfaces for a connection consumer. This is a component that needs to
+ * maintain a current list of connections to all of the repositories in the open metadata repository cohort.
+ */
+public interface OMRSConnectionConsumer
+{
+ /**
+ * Pass details of the connection for one of the remote repositories registered in a connected
+ * open metadata repository cohort.
+ *
+ * @param cohortName - name of the cohort adding the remote connection.
+ * @param metadataCollectionId - Unique identifier for the metadata collection
+ * @param remoteConnection - Connection object providing properties necessary to create an
+ * OMRSRepositoryConnector for the remote repository.
+ * @throws ConnectionCheckedException - there are invalid properties in the Connection
+ * @throws ConnectorCheckedException - there is a problem initializing the Connector
+ */
+ void addRemoteConnection(String cohortName,
+ String metadataCollectionId,
+ Connection remoteConnection) throws ConnectionCheckedException, ConnectorCheckedException;
+
+
+ /**
+ * Pass details of the connection for the repository that has left one of the open metadata repository cohorts.
+ *
+ * @param cohortName - name of the cohort removing the remote connection.
+ * @param metadataCollectionId - Unique identifier for the metadata collection.
+ */
+ void removeRemoteConnection(String cohortName,
+ String metadataCollectionId);
+
+
+ /**
+ * Remove all of the remote connections for the requested open metadata repository cohort.
+ *
+ * @param cohortName - name of the cohort
+ */
+ void removeCohort(String cohortName);
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/enterprise/connectormanager/OMRSConnectorConsumer.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/enterprise/connectormanager/OMRSConnectorConsumer.java b/omrs/src/main/java/org/apache/atlas/omrs/enterprise/connectormanager/OMRSConnectorConsumer.java
new file mode 100644
index 0000000..9ee6246
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/enterprise/connectormanager/OMRSConnectorConsumer.java
@@ -0,0 +1,61 @@
+/*
+ * 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.enterprise.connectormanager;
+
+import org.apache.atlas.omrs.metadatacollection.repositoryconnector.OMRSRepositoryConnector;
+
+/**
+ * OMRSConnectConsumer provides the interfaces for a connector consumer. This is a component that needs to
+ * maintain a current list of connectors to all of the remote repositories in the open metadata repository cohorts that
+ * the local server is a member of.
+ */
+public interface OMRSConnectorConsumer
+{
+ /**
+ * Pass the connector for the local repository to the connector consumer.
+ *
+ * @param metadataCollectionId - Unique identifier for the metadata collection
+ * @param localConnector - OMRSRepositoryConnector object for the local repository.
+ */
+ void setLocalConnector(String metadataCollectionId,
+ OMRSRepositoryConnector localConnector);
+
+
+ /**
+ * Pass the connector to one of the remote repositories in the metadata repository cohort.
+ *
+ * @param metadataCollectionId - Unique identifier for the metadata collection
+ * @param remoteConnector - OMRSRepositoryConnector object providing access to the remote repository.
+ */
+ void addRemoteConnector(String metadataCollectionId,
+ OMRSRepositoryConnector remoteConnector);
+
+
+ /**
+ * Pass the metadata collection id for a repository that has just left the metadata repository cohort.
+ *
+ * @param metadataCollectionId - identifier of the metadata collection that is no longer available.
+ */
+ void removeRemoteConnector(String metadataCollectionId);
+
+
+ /**
+ * Call disconnect on all registered connectors and stop calling them. The OMRS is about to shutdown.
+ */
+ void disconnectAllConnectors();
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/enterprise/connectormanager/OMRSConnectorManager.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/enterprise/connectormanager/OMRSConnectorManager.java b/omrs/src/main/java/org/apache/atlas/omrs/enterprise/connectormanager/OMRSConnectorManager.java
new file mode 100644
index 0000000..0a767d7
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/enterprise/connectormanager/OMRSConnectorManager.java
@@ -0,0 +1,48 @@
+/*
+ * 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.enterprise.connectormanager;
+
+
+/**
+ * OMRSConnectorManager provides the methods for connector consumers to register with the connector manager.
+ */
+public interface OMRSConnectorManager
+{
+ /**
+ * Register the supplied connector consumer with the connector manager. During the registration
+ * request, the connector manager will pass the connector to the local repository and
+ * the connectors to all currently registered remote repositories. Once successfully registered
+ * the connector manager will call the connector consumer each time the repositories in the
+ * metadata repository cluster changes.
+ *
+ * @param connectorConsumer OMRSConnectorConsumer interested in details of the connectors to
+ * all repositories registered in the metadata repository cluster.
+ * @return String identifier for the connectorConsumer - used for the unregister call.
+ */
+ String registerConnectorConsumer(OMRSConnectorConsumer connectorConsumer);
+
+
+ /**
+ * Unregister a connector consumer from the connector manager so it is no longer informed of
+ * changes to the metadata repository cluster.
+ *
+ * @param connectorConsumerId String identifier of the connector consumer returned on the
+ * registerConnectorConsumer.
+ */
+ void unregisterConnectorConsumer(String connectorConsumerId);
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/enterprise/connectormanager/OMRSEnterpriseConnectorManager.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/enterprise/connectormanager/OMRSEnterpriseConnectorManager.java b/omrs/src/main/java/org/apache/atlas/omrs/enterprise/connectormanager/OMRSEnterpriseConnectorManager.java
new file mode 100644
index 0000000..0bd1038
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/enterprise/connectormanager/OMRSEnterpriseConnectorManager.java
@@ -0,0 +1,539 @@
+/*
+ * 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.enterprise.connectormanager;
+
+import org.apache.atlas.ocf.Connector;
+import org.apache.atlas.ocf.ConnectorBroker;
+import org.apache.atlas.ocf.ffdc.ConnectionCheckedException;
+import org.apache.atlas.ocf.ffdc.ConnectorCheckedException;
+import org.apache.atlas.ocf.properties.Connection;
+import org.apache.atlas.omrs.ffdc.OMRSErrorCode;
+import org.apache.atlas.omrs.ffdc.exception.OMRSRuntimeException;
+import org.apache.atlas.omrs.metadatacollection.OMRSMetadataCollection;
+import org.apache.atlas.omrs.metadatacollection.repositoryconnector.OMRSRepositoryConnector;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.UUID;
+
+/**
+ * OMRSEnterpriseConnectorManager provides the connectors for all of the repositories in the connected metadata
+ * repository cohorts to each of the registered connector consumers. It supports:
+ * <ul>
+ * <li>
+ * A single local repository connector.
+ * </li>
+ * <li>
+ * A remote repository connector for each of the other repositories in the open metadata repository cohort.
+ * </li>
+ * </ul>
+ * <p>
+ * Connector instances are then passed to each of the registered connector consumers.
+ * </p>
+ * <p>
+ * The operation of the OMRSEnterpriseConnectorManager can be thought of in terms of its 3 contract interfaces:
+ * </p>
+ * <ul>
+ * <li>
+ * OMRSConnectionConsumer is the interface for passing connections to the OMRSEnterpriseConnectorManager.
+ * New connections are validated by creating a test connector and the combination of the metadata collection Id
+ * and connection are stored. An instance of the connector is passed to each of the registered
+ * connector consumers.
+ * </li>
+ * <li>
+ * OMRSConnectorManager is the interface that enables OMRSConnectorConsumers to register with the federation
+ * manager. When new connector consumers are stored their reference is stored and a uniqueId is
+ * returned to the connector consumer. This id can be used to unregister from the connector manager.
+ * </li>
+ * <li>
+ * OMRSConnectorConsumer is the interface that the federation manager uses to pass connectors
+ * to each registered connector consumer. The connector for the local repository is typically
+ * passed first (if it is available) followed by the remote connectors.
+ * </li>
+ * </ul>
+ * <p>
+ * With these interfaces, the OMRSEnterpriseConnectorManager acts as a go between the OMRSCohortRegistry and
+ * the EnterpriseOMRSRepositoryConnector instances.
+ * </p>
+ * <p>
+ * Note: this class uses synchronized methods to ensure that no registration information is lost when the
+ * server is operating multi-threaded.
+ * </p>
+ */
+public class OMRSEnterpriseConnectorManager implements OMRSConnectionConsumer, OMRSConnectorManager
+{
+ private boolean enterpriseAccessEnabled = false;
+
+ private String localMetadataCollectionId = null;
+ private OMRSRepositoryConnector localRepositoryConnector = null;
+ private ArrayList<RegisteredConnector> registeredRemoteConnectors = new ArrayList<>();
+ private ArrayList<RegisteredConnectorConsumer> registeredConnectorConsumers = new ArrayList<>();
+
+
+ /**
+ * Constructor for the enterprise connector manager.
+ *
+ * @param enterpriseAccessEnabled - boolean indicating whether the connector consumers should be
+ * informed of remote connectors. If enterpriseAccessEnabled = true
+ * the connector consumers will be informed of remote connectors; otherwise
+ * they will not.
+ */
+ public OMRSEnterpriseConnectorManager(boolean enterpriseAccessEnabled)
+ {
+ this.enterpriseAccessEnabled = enterpriseAccessEnabled;
+ }
+
+
+ /**
+ * The disconnect processing involved unregistering all repositories with each of the connector consumers.
+ * Each connector consumer will pass the disconnect() request to each of their repository connector instances.
+ */
+ public void disconnect()
+ {
+ /*
+ * Pass the disconnect request to each registered connector consumer.
+ */
+ for (RegisteredConnectorConsumer registeredConnectorConsumer : registeredConnectorConsumers)
+ {
+ registeredConnectorConsumer.getConnectorConsumer().disconnectAllConnectors();
+ }
+ }
+
+
+ /**
+ * Pass details of the connection for the local repository to the connection consumer.
+ *
+ * @param localMetadataCollectionId - Unique identifier for the metadata collection
+ * @param localRepositoryConnector - connector to the local repository
+ */
+ public void setLocalConnector(String localMetadataCollectionId,
+ OMRSRepositoryConnector localRepositoryConnector)
+ {
+
+ /*
+ * Connector is ok so save along with the metadata collection Id.
+ */
+ this.localRepositoryConnector = localRepositoryConnector;
+ this.localMetadataCollectionId = localMetadataCollectionId;
+
+ /*
+ * Pass the local connector to each registered connector consumer.
+ */
+ for (RegisteredConnectorConsumer registeredConnectorConsumer : registeredConnectorConsumers)
+ {
+ registeredConnectorConsumer.getConnectorConsumer().setLocalConnector(localMetadataCollectionId,
+ localRepositoryConnector);
+ }
+ }
+
+ /**
+ * Pass details of the connection for one of the remote repositories registered in a connected
+ * open metadata repository cohort.
+ *
+ * @param cohortName - name of the cohort adding the remote connection.
+ * @param metadataCollectionId - Unique identifier for the metadata collection
+ * @param remoteConnection - Connection object providing properties necessary to create an
+ * OMRSRepositoryConnector for the remote repository.
+ * @throws ConnectionCheckedException - there are invalid properties in the Connection
+ * @throws ConnectorCheckedException - there is a problem initializing the Connector
+ */
+ public synchronized void addRemoteConnection(String cohortName,
+ String metadataCollectionId,
+ Connection remoteConnection) throws ConnectionCheckedException, ConnectorCheckedException
+ {
+ /*
+ * First test that this connection represents an OMRSRepositoryConnector. If it does not then an exception
+ * is thrown by getOMRSConnector() to tell the caller there is a problem.
+ */
+ OMRSRepositoryConnector remoteConnector = this.getOMRSConnector(remoteConnection);
+ if (remoteConnector != null)
+ {
+ /*
+ * Need to validate that this repository connector has a metadata collection.
+ */
+ OMRSMetadataCollection metadataCollection = remoteConnector.getMetadataCollection();
+
+ /*
+ * Don't need to connector any more.
+ */
+ remoteConnector.disconnect();
+
+ /*
+ * Now test the metadata collection.
+ */
+ if (metadataCollection == null)
+ {
+ final String methodName = "addRemoteConnection()";
+
+ OMRSErrorCode errorCode = OMRSErrorCode.NULL_COHORT_METADATA_COLLECTION;
+ String errorMessage = errorCode.getErrorMessageId()
+ + errorCode.getFormattedErrorMessage(cohortName, metadataCollectionId);
+
+ throw new ConnectorCheckedException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ methodName,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+ }
+
+
+ /*
+ * Connector is ok so save the connection and metadata collection Id.
+ */
+ registeredRemoteConnectors.add(new RegisteredConnector(cohortName, metadataCollectionId, remoteConnection));
+
+ /*
+ * Pass the remote connector to each registered connector consumer if enterprise access is enabled.
+ */
+ if (enterpriseAccessEnabled)
+ {
+ for (RegisteredConnectorConsumer registeredConnectorConsumer : registeredConnectorConsumers)
+ {
+ registeredConnectorConsumer.getConnectorConsumer().addRemoteConnector(metadataCollectionId,
+ this.getOMRSConnector(remoteConnection));
+ }
+ }
+ }
+
+
+ /**
+ * Pass details that identify the connection for the repository that has left one of the open metadata repository cohorts.
+ * Since any repository may be a member of multiple cohorts, we only remove it from the list if it is
+ * the last connector for this repository to be removed.
+ *
+ * @param cohortName - name of the cohort removing the remote connection.
+ * @param metadataCollectionId - Unique identifier for the metadata collection.
+ */
+ public synchronized void removeRemoteConnection(String cohortName,
+ String metadataCollectionId)
+ {
+ /*
+ * Remove the connector from the registered list and work out if the repository is still registered
+ * after it has been removed from the specified cohort.
+ */
+ Iterator<RegisteredConnector> iterator = registeredRemoteConnectors.iterator();
+ int repositoryRegistrationCount = 0;
+
+ while (iterator.hasNext())
+ {
+ RegisteredConnector registeredRemoteConnector = iterator.next();
+
+ if (registeredRemoteConnector.getMetadataCollectionId().equals(metadataCollectionId))
+ {
+ /*
+ * Found a match for this repository - if the cohort matches too, remove it. If the
+ * cohort does not match then increment the count of registrations that still exist.
+ */
+ if (registeredRemoteConnector.getSource().equals(cohortName))
+ {
+ iterator.remove();
+ }
+ else
+ {
+ repositoryRegistrationCount ++;
+ }
+ }
+ }
+
+ /*
+ * Remove the connector from the registered connector consumers if federation is enabled
+ * and the repository is no longer registered through any cohort.
+ */
+ if ((enterpriseAccessEnabled) && (repositoryRegistrationCount == 0))
+ {
+ for (RegisteredConnectorConsumer registeredConnectorConsumer : registeredConnectorConsumers)
+ {
+ registeredConnectorConsumer.getConnectorConsumer().removeRemoteConnector(metadataCollectionId);
+ }
+ }
+ }
+
+
+ /**
+ * Remove all of the remote connections for the requested open metadata repository cohort.
+ * Care must be taken to only remove the remote connectors from the registered connector consumers if the
+ * remote connection is only registered with this cohort.
+ *
+ * @param cohortName - name of the cohort
+ */
+ public synchronized void removeCohort(String cohortName)
+ {
+ /*
+ * Step through the list of registered remote connections, building a list of metadata collection ids for
+ * the cohort
+ */
+ ArrayList<String> metadataCollectionIds = new ArrayList<>();
+
+ for (RegisteredConnector registeredRemoteConnector : registeredRemoteConnectors)
+ {
+ if (registeredRemoteConnector.getSource().equals(cohortName))
+ {
+ metadataCollectionIds.add(registeredRemoteConnector.getMetadataCollectionId());
+ }
+ }
+
+ /*
+ * Use the list of metadata collection Ids to call removeRemoteConnection(). This will manage the
+ * removal of the remote connectors from the connector consumers if it is uniquely registered in this
+ * cohort.
+ */
+ for (String metadataCollectionId : metadataCollectionIds)
+ {
+ this.removeRemoteConnection(cohortName, metadataCollectionId);
+ }
+ }
+
+
+ /**
+ * Register the supplied connector consumer with the connector manager. During the registration
+ * request, the connector manager will pass the connector to the local repository and
+ * the connectors to all currently registered remote repositories. Once successfully registered
+ * the connector manager will call the connector consumer each time the repositories in the
+ * metadata repository cluster changes.
+ *
+ * @param connectorConsumer OMRSConnectorConsumer interested in details of the connectors to
+ * all repositories registered in the metadata repository cluster.
+ * @return String identifier for the connectorConsumer - used for the unregister call.
+ */
+ public synchronized String registerConnectorConsumer(OMRSConnectorConsumer connectorConsumer)
+ {
+ /*
+ * Store the new connector consumer.
+ */
+ RegisteredConnectorConsumer registeredConnectorConsumer = new RegisteredConnectorConsumer(connectorConsumer);
+ String connectorConsumerId = registeredConnectorConsumer.getConnectorConsumerId();
+
+ registeredConnectorConsumers.add(registeredConnectorConsumer);
+
+
+ /*
+ * Pass the registered local connector to the new connector consumer (if available).
+ */
+ if (localRepositoryConnector != null)
+ {
+ connectorConsumer.setLocalConnector(this.localMetadataCollectionId,
+ this.localRepositoryConnector);
+ }
+
+ /*
+ * Pass each of the registered remote connectors (if any) to the new connector consumer
+ * if federation is enabled.
+ */
+ if (enterpriseAccessEnabled)
+ {
+ for (RegisteredConnector registeredConnector : registeredRemoteConnectors)
+ {
+ connectorConsumer.addRemoteConnector(registeredConnector.getMetadataCollectionId(),
+ getOMRSConnector(registeredConnector.getConnection()));
+ }
+ }
+
+ return connectorConsumerId;
+ }
+
+
+ /**
+ * Unregister a connector consumer from the connector manager so it is no longer informed of
+ * changes to the metadata repository cluster.
+ *
+ * @param connectorConsumerId String identifier of the connector consumer returned on the
+ * registerConnectorConsumer.
+ */
+ public synchronized void unregisterConnectorConsumer(String connectorConsumerId)
+ {
+ /*
+ * Remove the connector consumer from the registered list.
+ */
+ Iterator<RegisteredConnectorConsumer> iterator = registeredConnectorConsumers.iterator();
+
+ while(iterator.hasNext())
+ {
+ RegisteredConnectorConsumer registeredConnectorConsumer = iterator.next();
+
+ if (registeredConnectorConsumer.getConnectorConsumerId().equals(connectorConsumerId))
+ {
+ iterator.remove();
+ break;
+ }
+ }
+ }
+
+
+ /**
+ * Private method to convert a Connection into an OMRS connector using the OCF ConnectorBroker.
+ * The OCF ConnectorBroker is needed because the implementation of the OMRS connector is unknown and
+ * may have come from a third party. Thus the official OCF protocol is followed to create the connector.
+ * Any failure to create the connector is returned as an exception.
+ *
+ * @param connection - Connection properties
+ * @return OMRSRepositoryConnector for the connection
+ */
+ private OMRSRepositoryConnector getOMRSConnector(Connection connection)
+ {
+ String methodName = "getOMRSConnector()";
+
+ try
+ {
+ ConnectorBroker connectorBroker = new ConnectorBroker();
+ Connector connector = connectorBroker.getConnector(connection);
+
+ return (OMRSRepositoryConnector)connector;
+ }
+ catch (Throwable error)
+ {
+ /*
+ * If there is a problem initializing the connector then the ConnectorBroker will have created a
+ * detailed exception already. The only error case that this method has introduced is the cast
+ * of the Connector to OMRSRepositoryConnector. This could occur if the connector configured is a valid
+ * OCF Connector but not an OMRSRepositoryConnector.
+ */
+ String connectionName = connection.getConnectionName();
+
+ OMRSErrorCode errorCode = OMRSErrorCode.INVALID_OMRS_CONNECTION;
+ String errorMessage = errorCode.getErrorMessageId()
+ + errorCode.getFormattedErrorMessage(connectionName);
+
+ throw new OMRSRuntimeException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ methodName,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction(),
+ error);
+ }
+ }
+
+
+ /**
+ * RegisteredConnector holds the information about connecting to a repository in the open metadata repository
+ * cluster.
+ */
+ private class RegisteredConnector
+ {
+ private String source = null;
+ private String metadataCollectionId = null;
+ private Connection connection = null;
+
+
+ /**
+ * Constructor to set up registered connector.
+ *
+ * @param source - name of the source of the connector.
+ * @param metadataCollectionId - unique identifier for the metadata collection that this connector accesses.
+ * @param connection - connection used to generate the connector
+ */
+ public RegisteredConnector(String source, String metadataCollectionId, Connection connection)
+ {
+ this.source = source;
+ this.metadataCollectionId = metadataCollectionId;
+ this.connection = connection;
+ }
+
+
+ /**
+ * Return the source name for this connector.
+ *
+ * @return String name
+ */
+ public String getSource()
+ {
+ return source;
+ }
+
+ /**
+ * Return the unique identifier for the metadata collection that this connector accesses.
+ *
+ * @return String identifier
+ */
+ public String getMetadataCollectionId()
+ {
+ return metadataCollectionId;
+ }
+
+
+ /**
+ * Return the connection used to generate the connector to the metadata repository.
+ *
+ * @return Connection properties
+ */
+ public Connection getConnection()
+ {
+ return connection;
+ }
+ }
+
+
+ /**
+ * RegisteredConnectorConsumer relates a connector consumer to an identifier. It is used by
+ * OMRSEnterpriseConnectorManager to manage the list of registered connector consumers.
+ */
+ private class RegisteredConnectorConsumer
+ {
+ private String connectorConsumerId = null;
+ private OMRSConnectorConsumer connectorConsumer = null;
+
+
+ /**
+ * Constructor when the identifier of the connector consumer is known.
+ *
+ * @param connectorConsumerId - unique identifier of the connection consumer
+ * @param connectorConsumer - connector consumer itself
+ */
+ public RegisteredConnectorConsumer(String connectorConsumerId, OMRSConnectorConsumer connectorConsumer)
+ {
+ this.connectorConsumerId = connectorConsumerId;
+ this.connectorConsumer = connectorConsumer;
+ }
+
+
+ /**
+ * Constructor when the identifier for the connector consumer needs to be allocated.
+ *
+ * @param connectorConsumer - connector consumer itself
+ */
+ public RegisteredConnectorConsumer(OMRSConnectorConsumer connectorConsumer)
+ {
+ this.connectorConsumer = connectorConsumer;
+ this.connectorConsumerId = UUID.randomUUID().toString();
+ }
+
+
+ /**
+ * Return the unique identifier of the connector consumer.
+ *
+ * @return String identifier
+ */
+ public String getConnectorConsumerId()
+ {
+ return connectorConsumerId;
+ }
+
+
+ /**
+ * Return the registered connector consumer.
+ *
+ * @return - connector consumer object ref
+ */
+ public OMRSConnectorConsumer getConnectorConsumer()
+ {
+ return connectorConsumer;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/enterprise/repositoryconnector/EnterpriseOMRSConnection.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/enterprise/repositoryconnector/EnterpriseOMRSConnection.java b/omrs/src/main/java/org/apache/atlas/omrs/enterprise/repositoryconnector/EnterpriseOMRSConnection.java
new file mode 100644
index 0000000..9704d93
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/enterprise/repositoryconnector/EnterpriseOMRSConnection.java
@@ -0,0 +1,49 @@
+/*
+ * 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.enterprise.repositoryconnector;
+
+import org.apache.atlas.ocf.properties.Connection;
+import org.apache.atlas.ocf.properties.ConnectorType;
+
+/**
+ * EnterpriseOMRSConnection provides a valid connection for the EnterpriseOMRSConnector.
+ */
+public class EnterpriseOMRSConnection extends Connection
+{
+ final ConnectorType enterpriseConnectorType = new ConnectorType(null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ EnterpriseOMRSConnectorProvider.class.getName());
+
+
+ /**
+ * Default Constructor that sets up the connector
+ */
+ public EnterpriseOMRSConnection()
+ {
+ super(null);
+ super.connectorType = enterpriseConnectorType;
+ }
+}
[06/30] atlas git commit: ATLAS-2246: OMRS Connector API plus REST
and IGC Connector skeleton - 15th February 2018
Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/MatchCriteria.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/MatchCriteria.java b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/MatchCriteria.java
new file mode 100644
index 0000000..b60558e
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/MatchCriteria.java
@@ -0,0 +1,80 @@
+/*
+ * 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.metadatacollection.properties;
+
+
+import java.io.Serializable;
+
+/**
+ * The MatchCriteria enum defines how the metadata instances in the metadata collection should be matched
+ * against the properties supplied on the search request.
+ * <ul>
+ * <li>ALL means all properties must match.</li>
+ * <li>ANY means a match on any of properties is good enough.</li>
+ * <li>NONE means return instances where none of the supplied properties match.</li>
+ * </ul>
+ */
+public enum MatchCriteria implements Serializable
+{
+ ALL (0, "All", "All properties must match."),
+ ANY (1, "Any", "A match on any of properties in the instance is good enough."),
+ NONE (2, "None", "Return instances where none of the supplied properties match.");
+
+ private static final long serialVersionUID = 1L;
+
+ private int ordinal;
+ private String name;
+ private String description;
+
+ /**
+ * Constructor to set up a single instances of the enum.
+ *
+ * @param ordinal - numerical representation of the match criteria
+ * @param name - default string name of the match criteria
+ * @param description - default string description of the match criteria
+ */
+ MatchCriteria(int ordinal, String name, String description)
+ {
+ this.ordinal = ordinal;
+ this.name = name;
+ this.description = description;
+ }
+
+ /**
+ * Return the numeric representation of the match criteria.
+ *
+ * @return int ordinal
+ */
+ public int getOrdinal() { return ordinal; }
+
+
+ /**
+ * Return the default name of the match criteria.
+ *
+ * @return String name
+ */
+ public String getName() { return name; }
+
+
+ /**
+ * Return the default description of the match criteria.
+ *
+ * @return String description
+ */
+ public String getDescription() { return description; }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/SequencingOrder.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/SequencingOrder.java b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/SequencingOrder.java
new file mode 100644
index 0000000..9ed91c7
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/SequencingOrder.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.metadatacollection.properties;
+
+import java.io.Serializable;
+
+/**
+ * SequencingOrder is used for search requests against a metadata collection. It defines how the results should
+ * to be ordered before they are returned. This is particularly important when the results are to returned
+ * over multiple pages since the caller does not have all of the results at once to perform the sort themselves.
+ *
+ * The sequencing order values are:
+ * <ul>
+ * <li>
+ * ANY - return the results in any order. This is default.
+ * </li>
+ * <li>
+ * GUID - return in GUID sequence. This is used when the caller just needs a consistent order in the
+ * order that results are returned.
+ * </li>
+ * <li>
+ * CREATION_DATE_RECENT - return in the order that the elements were created - the most recent ones first.
+ * </li>
+ * <li>
+ * CREATION_DATE_OLDEST - return in the order that the elements were created - the oldest ones first.
+ * </li>
+ * <li>
+ * LAST_UPDATE_RECENT - return in the order of the latest update - the most recent first.
+ * </li>
+ * <li>
+ * LAST_UPDATE_OLDEST - return in the order of the latest update - the oldest first.
+ * </li>
+ * <li>
+ * PROPERTY_ASCENDING - return in ascending order of the values in a sequencing property. The sequencing
+ * property will be supplied as a parameter.
+ * </li>
+ * <li>
+ * PROPERTY_DESCENDING - return in descending order of the values in a sequencing property. The sequencing
+ * property will be supplied as a parameter.
+ * </li>
+ * </ul>
+ */
+public enum SequencingOrder implements Serializable
+{
+ ANY (0, "Any Order", "Any order."),
+ GUID (1, "GUID", "Order by GUID."),
+ CREATION_DATE_RECENT (2, "Creation Date (Recent First)", "Order by creation date, most recently created first."),
+ CREATION_DATE_OLDEST (3, "Creation Date (Oldest First)", "Order by creation date, oldest first."),
+ LAST_UPDATE_RECENT (4, "Last Update Date (Recent First)", "Order by last update date, most recently updated first."),
+ LAST_UPDATE_OLDEST (5, "Last Update Date (Oldest First)", "Order by last update date, most recently updated last."),
+ PROPERTY_ASCENDING (6, "By property value (Ascending)", "Order by property value, lowest value first."),
+ PROPERTY_DESCENDING (7, "By property value (Descending)", "Order by property value, highest first.");
+
+ private static final long serialVersionUID = 1L;
+
+ private int ordinal;
+ private String name;
+ private String description;
+
+ /**
+ * Constructor to set up a single instances of the enum.
+ *
+ * @param ordinal - numerical representation of the sequencing order
+ * @param name - default string name of the sequencing order
+ * @param description - default string description of the sequencing order
+ */
+ SequencingOrder(int ordinal, String name, String description)
+ {
+ this.ordinal = ordinal;
+ this.name = name;
+ this.description = description;
+ }
+
+ /**
+ * Return the numeric representation of the sequencing order.
+ *
+ * @return int ordinal
+ */
+ public int getOrdinal() { return ordinal; }
+
+
+ /**
+ * Return the default name of the sequencing order.
+ *
+ * @return String name
+ */
+ public String getName() { return name; }
+
+
+ /**
+ * Return the default description of the sequencing order.
+ *
+ * @return String description
+ */
+ public String getDescription() { return description; }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/ArrayPropertyValue.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/ArrayPropertyValue.java b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/ArrayPropertyValue.java
new file mode 100644
index 0000000..055293d
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/ArrayPropertyValue.java
@@ -0,0 +1,155 @@
+/*
+ * 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.metadatacollection.properties.instances;
+
+import org.apache.atlas.omrs.ffdc.OMRSErrorCode;
+import org.apache.atlas.omrs.ffdc.exception.OMRSRuntimeException;
+
+/**
+ * ArrayPropertyValue stores the values of an array within an entity, struct or relationship properties.
+ * The elements of the array are stored in an InstanceProperties map where the property name is set to the element
+ * number and the property value is set to the value of the element in the array.
+ */
+public class ArrayPropertyValue extends InstancePropertyValue
+{
+ private int arrayCount = 0;
+ private InstanceProperties arrayValues = null;
+
+
+ /**
+ * Default constructor sets the array to empty.
+ */
+ public ArrayPropertyValue()
+ {
+ super(InstancePropertyCategory.ARRAY);
+ }
+
+
+ /**
+ * Copy/clone constructor set up the array using the supplied template.
+ *
+ * @param template - ArrayPropertyValue
+ */
+ public ArrayPropertyValue(ArrayPropertyValue template)
+ {
+ super(template);
+
+ if (template !=null)
+ {
+ arrayCount = template.getArrayCount();
+ arrayValues = template.getArrayValues();
+ }
+ }
+
+
+ /**
+ * Return the number of elements in the array.
+ *
+ * @return int - array size
+ */
+ public int getArrayCount() { return arrayCount; }
+
+
+ /**
+ * Set up the number of elements in the array.
+ *
+ * @param arrayCount - int - array size
+ */
+ public void setArrayCount(int arrayCount) { this.arrayCount = arrayCount; }
+
+
+ /**
+ * Return a copy of the array elements.
+ *
+ * @return InstanceProperties containing the array elements
+ */
+ public InstanceProperties getArrayValues()
+ {
+ if (arrayValues == null)
+ {
+ return arrayValues;
+ }
+ else
+ {
+ return new InstanceProperties(arrayValues);
+ }
+ }
+
+
+ /**
+ * Add or update an element in the array.
+ *
+ * @param elementNumber - index number of the element in the array
+ * @param propertyValue - value to store
+ */
+ public void setArrayValue(int elementNumber, InstancePropertyValue propertyValue)
+ {
+ if (arrayCount > elementNumber)
+ {
+ if (arrayValues == null)
+ {
+ arrayValues = new InstanceProperties();
+ }
+ arrayValues.setProperty(new Integer(elementNumber).toString(), propertyValue);
+ }
+ else
+ {
+ /*
+ * Throw runtime exception to show the caller they are not using the array correctly.
+ */
+ OMRSErrorCode errorCode = OMRSErrorCode.ARRAY_OUT_OF_BOUNDS;
+ String errorMessage = errorCode.getErrorMessageId()
+ + errorCode.getFormattedErrorMessage(this.getClass().getSimpleName(),
+ new Integer(elementNumber).toString(),
+ new Integer(arrayCount).toString());
+
+ throw new OMRSRuntimeException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ "setArrayValue",
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+ }
+
+
+ /**
+ * Set up the array elements in one call.
+ *
+ * @param arrayValues - InstanceProperties containing the array elements
+ */
+ public void setArrayValues(InstanceProperties arrayValues) { this.arrayValues = arrayValues; }
+
+
+ /**
+ * Standard toString method.
+ *
+ * @return JSON style description of variables.
+ */
+ @Override
+ public String toString()
+ {
+ return "ArrayPropertyValue{" +
+ "arrayCount=" + arrayCount +
+ ", arrayValues=" + arrayValues +
+ ", instancePropertyCategory=" + getInstancePropertyCategory() +
+ ", typeGUID='" + getTypeGUID() + '\'' +
+ ", typeName='" + getTypeName() + '\'' +
+ '}';
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/Classification.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/Classification.java b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/Classification.java
new file mode 100644
index 0000000..98d41f3
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/Classification.java
@@ -0,0 +1,254 @@
+/*
+ * 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.metadatacollection.properties.instances;
+
+import org.apache.atlas.omrs.ffdc.OMRSErrorCode;
+import org.apache.atlas.omrs.ffdc.exception.OMRSRuntimeException;
+
+
+/**
+ * The Classification class stores information about a classification assigned to an entity. The Classification
+ * has a name and some properties. Some classifications are explicitly added to an entity and other
+ * classifications are propagated to an entity along the relationships connected to it. The origin of the
+ * classification is also stored.
+ *
+ * Note: it is not valid to have a classification with a null or blank name.
+ */
+public class Classification extends InstanceAuditHeader
+{
+ private String classificationName = null;
+ private InstanceProperties classificationProperties = null;
+ private ClassificationOrigin classificationOrigin = null;
+ private String classificationOriginGUID = null;
+
+ /*
+ * A private validation method used by the constructors
+ */
+ private String validateName(String name)
+ {
+ /*
+ * Throw an exception if the classification's name is null because that does not make sense.
+ * The constructors do not catch this exception so it is received by the creator of the classification
+ * object.
+ */
+ if (name == null || name.equals(""))
+ {
+ /*
+ * Build and throw exception. This should not happen - likely to be a problem in the
+ * repository connector.
+ */
+ OMRSErrorCode errorCode = OMRSErrorCode.NULL_CLASSIFICATION_NAME;
+ String errorMessage = errorCode.getErrorMessageId()
+ + errorCode.getFormattedErrorMessage();
+
+ throw new OMRSRuntimeException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ "validateName",
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+ else
+ {
+ return name;
+ }
+ }
+
+
+ /**
+ * Typical constructor - verifies and saves parameters.
+ *
+ * @param name - name of the classification
+ * @param properties - additional properties for the classification
+ * @param origin - the origin of the classification
+ * @param originGUID - the guid of the entity of the classification origin was propagated.
+ */
+ public Classification(String name,
+ InstanceProperties properties,
+ ClassificationOrigin origin,
+ String originGUID)
+ {
+ this.classificationName = validateName(name);
+ this.classificationProperties = properties;
+ this.classificationOrigin = origin;
+ this.classificationOriginGUID = originGUID;
+ }
+
+
+ /**
+ * Default constructor for automated generation tools.
+ */
+ public Classification()
+ {
+
+ }
+
+
+ /**
+ * Copy/clone Constructor - sets up new classification using values from the template
+ *
+ * @param templateClassification - object to copy
+ */
+ public Classification(Classification templateClassification)
+ {
+ /*
+ * An empty classification object is passed in the variable declaration so throw exception
+ * because we need the classification name.
+ */
+ if (templateClassification == null)
+ {
+ /*
+ * Build and throw exception. This should not happen - likely to be a problem in the
+ * repository connector.
+ */
+ OMRSErrorCode errorCode = OMRSErrorCode.NULL_CLASSIFICATION_NAME;
+ String errorMessage = errorCode.getErrorMessageId()
+ + errorCode.getFormattedErrorMessage("<Unknown>");
+
+ throw new OMRSRuntimeException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ "Copy Constructor",
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+ else
+ {
+ /*
+ * Extract and save the values from the template.
+ */
+ this.classificationName = validateName(templateClassification.getName());
+ this.classificationProperties = templateClassification.getProperties();
+ this.classificationOrigin = templateClassification.getClassificationOrigin();
+ this.classificationOriginGUID = templateClassification.getClassificationOriginGUID();
+ }
+ }
+
+
+ /**
+ * Return the name of the classification.
+ *
+ * @return name of classification
+ */
+ public String getName()
+ {
+ return classificationName;
+ }
+
+
+ /**
+ * Set up the name of the classification.
+ *
+ * @param classificationName - String name
+ */
+ public void setName(String classificationName)
+ {
+ this.classificationName = validateName(classificationName);
+ }
+
+
+ /**
+ * Returns a collection of the additional stored properties for the classification.
+ * If no stored properties are present then null is returned.
+ *
+ * @return properties for the classification
+ */
+ public InstanceProperties getProperties()
+ {
+ if (classificationProperties == null)
+ {
+ return classificationProperties;
+ }
+ else
+ {
+ return new InstanceProperties(classificationProperties);
+ }
+ }
+
+
+ /**
+ * Set up a collection of the additional stored properties for the classification.
+ *
+ * @param classificationProperties - properties object
+ */
+ public void setProperties(InstanceProperties classificationProperties)
+ {
+ this.classificationProperties = classificationProperties;
+ }
+
+
+ /**
+ * Return the origin of the classification.
+ *
+ * @return ClassificationOrigin enum
+ */
+ public ClassificationOrigin getClassificationOrigin()
+ {
+ return classificationOrigin;
+ }
+
+
+ /**
+ * Set up the origin of the classification.
+ *
+ * @param classificationOrigin - ClassificationOrigin enum
+ */
+ public void setClassificationOrigin(ClassificationOrigin classificationOrigin)
+ {
+ this.classificationOrigin = classificationOrigin;
+ }
+
+
+ /**
+ * Return the guid of the entity where a propagate classification came from.
+ *
+ * @return unique identifier of the classification's origin
+ */
+ public String getClassificationOriginGUID()
+ {
+ return classificationOriginGUID;
+ }
+
+
+ /**
+ * Set up the guid of the entity where a propagate classification came from.
+ *
+ * @param classificationOriginGUID - unique identifier of the classification's origin
+ */
+ public void setClassificationOriginGUID(String classificationOriginGUID)
+ {
+ this.classificationOriginGUID = classificationOriginGUID;
+ }
+
+
+ /**
+ * Standard toString method.
+ *
+ * @return JSON style description of variables.
+ */
+ @Override
+ public String toString()
+ {
+ return "Classification{" +
+ "classificationName='" + classificationName + '\'' +
+ ", classificationProperties=" + classificationProperties +
+ ", classificationOrigin=" + classificationOrigin +
+ ", classificationOriginGUID='" + classificationOriginGUID + '\'' +
+ '}';
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/ClassificationOrigin.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/ClassificationOrigin.java b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/ClassificationOrigin.java
new file mode 100644
index 0000000..d78f261
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/ClassificationOrigin.java
@@ -0,0 +1,81 @@
+/*
+ * 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.metadatacollection.properties.instances;
+
+import java.io.Serializable;
+
+/**
+ * ClassificationOrigin describes the provenance of a classification attached to an entity. Most classifications
+ * are explicitly assigned to an entity. However, it is possible for some classifications to flow along
+ * relationships to other entities. These are the propagated classifications. Each entity can only have one
+ * classification of a certain type. A propagated classification can not override an assigned classification.
+ * Classifications can only be attached to entities of specific types. However a propagated classification can
+ * flow through an entity that does not support the particular type of classification and then on to other
+ * relationships attached to the entity. The ClassificationPropagateRule in the relationship's RelationshipDef
+ * defines where the classification can flow to.
+ */
+public enum ClassificationOrigin implements Serializable
+{
+ ASSIGNED (0, "Assigned", "The classification is explicitly assigned to the entity"),
+ PROPAGATED (1, "Propagated", "The classification has propagated along a relationship to this entity");
+
+ private static final long serialVersionUID = 1L;
+
+ private int ordinal;
+ private String name;
+ private String description;
+
+
+ /**
+ * Default constructor for the classification origin.
+ *
+ * @param ordinal - numerical representation of the classification origin
+ * @param name - default string name of the classification origin
+ * @param description - default string description of the classification origin
+ */
+ ClassificationOrigin(int ordinal, String name, String description)
+ {
+ this.ordinal = ordinal;
+ this.name = name;
+ this.description = description;
+ }
+
+
+ /**
+ * Return the numeric representation of the classification origin.
+ *
+ * @return int ordinal
+ */
+ public int getOrdinal() { return ordinal; }
+
+
+ /**
+ * Return the default name of the classification origin.
+ *
+ * @return String name
+ */
+ public String getName() { return name; }
+
+
+ /**
+ * Return the default description of the classification origin.
+ *
+ * @return String description
+ */
+ public String getDescription() { return description; }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/EntityDetail.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/EntityDetail.java b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/EntityDetail.java
new file mode 100644
index 0000000..95e08d2
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/EntityDetail.java
@@ -0,0 +1,107 @@
+/*
+ * 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.metadatacollection.properties.instances;
+
+/**
+ * EntityDetail stores all of the type-specific properties for the entity. These properties can be
+ * requested in an InstanceProperties object on request.
+ */
+public class EntityDetail extends EntitySummary
+{
+ private InstanceProperties entityProperties = null;
+
+ /**
+ * Default Constructor - no properties established
+ */
+ public EntityDetail()
+ {
+ super();
+ }
+
+
+ /**
+ * Copy/clone constructor - properties copied from template.
+ *
+ * @param templateElement - element to copy.
+ */
+ public EntityDetail(EntityDetail templateElement)
+ {
+ super(templateElement);
+
+ if (templateElement != null)
+ {
+ entityProperties = templateElement.getProperties();
+ }
+ }
+
+
+ /**
+ * Return a copy of all of the properties for this entity. Null means no properties exist.
+ *
+ * @return InstanceProperties
+ */
+ public InstanceProperties getProperties()
+ {
+ if (entityProperties == null)
+ {
+ return entityProperties;
+ }
+ else
+ {
+ return new InstanceProperties(entityProperties);
+ }
+ }
+
+
+ /**
+ * Set up the properties for this entity.
+ *
+ * @param newProperties - InstanceProperties object
+ */
+ public void setProperties(InstanceProperties newProperties)
+ {
+ entityProperties = newProperties;
+ }
+
+
+ /**
+ * Standard toString method.
+ *
+ * @return JSON style description of variables.
+ */
+ @Override
+ public String toString()
+ {
+ return "EntityDetail{" +
+ "entityProperties=" + entityProperties +
+ ", classifications=" + getClassifications() +
+ ", type=" + getType() +
+ ", instanceProvenanceType=" + getInstanceProvenanceType() +
+ ", metadataCollectionId='" + getMetadataCollectionId() + '\'' +
+ ", instanceURL='" + getInstanceURL() + '\'' +
+ ", GUID='" + getGUID() + '\'' +
+ ", status=" + getStatus() +
+ ", createdBy='" + getCreatedBy() + '\'' +
+ ", updatedBy='" + getUpdatedBy() + '\'' +
+ ", createTime=" + getCreateTime() +
+ ", updateTime=" + getUpdateTime() +
+ ", versionName=" + getVersion() +
+ ", statusOnDelete=" + getStatusOnDelete() +
+ '}';
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/EntityProxy.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/EntityProxy.java b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/EntityProxy.java
new file mode 100644
index 0000000..09c0de7
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/EntityProxy.java
@@ -0,0 +1,107 @@
+/*
+ * 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.metadatacollection.properties.instances;
+
+/**
+ * EntityProxy summarizes an entity instance. It is used to describe one of the entities connected together by a
+ * relationship.
+ */
+public class EntityProxy extends EntitySummary
+{
+ private InstanceProperties uniqueAttributes = null;
+
+
+ /**
+ * Default constructor - sets up an empty entity proxy.
+ */
+ public EntityProxy()
+ {
+ super();
+ }
+
+
+ /**
+ * Copy/clone constructor for the entity proxy.
+ *
+ * @param template - entity proxy to copy
+ */
+ public EntityProxy(EntityProxy template)
+ {
+ super(template);
+
+ if (template == null)
+ {
+ this.uniqueAttributes = template.getUniqueAttributes();
+ }
+ }
+
+
+ /**
+ * Return a copy of the unique attributes for the entity.
+ *
+ * @return InstanceProperties iterator
+ */
+ public InstanceProperties getUniqueAttributes()
+ {
+ if (uniqueAttributes == null)
+ {
+ return uniqueAttributes;
+ }
+ else
+ {
+ return new InstanceProperties(uniqueAttributes);
+ }
+ }
+
+
+ /**
+ * Set up the list of unique properties for this entity proxy. These attributes provide properties such
+ * as unique names etc that are useful to display.
+ *
+ * @param uniqueAttributes - InstanceProperties iterator
+ */
+ public void setUniqueAttributes(InstanceProperties uniqueAttributes) { this.uniqueAttributes = uniqueAttributes; }
+
+
+
+ /**
+ * Standard toString method.
+ *
+ * @return JSON style description of variables.
+ */
+ @Override
+ public String toString()
+ {
+ return "EntityProxy{" +
+ "uniqueAttributes=" + uniqueAttributes +
+ ", classifications=" + getClassifications() +
+ ", type=" + getType() +
+ ", instanceProvenanceType=" + getInstanceProvenanceType() +
+ ", metadataCollectionId='" + getMetadataCollectionId() + '\'' +
+ ", instanceURL='" + getInstanceURL() + '\'' +
+ ", GUID='" + getGUID() + '\'' +
+ ", status=" + getStatus() +
+ ", createdBy='" + getCreatedBy() + '\'' +
+ ", updatedBy='" + getUpdatedBy() + '\'' +
+ ", createTime=" + getCreateTime() +
+ ", updateTime=" + getUpdateTime() +
+ ", versionName=" + getVersion() +
+ ", statusOnDelete=" + getStatusOnDelete() +
+ '}';
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/EntitySummary.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/EntitySummary.java b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/EntitySummary.java
new file mode 100644
index 0000000..056ea42
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/EntitySummary.java
@@ -0,0 +1,114 @@
+/*
+ * 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.metadatacollection.properties.instances;
+
+import java.util.ArrayList;
+
+
+/**
+ * EntitySummary is a POJO that provides the basic header attributes for an open metadata entity.
+ * This includes a summary of its type, its unique
+ * identifier (guid) last update data and a list of the classifications for the entity.
+ */
+public class EntitySummary extends InstanceHeader
+{
+ /*
+ * Details of classifications.
+ */
+ private ArrayList<Classification> classifications = null;
+
+
+ /**
+ * Default constructor - creates an empty entity
+ */
+ public EntitySummary()
+ {
+ /*
+ * Nothing to do - everything already initialized
+ */
+ super();
+ }
+
+ /**
+ * Copy/clone constructor.
+ *
+ * @param templateElement - template to copy.
+ */
+ public EntitySummary(EntitySummary templateElement)
+ {
+ super(templateElement);
+
+ if (templateElement != null)
+ {
+ classifications = templateElement.getClassifications();
+ }
+ }
+
+
+ /**
+ * Return a copy of the classifications for the entity. This is a list stored in a newly initialized
+ * iterator.
+ *
+ * @return Classifications iterator
+ */
+ public ArrayList<Classification> getClassifications()
+ {
+ if (classifications == null)
+ {
+ return classifications;
+ }
+ else
+ {
+ return new ArrayList<>(classifications);
+ }
+ }
+
+
+ /**
+ * Set up the classifications for an entity. This is stored as an iterator.
+ *
+ * @param classifications - Classifications list
+ */
+ public void setClassifications(ArrayList<Classification> classifications) { this.classifications = classifications; }
+
+
+ /**
+ * Standard toString method.
+ *
+ * @return JSON style description of variables.
+ */
+ @Override
+ public String toString()
+ {
+ return "EntitySummary{" +
+ "classifications=" + classifications +
+ ", type=" + getType() +
+ ", instanceProvenanceType=" + getInstanceProvenanceType() +
+ ", metadataCollectionId='" + getMetadataCollectionId() + '\'' +
+ ", instanceURL='" + getInstanceURL() + '\'' +
+ ", GUID='" + getGUID() + '\'' +
+ ", status=" + getStatus() +
+ ", createdBy='" + getCreatedBy() + '\'' +
+ ", updatedBy='" + getUpdatedBy() + '\'' +
+ ", createTime=" + getCreateTime() +
+ ", updateTime=" + getUpdateTime() +
+ ", versionName=" + getVersion() +
+ ", statusOnDelete=" + getStatusOnDelete() +
+ '}';
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/EntityUniverse.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/EntityUniverse.java b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/EntityUniverse.java
new file mode 100644
index 0000000..a5af8f9
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/EntityUniverse.java
@@ -0,0 +1,115 @@
+/*
+ * 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.metadatacollection.properties.instances;
+
+import java.util.ArrayList;
+
+/**
+ * EntityUniverse extends EntityDetail to add the relationships that this entity has. These are available
+ * in an iterator to make them easy to process.
+ */
+public class EntityUniverse extends EntityDetail
+{
+ private ArrayList<Relationship> entityRelationships = null;
+
+
+ /**
+ * Default constructor - initializes entity's universe as empty.
+ */
+ public EntityUniverse()
+ {
+ super();
+ }
+
+
+ /**
+ * Copy/clone constructor.
+ *
+ * @param templateElement - template to copy. If null passed, the EntityUniverse is initialized as empty.
+ */
+ public EntityUniverse(EntityUniverse templateElement)
+ {
+ super(templateElement);
+
+ if (templateElement != null)
+ {
+ entityRelationships = templateElement.getEntityRelationships();
+ }
+ }
+
+
+ /**
+ * Copy/clone constructor from an EntityDetail.
+ *
+ * @param templateElement - template to copy. If null passed, the EntityUniverse is initialized as empty.
+ */
+ public EntityUniverse(EntityDetail templateElement)
+ {
+ super(templateElement);
+ }
+
+
+ /**
+ * Return a copy of the relationships for this entity in an iterator.
+ *
+ * @return Relationships list.
+ */
+ public ArrayList<Relationship> getEntityRelationships()
+ {
+ return entityRelationships;
+ }
+
+
+ /**
+ * Set up the list of relationships for this entity.
+ *
+ * @param entityRelationships - Relationships list
+ */
+ public void setEntityRelationships(ArrayList<Relationship> entityRelationships)
+ {
+ this.entityRelationships = entityRelationships;
+ }
+
+
+ /**
+ * Standard toString method.
+ *
+ * @return JSON style description of variables.
+ */
+ @Override
+ public String toString()
+ {
+ return "EntityUniverse{" +
+ "entityRelationships=" + entityRelationships +
+ ", properties=" + getProperties() +
+ ", classifications=" + getClassifications() +
+ ", type=" + getType() +
+ ", instanceProvenanceType=" + getInstanceProvenanceType() +
+ ", metadataCollectionId='" + getMetadataCollectionId() + '\'' +
+ ", instanceURL='" + getInstanceURL() + '\'' +
+ ", GUID='" + getGUID() + '\'' +
+ ", status=" + getStatus() +
+ ", createdBy='" + getCreatedBy() + '\'' +
+ ", updatedBy='" + getUpdatedBy() + '\'' +
+ ", createTime=" + getCreateTime() +
+ ", updateTime=" + getUpdateTime() +
+ ", version=" + getVersion() +
+ ", statusOnDelete=" + getStatusOnDelete() +
+ '}';
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/EnumPropertyValue.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/EnumPropertyValue.java b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/EnumPropertyValue.java
new file mode 100644
index 0000000..7d433d2
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/EnumPropertyValue.java
@@ -0,0 +1,123 @@
+/*
+ * 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.metadatacollection.properties.instances;
+
+/**
+ * An EnumPropertyValue stores the value for an enum property.
+ */
+public class EnumPropertyValue extends InstancePropertyValue
+{
+ private int ordinal = 99;
+ private String symbolicName = null;
+ private String description = null;
+
+
+ /**
+ * Default constructor initializes an empty enum value
+ */
+ public EnumPropertyValue()
+ {
+ super(InstancePropertyCategory.ENUM);
+ }
+
+
+ /**
+ * Copy/clone constructor initializes the enum with the values from the template.
+ *
+ * @param template - EnumPropertyValue to copy
+ */
+ public EnumPropertyValue(EnumPropertyValue template)
+ {
+ super(template);
+
+ if (template != null)
+ {
+ this.ordinal = template.getOrdinal();
+ this.symbolicName = template.getSymbolicName();
+ this.description = template.getDescription();
+ }
+ }
+
+
+ /**
+ * Return the integer ordinal for this enum.
+ *
+ * @return int ordinal
+ */
+ public int getOrdinal() { return ordinal; }
+
+
+ /**
+ * Set the integer ordinal for this enum.
+ *
+ * @param ordinal - int
+ */
+ public void setOrdinal(int ordinal) { this.ordinal = ordinal; }
+
+
+ /**
+ * Return the symbolic name for this enum value.
+ *
+ * @return String symbolic name
+ */
+ public String getSymbolicName() { return symbolicName; }
+
+
+ /**
+ * Set up the symbolic name for this enum value.
+ *
+ * @param symbolicName - String symbolic name
+ */
+ public void setSymbolicName(String symbolicName) { this.symbolicName = symbolicName; }
+
+
+ /**
+ * Return the description for this enum.
+ *
+ * @return String description
+ */
+ public String getDescription() { return description; }
+
+
+ /**
+ * Set up the description for this enum.
+ *
+ * @param description - String description
+ */
+ public void setDescription(String description) { this.description = description; }
+
+
+ /**
+ * Standard toString method.
+ *
+ * @return JSON style description of variables.
+ */
+ @Override
+ public String toString()
+ {
+ return "EnumPropertyValue{" +
+ "ordinal=" + ordinal +
+ ", symbolicName='" + symbolicName + '\'' +
+ ", description='" + description + '\'' +
+ ", instancePropertyCategory=" + getInstancePropertyCategory() +
+ ", typeGUID='" + getTypeGUID() + '\'' +
+ ", typeName='" + getTypeName() + '\'' +
+ '}';
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/InstanceAuditHeader.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/InstanceAuditHeader.java b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/InstanceAuditHeader.java
new file mode 100644
index 0000000..f79aeba
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/InstanceAuditHeader.java
@@ -0,0 +1,266 @@
+/*
+ * 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.metadatacollection.properties.instances;
+
+import java.util.ArrayList;
+import java.util.Date;
+
+/**
+ * InstanceAuditHeader manages the attributes that are common to classifications and "proper" instances, ie
+ * as entities and relationships. We need to be able to audit when these fundamental elements change and
+ * by whom. Thus they share this header.
+ */
+public abstract class InstanceAuditHeader extends InstanceElementHeader
+{
+ /*
+ * Summary information about this element's type
+ */
+ protected InstanceType type = null;
+
+ /*
+ * Standard header information for a classification, entity and relationship.
+ */
+ protected String createdBy = null;
+ protected String updatedBy = null;
+ protected Date createTime = null;
+ protected Date updateTime = null;
+ protected Long version = 0L;
+
+ protected InstanceStatus currentStatus = InstanceStatus.UNKNOWN;
+
+ /*
+ * Used only if the status is DELETED. It defines the status to use if the instance is restored.
+ */
+ protected InstanceStatus statusOnDelete = InstanceStatus.UNKNOWN;
+
+
+ /**
+ * Default Constructor sets the instance to nulls.
+ */
+ public InstanceAuditHeader()
+ {
+ super();
+ }
+
+
+ /**
+ * Copy/clone constructor set the value to those supplied in the template.
+ *
+ * @param template - Instance header
+ */
+ public InstanceAuditHeader(InstanceAuditHeader template)
+ {
+ super(template);
+
+ if (template != null)
+ {
+ this.type = template.getType();
+ this.createdBy = template.getCreatedBy();
+ this.updatedBy = template.getUpdatedBy();
+ this.createTime = template.getCreateTime();
+ this.updateTime = template.getUpdateTime();
+ this.version = template.getVersion();
+ this.currentStatus = template.getStatus();
+ this.statusOnDelete = template.getStatusOnDelete();
+ }
+ }
+
+
+ /**
+ * Return the type of this instance. This identifies the type definition (TypeDef) that determines its properties.
+ *
+ * @return InstanceType object
+ */
+ public InstanceType getType()
+ {
+ if (type == null)
+ {
+ return type;
+ }
+ else
+ {
+ return new InstanceType(type);
+ }
+ }
+
+
+ /**
+ * Set up the type of this instance. This identifies the type definition (TypeDef) that determines its properties.
+ *
+ * @param type - InstanceType object
+ */
+ public void setType(InstanceType type)
+ {
+ this.type = type;
+ }
+
+
+ /**
+ * Return the status of this instance (UNKNOWN, PROPOSED, DRAFT, ACTIVE, DELETED).
+ *
+ * @return InstanceStatus
+ */
+ public InstanceStatus getStatus() { return currentStatus; }
+
+
+ /**
+ * Set up the status of this instance (UNKNOWN, PROPOSED, DRAFT, ACTIVE, DELETED).
+ *
+ * @param newStatus - InstanceStatus
+ */
+ public void setStatus(InstanceStatus newStatus) { this.currentStatus = newStatus; }
+
+
+ /**
+ * Return the name of the user that created this instance.
+ *
+ * @return String user name
+ */
+ public String getCreatedBy() { return createdBy; }
+
+
+ /**
+ * Set up the name of the user that created this instance.
+ *
+ * @param createdBy String user name
+ */
+ public void setCreatedBy(String createdBy) { this.createdBy = createdBy; }
+
+
+ /**
+ * Return the name of the user that last updated this instance.
+ *
+ * @return String user name
+ */
+ public String getUpdatedBy() { return updatedBy; }
+
+
+ /**
+ * Set up the name of the user that last updated this instance.
+ *
+ * @param updatedBy - String user name
+ */
+ public void setUpdatedBy(String updatedBy) { this.updatedBy = updatedBy; }
+
+
+ /**
+ * Return the date/time that this instance was created.
+ *
+ * @return Date creation time
+ */
+ public Date getCreateTime()
+ {
+ if (createTime == null)
+ {
+ return createTime;
+ }
+ else
+ {
+ return new Date(createTime.getTime());
+ }
+ }
+
+
+ /**
+ * Set up the time that this instance was created.
+ *
+ * @param createTime Date of creation
+ */
+ public void setCreateTime(Date createTime) { this.createTime = createTime; }
+
+
+ /**
+ * Return what was the late time this instance was updated.
+ *
+ * @return Date - last update time
+ */
+ public Date getUpdateTime()
+ {
+ if (updateTime == null)
+ {
+ return updateTime;
+ }
+ else
+ {
+ return new Date(updateTime.getTime());
+ }
+ }
+
+
+ /**
+ * Set up the last update time for this instance.
+ *
+ * @param updateTime - Date - last update time
+ */
+ public void setUpdateTime(Date updateTime) { this.updateTime = updateTime; }
+
+
+ /**
+ * Return the version number for this instance.
+ *
+ * @return Long versionName number
+ */
+ public Long getVersion() { return version; }
+
+
+ /**
+ * Set up the versionName number for this instance.
+ *
+ * @param version - Long versionName number
+ */
+ public void setVersion(Long version) { this.version = version; }
+
+
+ /**
+ * Return the status to use when a deleted instance is restored. UNKNOWN is used whenever the instance is
+ * not in DELETED status.
+ *
+ * @return InstanceStatus
+ */
+ public InstanceStatus getStatusOnDelete() { return statusOnDelete; }
+
+
+ /**
+ * Set up the status to use when a deleted instance is restored. UNKNOWN is used whenever the instance is
+ * not in DELETED status.
+ *
+ * @param statusOnDelete - InstanceStatus Enum
+ */
+ public void setStatusOnDelete(InstanceStatus statusOnDelete) { this.statusOnDelete = statusOnDelete; }
+
+
+ /**
+ * Standard toString method.
+ *
+ * @return JSON style description of variables.
+ */
+ @Override
+ public String toString()
+ {
+ return "InstanceHeader{" +
+ "type=" + type +
+ ", status=" + currentStatus +
+ ", createdBy='" + createdBy + '\'' +
+ ", updatedBy='" + updatedBy + '\'' +
+ ", createTime=" + createTime +
+ ", updateTime=" + updateTime +
+ ", versionName=" + version +
+ ", statusOnDelete=" + statusOnDelete +
+ '}';
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/InstanceElementHeader.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/InstanceElementHeader.java b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/InstanceElementHeader.java
new file mode 100644
index 0000000..0ffef54
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/InstanceElementHeader.java
@@ -0,0 +1,53 @@
+/*
+ * 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.metadatacollection.properties.instances;
+
+import java.io.Serializable;
+
+/**
+ * InstanceElementHeader provides a common base for all instance information from the metadata collection.
+ * It implements Serializable.
+ */
+public abstract class InstanceElementHeader implements Serializable
+{
+ private static final long serialVersionUID = 1L;
+
+
+ /**
+ * Default Constructor sets the instance to nulls
+ */
+ public InstanceElementHeader()
+ {
+ /*
+ * Nothing to do.
+ */
+ }
+
+
+ /**
+ * Copy/clone constructor set values from the template
+ *
+ * @param template - InstanceElementHeader to copy
+ */
+ public InstanceElementHeader(InstanceElementHeader template)
+ {
+ /*
+ * Nothing to do.
+ */
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/InstanceGraph.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/InstanceGraph.java b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/InstanceGraph.java
new file mode 100644
index 0000000..11fc7e1
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/InstanceGraph.java
@@ -0,0 +1,259 @@
+/*
+ * 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.metadatacollection.properties.instances;
+
+
+import java.util.ArrayList;
+
+/**
+ * InstanceGraph stores a subgraph of entities and relationships and provides methods to access its content.
+ * It stores a list of entities and a list of relationships. It is possible to request a list for each
+ * of these two lists, or request elements that link to a specific element. For example, request the relationships
+ * that link to an entity or the entity at a specific end of a relationship.
+ */
+public class InstanceGraph extends InstanceElementHeader
+{
+ private ArrayList<EntityDetail> entityElementList = null;
+ private ArrayList<Relationship> relationshipElementList = null;
+
+
+ /**
+ * Default Constructor creates a graph with the supplied list of elements. It assumes the caller has supplied
+ * elements that do link together. However, this graph supports graph fragments.
+ *
+ * @param entityElementList - list of entity elements to add to the list
+ * @param relationshipElementList - list of relationship elements to add to the list
+ */
+ public InstanceGraph(ArrayList<EntityDetail> entityElementList,
+ ArrayList<Relationship> relationshipElementList)
+ {
+ this.entityElementList = entityElementList;
+ this.relationshipElementList = relationshipElementList;
+ }
+
+
+ /**
+ * Copy/clone constructor.
+ *
+ * @param templateGraph - graph to copy; null to create an empty graph
+ */
+ public InstanceGraph(InstanceGraph templateGraph)
+ {
+ if (templateGraph != null)
+ {
+ entityElementList = templateGraph.getEntities();
+ relationshipElementList = templateGraph.getRelationships();
+ }
+ }
+
+
+ /**
+ * Return the list of all of the entities (vertices/nodes) in the instance graph. Null means empty graph.
+ *
+ * @return EntityDetails - entity list
+ */
+ public ArrayList<EntityDetail> getEntities()
+ {
+ if (entityElementList != null)
+ {
+ ArrayList<EntityDetail> entities = new ArrayList<>();
+
+ for (EntityDetail entity : entityElementList)
+ {
+ entities.add(new EntityDetail(entity));
+ }
+ return entities;
+ }
+ else
+ {
+ return entityElementList;
+ }
+ }
+
+
+ /**
+ * Return the list of all relationships (edges/links) in the instance graph. Null means a disconnected/empty graph.
+ *
+ * @return Relationships - relationship list
+ */
+ public ArrayList<Relationship> getRelationships()
+ {
+ if (relationshipElementList != null)
+ {
+ ArrayList<Relationship> relationships = new ArrayList<>();
+
+ for (Relationship relationship : relationshipElementList)
+ {
+ relationships.add(new Relationship(relationship));
+ }
+
+ return relationships;
+ }
+ else
+ {
+ return relationshipElementList;
+ }
+ }
+
+
+ /**
+ * Return a list of relationships that are connected to a specific entity.
+ *
+ * @param anchorEntityGUID - unique identifier for an entity
+ * @return Relationships - relationship iterator
+ */
+ public ArrayList<Relationship> getRelationshipsForEntity(String anchorEntityGUID)
+ {
+ ArrayList<Relationship> matchingRelationships = new ArrayList<>();
+
+ /*
+ * Load copies of each relationship that matches the requested entity into matchingRelationships.
+ */
+ if (relationshipElementList != null)
+ {
+ for (Relationship relationship : relationshipElementList)
+ {
+ if (relationship.relatedToEntity(anchorEntityGUID))
+ {
+ matchingRelationships.add(new Relationship(relationship));
+ }
+ }
+ }
+
+ /*
+ * Return any matched relationships in an iterator for the caller to step through.
+ */
+ if (matchingRelationships.isEmpty())
+ {
+ return null;
+ }
+ else
+ {
+ return matchingRelationships;
+ }
+ }
+
+
+ /**
+ * Return the entity connected at the far end of an entity's relationship.
+ *
+ * @param anchorEntityGUID - unique id for the known entity.
+ * @param linkingRelationshipGUID - the relationship to traverse.
+ * @return EntityDetail - the requested entity at the far end of the relationship.
+ * Null if the relationship or entity is not found.
+ */
+ public EntityDetail getLinkedEntity(String anchorEntityGUID, String linkingRelationshipGUID)
+ {
+ Relationship matchingRelationship = null;
+ String linkedEntityGUID = null;
+ EntityDetail linkedEntity = null;
+
+ /*
+ * Step through the list of relationships looking for the matching one. If parameters are null we will not
+ * match with the list.
+ */
+ if (relationshipElementList != null)
+ {
+ for (Relationship relationship : relationshipElementList)
+ {
+ if (relationship.getGUID().equals(linkingRelationshipGUID))
+ {
+ matchingRelationship = relationship;
+ break;
+ }
+ }
+ }
+
+ /*
+ * Return null if the relationship is not known
+ */
+ if (matchingRelationship == null)
+ {
+ return null;
+ }
+
+ /*
+ * Extract the guid of the linking entity.
+ */
+ linkedEntityGUID = matchingRelationship.getLinkedEntity(anchorEntityGUID);
+
+ /*
+ * Return null if the entity does not match.
+ */
+ if (linkedEntityGUID == null)
+ {
+ return null;
+ }
+
+ /*
+ * Step through the list of entities in the graph looking for the appropriate entity to return.
+ * If no match occurs, null will be returned.
+ */
+ for (EntityDetail entity : entityElementList)
+ {
+ if (entity.getGUID().equals(linkedEntityGUID))
+ {
+ linkedEntity = new EntityDetail(entity);
+ break;
+ }
+ }
+
+ return linkedEntity;
+ }
+
+
+ /**
+ * Return the number of entities in the graph.
+ *
+ * @return elementCount for entities
+ */
+ public int getEntityElementCount()
+ {
+ return entityElementList.size();
+ }
+
+
+ /**
+ * Return the number of relationships in the graph.
+ *
+ * @return elementCount for relationships
+ */
+ public int getRelationshipElementCount()
+ {
+ return relationshipElementList.size();
+ }
+
+
+ /**
+ * Standard toString method.
+ *
+ * @return JSON style description of variables.
+ */
+ @Override
+ public String toString()
+ {
+ return "InstanceGraph{" +
+ "entityElementList=" + entityElementList +
+ ", relationshipElementList=" + relationshipElementList +
+ ", entities=" + getEntities() +
+ ", relationships=" + getRelationships() +
+ ", entityElementCount=" + getEntityElementCount() +
+ ", relationshipElementCount=" + getRelationshipElementCount() +
+ '}';
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/InstanceHeader.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/InstanceHeader.java b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/InstanceHeader.java
new file mode 100644
index 0000000..934974d
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/InstanceHeader.java
@@ -0,0 +1,172 @@
+/*
+ * 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.metadatacollection.properties.instances;
+
+
+/**
+ * InstanceHeader manages the attributes that are common to entities and relationship instances. This includes
+ * information abut its type, provenance and change history.
+ */
+public abstract class InstanceHeader extends InstanceAuditHeader
+{
+ /*
+ * Provenance information defining where the instance came from and whether this is a master or reference copy.
+ */
+ private InstanceProvenanceType instanceProvenanceType = InstanceProvenanceType.UNKNOWN;
+ private String metadataCollectionId = null;
+
+ /*
+ * Entities and relationships have unique identifiers.
+ */
+ private String guid = null;
+
+ /*
+ * Some metadata repositories offer a direct URL to access the instance.
+ */
+ private String instanceURL = null;
+
+ /**
+ * Default Constructor sets the instance to nulls.
+ */
+ public InstanceHeader()
+ {
+ super();
+ }
+
+
+ /**
+ * Copy/clone constructor set the value to those supplied in the template.
+ *
+ * @param template - Instance header
+ */
+ public InstanceHeader(InstanceHeader template)
+ {
+ super(template);
+
+ if (template != null)
+ {
+ this.metadataCollectionId = template.getMetadataCollectionId();
+ this.instanceProvenanceType = template.getInstanceProvenanceType();
+ this.guid = template.getGUID();
+ this.instanceURL = template.getInstanceURL();
+ }
+ }
+
+
+ /**
+ * Return the type of the provenance for this instance (UNKNOWN, LOCAL_COHORT, EXPORT_ARCHIVE, CONTENT_PACK,
+ * DEREGISTERED_REPOSITORY, CONFIGURATION).
+ *
+ * @return InstanceProvenanceType enum
+ */
+ public InstanceProvenanceType getInstanceProvenanceType() { return instanceProvenanceType; }
+
+
+ /**
+ * Set up the type of the provenance for this instance (UNKNOWN, LOCAL_COHORT, EXPORT_ARCHIVE, CONTENT_PACK,
+ * DEREGISTERED_REPOSITORY, CONFIGURATION).
+ *
+ * @param instanceProvenanceType - InstanceProvenanceType enum
+ */
+ public void setInstanceProvenanceType(InstanceProvenanceType instanceProvenanceType)
+ {
+ this.instanceProvenanceType = instanceProvenanceType;
+ }
+
+
+ /**
+ * Return the unique identifier for the metadata collection that is the home for this instance.
+ * If the metadataCollectionId is null it means this instance belongs to the local metadata collection.
+ *
+ * @return metadataCollectionId - String unique identifier for the repository
+ */
+ public String getMetadataCollectionId() { return metadataCollectionId; }
+
+
+ /**
+ * Set up the unique identifier for the home metadata collection for this instance.
+ * If the metadataCollectionId is null it means this instance belongs to the local metadata collection.
+ *
+ * @param metadataCollectionId - String unique identifier for the repository
+ */
+ public void setMetadataCollectionId(String metadataCollectionId) { this.metadataCollectionId = metadataCollectionId; }
+
+
+ /**
+ * Return the URL for this instance (or null if the metadata repository does not support instance URLs).
+ *
+ * @return String URL
+ */
+ public String getInstanceURL()
+ {
+ return instanceURL;
+ }
+
+
+ /**
+ * Set up the URL for this instance (or null if the metadata repository does not support instance URLs).
+ *
+ * @param instanceURL - String URL
+ */
+ public void setInstanceURL(String instanceURL)
+ {
+ this.instanceURL = instanceURL;
+ }
+
+
+ /**
+ * Return the unique identifier for this instance.
+ *
+ * @return guid - String unique identifier
+ */
+ public String getGUID() { return guid; }
+
+
+ /**
+ * Set up the unique identifier for this instance.
+ *
+ * @param guid - String unique identifier
+ */
+ public void setGUID(String guid) { this.guid = guid; }
+
+
+ /**
+ * Standard toString method.
+ *
+ * @return JSON style description of variables.
+ */
+ @Override
+ public String toString()
+ {
+ return "InstanceHeader{" +
+ "type=" + type +
+ ", instanceProvenanceType=" + instanceProvenanceType +
+ ", metadataCollectionId='" + metadataCollectionId + '\'' +
+ ", instanceURL='" + instanceURL + '\'' +
+ ", currentStatus=" + currentStatus +
+ ", guid='" + guid + '\'' +
+ ", createdBy='" + createdBy + '\'' +
+ ", updatedBy='" + updatedBy + '\'' +
+ ", createTime=" + createTime +
+ ", updateTime=" + updateTime +
+ ", versionName=" + version +
+ ", statusOnDelete=" + statusOnDelete +
+ ", GUID='" + getGUID() + '\'' +
+ '}';
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/InstanceProperties.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/InstanceProperties.java b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/InstanceProperties.java
new file mode 100644
index 0000000..bc228d3
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/InstanceProperties.java
@@ -0,0 +1,196 @@
+
+/*
+ * 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.metadatacollection.properties.instances;
+
+import org.apache.atlas.omrs.ffdc.OMRSErrorCode;
+import org.apache.atlas.omrs.ffdc.exception.OMRSRuntimeException;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+
+/**
+ * The InstanceProperties class provides support for arbitrary properties to be added to an entity,
+ * struct or relationship object.
+ * It wraps a java.util.Map map object built around HashMap. The property name (or domain) of the map is the name
+ * of the property. The property value (or range) of the map is a subclass of InstancePropertyValue depending on
+ * the type of the property:
+ * <ul>
+ * <li>
+ * PrimitivePropertyValue - for primitives such as strings and numbers. The full list of primitives are
+ * given in PrimitiveDefCategory.
+ * </li>
+ * <li>
+ * EnumPropertyValue - for properties with a type consisting of an enumeration of valid values. Each
+ * </li>
+ * <li>
+ * StructPropertyValue - for properties that have a type of a complex structure (aka struct).
+ * The Struct can be thought of as a list of related properties.
+ * </li>
+ * <li>
+ * MapPropertyValue - for properties that have a type of map.
+ * The map holds an unordered list of name-value pairs. The pairs are of the same type and the name for
+ * the pair is unique within the map.
+ * </li>
+ * <li>
+ * ArrayPropertyValue - for properties that have a type of Array.
+ * This is an ordered list of values of the same type.
+ * </li>
+ * </ul>
+ */
+public class InstanceProperties extends InstanceElementHeader
+{
+ /*
+ * Map from property name to property value. The value includes type information.
+ */
+ private Map<String, InstancePropertyValue> instanceProperties = new HashMap<>();
+
+
+ /**
+ * Typical constructor
+ */
+ public InstanceProperties()
+ {
+ super();
+ }
+
+
+ /**
+ * Copy/clone Constructor.
+ *
+ * @param templateProperties - template object to copy.
+ */
+ public InstanceProperties(InstanceProperties templateProperties)
+ {
+ super(templateProperties);
+
+ /*
+ * An empty properties object is created in the private variable declaration so nothing to do.
+ */
+ if (templateProperties != null)
+ {
+ /*
+ * Process templateProperties if they are not null
+ */
+ Iterator<String> propertyNames = templateProperties.getPropertyNames();
+
+ if (propertyNames != null)
+ {
+ while (propertyNames.hasNext())
+ {
+ String newPropertyName = propertyNames.next();
+ InstancePropertyValue newPropertyValue = templateProperties.getPropertyValue(newPropertyName);
+
+ instanceProperties.put(newPropertyName, newPropertyValue);
+ }
+ }
+ }
+ }
+
+
+ /**
+ * Returns a list of the instance properties for the element.
+ * If no stored properties are present then null is returned.
+ *
+ * @return list of properties
+ */
+ public Iterator<String> getPropertyNames()
+ {
+ return instanceProperties.keySet().iterator();
+ }
+
+
+ /**
+ * Returns the requested instance property for the element.
+ * If no stored property with that name is present then null is returned.
+ *
+ * @param name - String name of the property to return.
+ * @return requested property value.
+ */
+ public InstancePropertyValue getPropertyValue(String name)
+ {
+ return instanceProperties.get(name);
+ }
+
+
+ /**
+ * Adds or updates an instance property.
+ * If a null is supplied for the property name, an OMRS runtime exception is thrown.
+ * If a null is supplied for the property value, the property is removed.
+ *
+ * @param newPropertyName - name
+ * @param newPropertyValue - value
+ */
+ public void setProperty(String newPropertyName, InstancePropertyValue newPropertyValue)
+ {
+ if (newPropertyName == null)
+ {
+ /*
+ * Build and throw exception.
+ */
+ OMRSErrorCode errorCode = OMRSErrorCode.NULL_PROPERTY_NAME;
+ String errorMessage = errorCode.getErrorMessageId()
+ + errorCode.getFormattedErrorMessage();
+
+ throw new OMRSRuntimeException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ "setProperty",
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+ else if (newPropertyValue == null)
+ {
+ instanceProperties.remove(newPropertyName);
+ }
+ else
+ {
+ instanceProperties.put(newPropertyName, newPropertyValue);
+ }
+ }
+
+
+ /**
+ * Return the number of properties stored.
+ *
+ * @return int property count
+ */
+ public int getPropertyCount()
+ {
+ return instanceProperties.size();
+ }
+
+
+ /**
+ * Standard toString method.
+ *
+ * @return JSON style description of variables.
+ */
+ @Override
+ public String toString()
+ {
+ return "InstanceProperties{" +
+ "instanceProperties=" + instanceProperties +
+ ", propertyNames=" + getPropertyNames() +
+ ", propertyCount=" + getPropertyCount() +
+ '}';
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/InstancePropertyCategory.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/InstancePropertyCategory.java b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/InstancePropertyCategory.java
new file mode 100644
index 0000000..f7393eb
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/InstancePropertyCategory.java
@@ -0,0 +1,91 @@
+/*
+ * 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.metadatacollection.properties.instances;
+
+import java.io.Serializable;
+
+/**
+ * The InstancePropertyCategory defines the list of value types for the properties for open metadata.
+ * It is used in the InstancePropertyValue class to distinguish its subclasses.
+ */
+public enum InstancePropertyCategory implements Serializable
+{
+ UNKNOWN (0, "<Unknown>", "Uninitialized InstancePropertyValue object."),
+ PRIMITIVE (1, "Primitive", "A primitive type."),
+ ENUM (2, "Enum", "A pre-defined list of valid values."),
+ STRUCT (3, "Struct", "A collection of related properties."),
+ MAP (4, "Map", "A set of name->value pairs where all names are unique in the map."),
+ ARRAY (5, "Array", "An ordered list of values, each with the same type.");
+
+ private static final long serialVersionUID = 1L;
+
+ private int typeCode;
+ private String typeName;
+ private String typeDescription;
+
+
+ /**
+ * Default Constructor
+ *
+ * @param typeCode - ordinal for this enum
+ * @param typeName - symbolic name for this enum
+ * @param typeDescription - short description for this enum
+ */
+ InstancePropertyCategory(int typeCode, String typeName, String typeDescription)
+ {
+ /*
+ * Save the values supplied
+ */
+ this.typeCode = typeCode;
+ this.typeName = typeName;
+ this.typeDescription = typeDescription;
+ }
+
+
+ /**
+ * Return the code for this enum instance
+ *
+ * @return int - type code
+ */
+ public int getTypeCode()
+ {
+ return typeCode;
+ }
+
+
+ /**
+ * Return the default name for this enum instance.
+ *
+ * @return String - default name
+ */
+ public String getTypeName()
+ {
+ return typeName;
+ }
+
+
+ /**
+ * Return the default description for the type for this enum instance.
+ *
+ * @return String - default description
+ */
+ public String getTypeDescription()
+ {
+ return typeDescription;
+ }
+}
[24/30] atlas git commit: ATLAS-2246: OMRS Connector API plus REST
and IGC Connector skeleton - 15th February 2018
Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/enterprise/repositoryconnector/EnterpriseOMRSConnectorProperties.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/enterprise/repositoryconnector/EnterpriseOMRSConnectorProperties.java b/omrs/src/main/java/org/apache/atlas/omrs/enterprise/repositoryconnector/EnterpriseOMRSConnectorProperties.java
new file mode 100644
index 0000000..72821ad
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/enterprise/repositoryconnector/EnterpriseOMRSConnectorProperties.java
@@ -0,0 +1,52 @@
+/*
+ * 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.enterprise.repositoryconnector;
+
+import org.apache.atlas.ocf.ffdc.PropertyServerException;
+import org.apache.atlas.ocf.properties.ConnectedAssetProperties;
+import org.apache.atlas.omrs.enterprise.connectormanager.OMRSConnectorManager;
+
+
+/**
+ * EnterpriseOMRSConnectorProperties provides information about the connections and the metadata collections
+ * that the EnterpriseOMRSRepositoryConnector is retrieving information from.
+ */
+public class EnterpriseOMRSConnectorProperties extends ConnectedAssetProperties
+{
+ public EnterpriseOMRSConnectorProperties(EnterpriseOMRSRepositoryConnector parentConnector,
+ OMRSConnectorManager connectorManager,
+ String enterpriseMetadataCollectionId,
+ String enterpriseMetadataCollectionName)
+ {
+ super();
+ // TODO not implemented yet
+ }
+
+
+ /**
+ * Request the values in the ConnectedAssetProperties are refreshed with the current values from the
+ * metadata repository. In the case of the
+ *
+ * @throws PropertyServerException - there is a problem connecting to the server to retrieve metadata.
+ */
+ public void refresh() throws PropertyServerException
+ {
+ // TODO not implemented yet
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/enterprise/repositoryconnector/EnterpriseOMRSConnectorProvider.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/enterprise/repositoryconnector/EnterpriseOMRSConnectorProvider.java b/omrs/src/main/java/org/apache/atlas/omrs/enterprise/repositoryconnector/EnterpriseOMRSConnectorProvider.java
new file mode 100644
index 0000000..ae4c803
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/enterprise/repositoryconnector/EnterpriseOMRSConnectorProvider.java
@@ -0,0 +1,153 @@
+/*
+ * 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.enterprise.repositoryconnector;
+
+import org.apache.atlas.ocf.Connector;
+import org.apache.atlas.ocf.ffdc.ConnectionCheckedException;
+import org.apache.atlas.ocf.ffdc.ConnectorCheckedException;
+import org.apache.atlas.ocf.properties.Connection;
+import org.apache.atlas.omrs.enterprise.connectormanager.OMRSConnectorManager;
+import org.apache.atlas.omrs.ffdc.OMRSErrorCode;
+
+import org.apache.atlas.omrs.metadatacollection.repositoryconnector.OMRSRepositoryConnectorProviderBase;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.UUID;
+
+
+/**
+ * In the Open Connector Framework (OCF), a ConnectorProvider is a factory for a specific type of connector.
+ * The EnterpriseOMRSConnectorProvider is the connector provider for the EnterpriseOMRSRepositoryConnector.
+ *
+ * It will return new instances of the EnterpriseOMRSRepositoryConnector as long as it is configured with the connector
+ * manager. This should happen at server startup, which means the exception due to a lack of connector
+ * manager are unexpected.
+ */
+public class EnterpriseOMRSConnectorProvider extends OMRSRepositoryConnectorProviderBase
+{
+ private final int hashCode = UUID.randomUUID().hashCode();
+
+ private static final Logger log = LoggerFactory.getLogger(EnterpriseOMRSConnectorProvider.class);
+
+ private static OMRSConnectorManager connectorManager = null;
+ private static String enterpriseMetadataCollectionId = null;
+ private static String enterpriseMetadataCollectionName = null;
+
+
+ /**
+ * Set up the connector manager. This call is used to control whether the EnterpriseOMRSConnectorProvider
+ * produces connectors or not. An EnterpriseOMRSRepositoryConnector needs the connector manager to maintain the
+ * list of connectors to the repositories in the cohort.
+ *
+ * @param connectorManager - manager of the list of connectors to remote repositories.
+ * @param enterpriseMetadataCollectionId - unique identifier for the combined metadata collection covered by the
+ * connected open metadata repositories.
+ * @param enterpriseMetadataCollectionName - name of the combined metadata collection covered by the connected open
+ * metadata repositories. Used for messages.
+ */
+ public synchronized static void initialize(OMRSConnectorManager connectorManager,
+ String enterpriseMetadataCollectionId,
+ String enterpriseMetadataCollectionName)
+ {
+ EnterpriseOMRSConnectorProvider.connectorManager = connectorManager;
+ EnterpriseOMRSConnectorProvider.enterpriseMetadataCollectionId = enterpriseMetadataCollectionId;
+ EnterpriseOMRSConnectorProvider.enterpriseMetadataCollectionName = enterpriseMetadataCollectionName;
+ }
+
+
+ /**
+ * Typical constructor used with the connector broker. It sets up the class to use for the repository connector
+ * instance.
+ */
+ public EnterpriseOMRSConnectorProvider()
+ {
+ super();
+
+ Class connectorClass = EnterpriseOMRSRepositoryConnector.class;
+
+ super.setConnectorClassName(connectorClass.getName());
+ }
+
+
+ /**
+ * Creates a new instance of an EnterpriseOMRSRepositoryConnector based on the information in the supplied connection.
+ *
+ * @param connection - connection that should have all of the properties needed by the Connector Provider
+ * to create a connector instance.
+ * @return Connector - instance of the connector.
+ * @throws ConnectionCheckedException - if there are missing or invalid properties in the connection
+ * @throws ConnectorCheckedException - if there are issues instantiating or initializing the connector
+ */
+ public Connector getConnector(Connection connection) throws ConnectionCheckedException, ConnectorCheckedException
+ {
+ String methodName = "getConnector()";
+
+ if (log.isDebugEnabled())
+ {
+ log.debug(methodName + " called");
+ }
+
+ if (EnterpriseOMRSConnectorProvider.connectorManager == null)
+ {
+ /*
+ * If the cohort is not connected then throw an exception to indicate that the repositories are offline.
+ */
+ OMRSErrorCode errorCode = OMRSErrorCode.COHORT_NOT_CONNECTED;
+ String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage();
+
+ throw new ConnectorCheckedException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ methodName,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+
+ /*
+ * Create and initialize a new connector.
+ */
+ EnterpriseOMRSRepositoryConnector connector = new EnterpriseOMRSRepositoryConnector(EnterpriseOMRSConnectorProvider.connectorManager,
+ enterpriseMetadataCollectionName);
+
+ connector.initialize(this.getNewConnectorGUID(), connection);
+ connector.setMetadataCollectionId(enterpriseMetadataCollectionId);
+ connector.initializeConnectedAssetProperties(new EnterpriseOMRSConnectorProperties(connector,
+ EnterpriseOMRSConnectorProvider.connectorManager,
+ enterpriseMetadataCollectionId,
+ enterpriseMetadataCollectionName));
+
+ if (log.isDebugEnabled())
+ {
+ log.debug(methodName + " returns: " + connector.getConnectorInstanceId() + ", " + connection.getConnectionName());
+ }
+
+ return connector;
+ }
+
+
+ /**
+ * Simple hashCode implementation
+ *
+ * @return hashCode
+ */
+ public int hashCode()
+ {
+ return hashCode;
+ }
+}
[07/30] atlas git commit: ATLAS-2246: OMRS Connector API plus REST
and IGC Connector skeleton - 15th February 2018
Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/OMRSMetadataCollectionBase.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/OMRSMetadataCollectionBase.java b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/OMRSMetadataCollectionBase.java
new file mode 100644
index 0000000..778f6b0
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/OMRSMetadataCollectionBase.java
@@ -0,0 +1,2143 @@
+/*
+ * 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.metadatacollection;
+
+import org.apache.atlas.omrs.ffdc.exception.*;
+import org.apache.atlas.omrs.metadatacollection.properties.MatchCriteria;
+import org.apache.atlas.omrs.metadatacollection.properties.SequencingOrder;
+import org.apache.atlas.omrs.metadatacollection.properties.instances.*;
+import org.apache.atlas.omrs.metadatacollection.properties.typedefs.*;
+
+import java.util.ArrayList;
+import java.util.Date;
+
+/**
+ * <p>
+ * OMRSMetadataCollection is the common interface for working with the contents of a metadata repository.
+ * Within a metadata collection are the type definitions (TypeDefs) and metadata instances (Entities and
+ * Relationships). OMRSMetadataCollectionBase provides empty implementation of the the abstract methods of
+ * OMRSMetadataCollection.
+ *
+ * The methods on OMRSMetadataCollection are in the following major groups:
+ * </p>
+ * <ul>
+ * <li><b>Methods to retrieve information about the metadata repository</b> -
+ * Used to retrieve or confirm the identity of the metadata repository
+ * </li>
+ * <li><b>Methods for working with typedefs</b> -
+ * Typedefs are used to define the type model for open metadata.
+ * The open metadata support had a comprehensive set of typedefs implemented, and these can be augmented by
+ * different vendors or applications. The typedefs can be queried, created, updated and deleted though the
+ * metadata collection.
+ * </li>
+ *
+ * <li><b>Methods for querying Entities and Relationships</b> -
+ * The metadata repository stores instances of the typedefs as metadata instances.
+ * Principally these are entities (nodes in the graph) and relationships (links between nodes).
+ * Both the entities and relationships can have properties.
+ * The entity may also have structured properties called structs and classifications attached.
+ * This second group of methods supports a range of queries to retrieve these instances.
+ * </li>
+ *
+ * <li><b>Methods for maintaining the instances</b> -
+ * The fourth group of methods supports the maintenance of the metadata instances. Each instance as a status
+ * (see InstanceStatus) that allows an instance to be proposed, drafted and approved before it becomes
+ * active. The instances can also be soft-deleted and restored or purged from the metadata
+ * collection.
+ * </li>
+ * <li>
+ * <b>Methods for repairing the metadata collections of the cohort</b> -
+ * The fifth group of methods are for editing the control information of entities and relationships to
+ * manage changes in the cohort. These methods are advanced methods and are rarely used.
+ * </li>
+ * <li>
+ * <b>Methods for local maintenance of a metadata collection</b>
+ * The final group of methods are for removing reference copies of the metadata instances. These updates
+ * are not broadcast to the rest of the Cohort as events.
+ * </li>
+ * </ul>
+ */
+public abstract class OMRSMetadataCollectionBase extends OMRSMetadataCollection
+{
+ protected String metadataCollectionId;
+
+ /**
+ * Constructor to save the metadata collection id.
+ *
+ * @param metadataCollectionId - unique identifier for the metadata managed by the repository.
+ */
+ public OMRSMetadataCollectionBase(String metadataCollectionId)
+ {
+ super(metadataCollectionId);
+ }
+
+
+ /* ======================================================================
+ * Group 1: Confirm the identity of the metadata repository being called.
+ */
+
+ /**
+ * Returns the identifier of the metadata repository. This is the identifier used to register the
+ * metadata repository with the metadata repository cohort. It is also the identifier used to
+ * identify the home repository of a metadata instance.
+ *
+ * @return String - metadata collection id.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository.
+ */
+ public String getMetadataCollectionId() throws RepositoryErrorException
+ {
+ return super.metadataCollectionId;
+ }
+
+
+ /* ==============================
+ * Group 2: Working with typedefs
+ */
+
+
+ /**
+ * Returns the list of different types of metadata organized into two groups. The first are the
+ * attribute type definitions (AttributeTypeDefs). These provide types for properties in full
+ * type definitions. Full type definitions (TypeDefs) describe types for entities, relationships
+ * and classifications.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @return TypeDefGallery - List of different categories of type definitions.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public TypeDefGallery getAllTypes(String userId) throws RepositoryErrorException,
+ UserNotAuthorizedException
+ {
+ return null;
+ }
+
+
+ /**
+ * Returns a list of type definitions that have the specified name. Type names should be unique. This
+ * method allows wildcard character to be included in the name. These are * (asterisk) for an
+ * arbitrary string of characters and ampersand for an arbitrary character.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param name - name of the TypeDefs to return (including wildcard characters).
+ * @return TypeDefs list.
+ * @throws InvalidParameterException - the name of the TypeDef is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public TypeDefGallery findTypesByName(String userId,
+ String name) throws InvalidParameterException,
+ RepositoryErrorException,
+ UserNotAuthorizedException
+ {
+ return null;
+ }
+
+
+ /**
+ * Returns all of the TypeDefs for a specific category.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param category - enum value for the category of TypeDef to return.
+ * @return TypeDefs list.
+ * @throws InvalidParameterException - the TypeDefCategory is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public ArrayList<TypeDef> findTypeDefsByCategory(String userId,
+ TypeDefCategory category) throws InvalidParameterException,
+ RepositoryErrorException,
+ UserNotAuthorizedException
+ {
+ return null;
+ }
+
+
+ /**
+ * Returns all of the AttributeTypeDefs for a specific category.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param category - enum value for the category of an AttributeTypeDef to return.
+ * @return TypeDefs list.
+ * @throws InvalidParameterException - the TypeDefCategory is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public ArrayList<AttributeTypeDef> findAttributeTypeDefsByCategory(String userId,
+ AttributeTypeDefCategory category) throws InvalidParameterException,
+ RepositoryErrorException,
+ UserNotAuthorizedException
+ {
+ return null;
+ }
+
+
+ /**
+ * Return the TypeDefs that have the properties matching the supplied match criteria.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param matchCriteria - TypeDefProperties - a list of property names and values.
+ * @return TypeDefs list.
+ * @throws InvalidParameterException - the matchCriteria is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public ArrayList<TypeDef> findTypeDefsByProperty(String userId,
+ TypeDefProperties matchCriteria) throws InvalidParameterException,
+ RepositoryErrorException,
+ UserNotAuthorizedException
+ {
+ return null;
+ }
+
+
+ /**
+ * Return the types that are linked to the elements from the specified standard.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param standard - name of the standard - null means any.
+ * @param organization - name of the organization - null means any.
+ * @param identifier - identifier of the element in the standard - null means any.
+ * @return TypeDefs list - each entry in the list contains a typedef. This is is a structure
+ * describing the TypeDef's category and properties.
+ * @throws InvalidParameterException - all attributes of the external id are null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public TypeDefGallery findTypesByExternalID(String userId,
+ String standard,
+ String organization,
+ String identifier) throws InvalidParameterException,
+ RepositoryErrorException,
+ UserNotAuthorizedException
+ {
+ return null;
+ }
+
+
+ /**
+ * Return the TypeDefs that match the search criteria.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param searchCriteria - String - search criteria.
+ * @return TypeDefs list - each entry in the list contains a typedef. This is is a structure
+ * describing the TypeDef's category and properties.
+ * @throws InvalidParameterException - the searchCriteria is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public ArrayList<TypeDef> searchForTypeDefs(String userId,
+ String searchCriteria) throws InvalidParameterException,
+ RepositoryErrorException,
+ UserNotAuthorizedException
+ {
+ return null;
+ }
+
+
+ /**
+ * Return the TypeDef identified by the GUID.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param guid - String unique id of the TypeDef.
+ * @return TypeDef structure describing its category and properties.
+ * @throws InvalidParameterException - the guid is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws TypeDefNotKnownException - The requested TypeDef is not known in the metadata collection.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public TypeDef getTypeDefByGUID(String userId,
+ String guid) throws InvalidParameterException,
+ RepositoryErrorException,
+ TypeDefNotKnownException,
+ UserNotAuthorizedException
+ {
+ return null;
+ }
+
+
+ /**
+ * Return the AttributeTypeDef identified by the GUID.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param guid - String unique id of the TypeDef
+ * @return TypeDef structure describing its category and properties.
+ * @throws InvalidParameterException - the guid is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws TypeDefNotKnownException - The requested TypeDef is not known in the metadata collection.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public AttributeTypeDef getAttributeTypeDefByGUID(String userId,
+ String guid) throws InvalidParameterException,
+ RepositoryErrorException,
+ TypeDefNotKnownException,
+ UserNotAuthorizedException
+ {
+ return null;
+ }
+
+
+ /**
+ * Return the TypeDef identified by the unique name.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param name - String name of the TypeDef.
+ * @return TypeDef structure describing its category and properties.
+ * @throws InvalidParameterException - the name is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws TypeDefNotKnownException - the requested TypeDef is not found in the metadata collection.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public TypeDef getTypeDefByName(String userId,
+ String name) throws InvalidParameterException,
+ RepositoryErrorException,
+ TypeDefNotKnownException,
+ UserNotAuthorizedException
+ {
+ return null;
+ }
+
+
+ /**
+ * Return the AttributeTypeDef identified by the unique name.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param name - String name of the TypeDef.
+ * @return TypeDef structure describing its category and properties.
+ * @throws InvalidParameterException - the name is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws TypeDefNotKnownException - the requested TypeDef is not found in the metadata collection.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public AttributeTypeDef getAttributeTypeDefByName(String userId,
+ String name) throws InvalidParameterException,
+ RepositoryErrorException,
+ TypeDefNotKnownException,
+ UserNotAuthorizedException
+ {
+ return null;
+ }
+
+
+ /**
+ * Create a collection of related types.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param newTypes - TypeDefGallery structure describing the new AttributeTypeDefs and TypeDefs.
+ * @throws InvalidParameterException - the new TypeDef is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws TypeDefNotSupportedException - the repository is not able to support this TypeDef.
+ * @throws TypeDefKnownException - the TypeDef is already stored in the repository.
+ * @throws TypeDefConflictException - the new TypeDef conflicts with an existing TypeDef.
+ * @throws InvalidTypeDefException - the new TypeDef has invalid contents.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public void addTypeDefGallery(String userId,
+ TypeDefGallery newTypes) throws InvalidParameterException,
+ RepositoryErrorException,
+ TypeDefNotSupportedException,
+ TypeDefKnownException,
+ TypeDefConflictException,
+ InvalidTypeDefException,
+ UserNotAuthorizedException
+ {
+
+ }
+
+
+
+
+ /**
+ * Create a definition of a new TypeDef.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param newTypeDef - TypeDef structure describing the new TypeDef.
+ * @throws InvalidParameterException - the new TypeDef is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws TypeDefNotSupportedException - the repository is not able to support this TypeDef.
+ * @throws TypeDefKnownException - the TypeDef is already stored in the repository.
+ * @throws TypeDefConflictException - the new TypeDef conflicts with an existing TypeDef.
+ * @throws InvalidTypeDefException - the new TypeDef has invalid contents.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public void addTypeDef(String userId,
+ TypeDef newTypeDef) throws InvalidParameterException,
+ RepositoryErrorException,
+ TypeDefNotSupportedException,
+ TypeDefKnownException,
+ TypeDefConflictException,
+ InvalidTypeDefException,
+ UserNotAuthorizedException
+ {
+
+ }
+
+
+ /**
+ * Create a definition of a new AttributeTypeDef.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param newAttributeTypeDef - TypeDef structure describing the new TypeDef.
+ * @throws InvalidParameterException - the new TypeDef is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws TypeDefNotSupportedException - the repository is not able to support this TypeDef.
+ * @throws TypeDefKnownException - the TypeDef is already stored in the repository.
+ * @throws TypeDefConflictException - the new TypeDef conflicts with an existing TypeDef.
+ * @throws InvalidTypeDefException - the new TypeDef has invalid contents.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public void addAttributeTypeDef(String userId,
+ AttributeTypeDef newAttributeTypeDef) throws InvalidParameterException,
+ RepositoryErrorException,
+ TypeDefNotSupportedException,
+ TypeDefKnownException,
+ TypeDefConflictException,
+ InvalidTypeDefException,
+ UserNotAuthorizedException
+ {
+
+ }
+
+
+ /**
+ * Verify that a definition of a TypeDef is either new - or matches the definition already stored.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param typeDef - TypeDef structure describing the TypeDef to test.
+ * @return boolean - true means the TypeDef matches the local definition - false means the TypeDef is not known.
+ * @throws InvalidParameterException - the TypeDef is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws TypeDefNotSupportedException - the repository is not able to support this TypeDef.
+ * @throws TypeDefConflictException - the new TypeDef conflicts with an existing TypeDef.
+ * @throws InvalidTypeDefException - the new TypeDef has invalid contents.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public boolean verifyTypeDef(String userId,
+ TypeDef typeDef) throws InvalidParameterException,
+ RepositoryErrorException,
+ TypeDefNotSupportedException,
+ TypeDefConflictException,
+ InvalidTypeDefException,
+ UserNotAuthorizedException
+ {
+ return true;
+ }
+
+
+ /**
+ * Verify that a definition of an AttributeTypeDef is either new - or matches the definition already stored.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param attributeTypeDef - TypeDef structure describing the TypeDef to test.
+ * @return boolean - true means the TypeDef matches the local definition - false means the TypeDef is not known.
+ * @throws InvalidParameterException - the TypeDef is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws TypeDefNotSupportedException - the repository is not able to support this TypeDef.
+ * @throws TypeDefConflictException - the new TypeDef conflicts with an existing TypeDef.
+ * @throws InvalidTypeDefException - the new TypeDef has invalid contents.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public boolean verifyAttributeTypeDef(String userId,
+ AttributeTypeDef attributeTypeDef) throws InvalidParameterException,
+ RepositoryErrorException,
+ TypeDefNotSupportedException,
+ TypeDefConflictException,
+ InvalidTypeDefException,
+ UserNotAuthorizedException
+ {
+ return true;
+ }
+
+
+ /**
+ * Update one or more properties of the TypeDef. The TypeDefPatch controls what types of updates
+ * are safe to make to the TypeDef.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param typeDefPatch - TypeDef patch describing change to TypeDef.
+ * @return updated TypeDef
+ * @throws InvalidParameterException - the TypeDefPatch is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws TypeDefNotKnownException - the requested TypeDef is not found in the metadata collection.
+ * @throws PatchErrorException - the TypeDef can not be updated because the supplied patch is incompatible
+ * with the stored TypeDef.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public TypeDef updateTypeDef(String userId,
+ TypeDefPatch typeDefPatch) throws InvalidParameterException,
+ RepositoryErrorException,
+ TypeDefNotKnownException,
+ PatchErrorException,
+ UserNotAuthorizedException
+ {
+ return null;
+ }
+
+
+ /**
+ * Delete the TypeDef. This is only possible if the TypeDef has never been used to create instances or any
+ * instances of this TypeDef have been purged from the metadata collection.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param obsoleteTypeDefGUID - String unique identifier for the TypeDef.
+ * @param obsoleteTypeDefName - String unique name for the TypeDef.
+ * @throws InvalidParameterException - the one of TypeDef identifiers is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws TypeDefNotKnownException - the requested TypeDef is not found in the metadata collection.
+ * @throws TypeDefInUseException - the TypeDef can not be deleted because there are instances of this type in the
+ * the metadata collection. These instances need to be purged before the
+ * TypeDef can be deleted.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public void deleteTypeDef(String userId,
+ String obsoleteTypeDefGUID,
+ String obsoleteTypeDefName) throws InvalidParameterException,
+ RepositoryErrorException,
+ TypeDefNotKnownException,
+ TypeDefInUseException,
+ UserNotAuthorizedException
+ {
+ }
+
+
+ /**
+ * Delete an AttributeTypeDef. This is only possible if the AttributeTypeDef has never been used to create
+ * instances or any instances of this AttributeTypeDef have been purged from the metadata collection.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param obsoleteTypeDefGUID - String unique identifier for the AttributeTypeDef.
+ * @param obsoleteTypeDefName - String unique name for the AttributeTypeDef.
+ * @throws InvalidParameterException - the one of AttributeTypeDef identifiers is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws TypeDefNotKnownException - the requested AttributeTypeDef is not found in the metadata collection.
+ * @throws TypeDefInUseException - the AttributeTypeDef can not be deleted because there are instances of this type in the
+ * the metadata collection. These instances need to be purged before the
+ * AttributeTypeDef can be deleted.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public void deleteAttributeTypeDef(String userId,
+ String obsoleteTypeDefGUID,
+ String obsoleteTypeDefName) throws InvalidParameterException,
+ RepositoryErrorException,
+ TypeDefNotKnownException,
+ TypeDefInUseException,
+ UserNotAuthorizedException
+ {
+ }
+
+
+ /**
+ * Change the guid or name of an existing TypeDef to a new value. This is used if two different
+ * TypeDefs are discovered to have the same guid. This is extremely unlikely but not impossible so
+ * the open metadata protocol has provision for this.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param originalTypeDefGUID - the original guid of the TypeDef.
+ * @param originalTypeDefName - the original name of the TypeDef.
+ * @param newTypeDefGUID - the new identifier for the TypeDef.
+ * @param newTypeDefName - new name for this TypeDef.
+ * @return typeDef - new values for this TypeDef, including the new guid/name.
+ * @throws InvalidParameterException - one of the parameters is invalid or null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws TypeDefNotKnownException - the TypeDef identified by the original guid/name is not found
+ * in the metadata collection.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public TypeDef reIdentifyTypeDef(String userId,
+ String originalTypeDefGUID,
+ String originalTypeDefName,
+ String newTypeDefGUID,
+ String newTypeDefName) throws InvalidParameterException,
+ RepositoryErrorException,
+ TypeDefNotKnownException,
+ UserNotAuthorizedException
+ {
+ return null;
+ }
+
+
+ /**
+ * Change the guid or name of an existing TypeDef to a new value. This is used if two different
+ * TypeDefs are discovered to have the same guid. This is extremely unlikely but not impossible so
+ * the open metadata protocol has provision for this.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param originalAttributeTypeDefGUID - the original guid of the AttributeTypeDef.
+ * @param originalAttributeTypeDefName - the original name of the AttributeTypeDef.
+ * @param newAttributeTypeDefGUID - the new identifier for the AttributeTypeDef.
+ * @param newAttributeTypeDefName - new name for this AttributeTypeDef.
+ * @return attributeTypeDef - new values for this AttributeTypeDef, including the new guid/name.
+ * @throws InvalidParameterException - one of the parameters is invalid or null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws TypeDefNotKnownException - the AttributeTypeDef identified by the original guid/name is not
+ * found in the metadata collection.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public AttributeTypeDef reIdentifyAttributeTypeDef(String userId,
+ String originalAttributeTypeDefGUID,
+ String originalAttributeTypeDefName,
+ String newAttributeTypeDefGUID,
+ String newAttributeTypeDefName) throws InvalidParameterException,
+ RepositoryErrorException,
+ TypeDefNotKnownException,
+ UserNotAuthorizedException
+ {
+ return null;
+ }
+
+
+ /* ===================================================
+ * Group 3: Locating entity and relationship instances
+ */
+
+
+ /**
+ * Returns a boolean indicating if the entity is stored in the metadata collection.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param guid - String unique identifier for the entity.
+ * @return entity details if the entity is found in the metadata collection; otherwise return null.
+ * @throws InvalidParameterException - the guid is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public EntityDetail isEntityKnown(String userId,
+ String guid) throws InvalidParameterException,
+ RepositoryErrorException,
+ UserNotAuthorizedException
+ {
+ return null;
+ }
+
+
+ /**
+ * Return the header and classifications for a specific entity.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param guid - String unique identifier for the entity.
+ * @return EntitySummary structure
+ * @throws InvalidParameterException - the guid is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws EntityNotKnownException - the requested entity instance is not known in the metadata collection.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public EntitySummary getEntitySummary(String userId,
+ String guid) throws InvalidParameterException,
+ RepositoryErrorException,
+ EntityNotKnownException,
+ UserNotAuthorizedException
+ {
+ return null;
+ }
+
+
+ /**
+ * Return the header, classifications and properties of a specific entity.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param guid - String unique identifier for the entity.
+ * @return EntityDetail structure.
+ * @throws InvalidParameterException - the guid is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws EntityNotKnownException - the requested entity instance is not known in the metadata collection.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public EntityDetail getEntityDetail(String userId,
+ String guid) throws InvalidParameterException,
+ RepositoryErrorException,
+ EntityNotKnownException,
+ UserNotAuthorizedException
+ {
+ return null;
+ }
+
+
+ /**
+ * Return a historical versionName of an entity - includes the header, classifications and properties of the entity.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param guid - String unique identifier for the entity.
+ * @param asOfTime - the time used to determine which versionName of the entity that is desired.
+ * @return EntityDetail structure.
+ * @throws InvalidParameterException - the guid or date is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws EntityNotKnownException - the requested entity instance is not known in the metadata collection
+ * at the time requested.
+ * @throws PropertyErrorException - the asOfTime property is for a future time
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public EntityDetail getEntityDetail(String userId,
+ String guid,
+ Date asOfTime) throws InvalidParameterException,
+ RepositoryErrorException,
+ EntityNotKnownException,
+ PropertyErrorException,
+ UserNotAuthorizedException
+ {
+ return null;
+ }
+
+
+ /**
+ * Return the header, classifications, properties and relationships for a specific entity.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param guid - String unique identifier for the entity.
+ * @return EntityUniverse structure.
+ * @throws InvalidParameterException - the guid is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws EntityNotKnownException - the requested entity instance is not known in the metadata collection.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public EntityUniverse getEntityUniverse(String userId,
+ String guid) throws InvalidParameterException,
+ RepositoryErrorException,
+ EntityNotKnownException,
+ UserNotAuthorizedException
+ {
+ return null;
+ }
+
+
+ /**
+ * Return the relationships for a specific entity.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param entityGUID - String unique identifier for the entity.
+ * @param fromRelationshipElement - the starting element number of the relationships to return.
+ * This is used when retrieving elements
+ * beyond the first page of results. Zero means start from the first element.
+ * @param limitResultsByStatus - By default, relationships in all statuses are returned. However, it is possible
+ * to specify a list of statuses (eg ACTIVE) to restrict the results to. Null means all
+ * status values.
+ * @param asOfTime - Requests a historical query of the relationships for the entity. Null means return the
+ * present values.
+ * @param sequencingProperty - String name of the property that is to be used to sequence the results.
+ * Null means do not sequence on a property name (see SequencingOrder).
+ * @param sequencingOrder - Enum defining how the results should be ordered.
+ * @param pageSize -- the maximum number of result classifications that can be returned on this request. Zero means
+ * unrestricted return results size.
+ * @return Relationships list. Null means no relationships associated with the entity.
+ * @throws InvalidParameterException - a parameter is invalid or null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws EntityNotKnownException - the requested entity instance is not known in the metadata collection.
+ * @throws PropertyErrorException - the sequencing property is not valid for the attached classifications.
+ * @throws PagingErrorException - the paging/sequencing parameters are set up incorrectly.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public ArrayList<Relationship> getRelationshipsForEntity(String userId,
+ String entityGUID,
+ int fromRelationshipElement,
+ ArrayList<InstanceStatus> limitResultsByStatus,
+ Date asOfTime,
+ String sequencingProperty,
+ SequencingOrder sequencingOrder,
+ int pageSize) throws InvalidParameterException,
+ RepositoryErrorException,
+ EntityNotKnownException,
+ PropertyErrorException,
+ PagingErrorException,
+ UserNotAuthorizedException
+ {
+ return null;
+ }
+
+
+ /**
+ * Return a list of entities that match the supplied properties according to the match criteria. The results
+ * can be returned over many pages.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param entityTypeGUID - String unique identifier for the entity type of interest (null means any entity type).
+ * @param matchProperties - List of entity properties to match to (null means match on entityTypeGUID only).
+ * @param matchCriteria - Enum defining how the properties should be matched to the entities in the repository.
+ * @param fromEntityDetailElement - the starting element number of the entities to return.
+ * This is used when retrieving elements
+ * beyond the first page of results. Zero means start from the first element.
+ * @param limitResultsByStatus - By default, entities in all statuses are returned. However, it is possible
+ * to specify a list of statuses (eg ACTIVE) to restrict the results to. Null means all
+ * status values.
+ * @param limitResultsByClassification - List of classifications that must be present on all returned entities.
+ * @param asOfTime - Requests a historical query of the entity. Null means return the present values.
+ * @param sequencingProperty - String name of the entity property that is to be used to sequence the results.
+ * Null means do not sequence on a property name (see SequencingOrder).
+ * @param sequencingOrder - Enum defining how the results should be ordered.
+ * @param pageSize - the maximum number of result entities that can be returned on this request. Zero means
+ * unrestricted return results size.
+ * @return a list of entities matching the supplied criteria - null means no matching entities in the metadata
+ * collection.
+ *
+ * @throws InvalidParameterException - a parameter is invalid or null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws TypeErrorException - the type guid passed on the request is not known by the
+ * metadata collection.
+ * @throws PropertyErrorException - the properties specified are not valid for any of the requested types of
+ * entity.
+ * @throws PagingErrorException - the paging/sequencing parameters are set up incorrectly.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public ArrayList<EntityDetail> findEntitiesByProperty(String userId,
+ String entityTypeGUID,
+ InstanceProperties matchProperties,
+ MatchCriteria matchCriteria,
+ int fromEntityDetailElement,
+ ArrayList<InstanceStatus> limitResultsByStatus,
+ ArrayList<String> limitResultsByClassification,
+ Date asOfTime,
+ String sequencingProperty,
+ SequencingOrder sequencingOrder,
+ int pageSize) throws InvalidParameterException,
+ RepositoryErrorException,
+ TypeErrorException,
+ PropertyErrorException,
+ PagingErrorException,
+ UserNotAuthorizedException
+ {
+ return null;
+ }
+
+
+ /**
+ * Return a list of entities that have the requested type of classification attached.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param entityTypeGUID - unique identifier for the type of entity requested. Null mans any type of entity.
+ * @param classificationName - name of the classification - a null is not valid.
+ * @param matchClassificationProperties - list of classification properties used to narrow the search.
+ * @param matchCriteria - Enum defining how the properties should be matched to the classifications in the repository.
+ * @param fromEntityDetailElement - the starting element number of the entities to return.
+ * This is used when retrieving elements
+ * beyond the first page of results. Zero means start from the first element.
+ * @param limitResultsByStatus - By default, entities in all statuses are returned. However, it is possible
+ * to specify a list of statuses (eg ACTIVE) to restrict the results to. Null means all
+ * status values.
+ * @param asOfTime - Requests a historical query of the entity. Null means return the present values.
+ * @param sequencingProperty - String name of the entity property that is to be used to sequence the results.
+ * Null means do not sequence on a property name (see SequencingOrder).
+ * @param sequencingOrder - Enum defining how the results should be ordered.
+ * @param pageSize - the maximum number of result entities that can be returned on this request. Zero means
+ * unrestricted return results size.
+ * @return a list of entities matching the supplied criteria - null means no matching entities in the metadata
+ * collection.
+ * @throws InvalidParameterException - a parameter is invalid or null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws TypeErrorException - the type guid passed on the request is not known by the
+ * metadata collection.
+ * @throws ClassificationErrorException - the classification request is not known to the metadata collection.
+ * @throws PropertyErrorException - the properties specified are not valid for the requested type of
+ * classification.
+ * @throws PagingErrorException - the paging/sequencing parameters are set up incorrectly.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public ArrayList<EntityDetail> findEntitiesByClassification(String userId,
+ String entityTypeGUID,
+ String classificationName,
+ InstanceProperties matchClassificationProperties,
+ MatchCriteria matchCriteria,
+ ArrayList<InstanceStatus> limitResultsByStatus,
+ Date asOfTime,
+ String sequencingProperty,
+ SequencingOrder sequencingOrder,
+ int fromEntityDetailElement,
+ int pageSize) throws InvalidParameterException,
+ RepositoryErrorException,
+ TypeErrorException,
+ ClassificationErrorException,
+ PropertyErrorException,
+ PagingErrorException,
+ UserNotAuthorizedException
+ {
+ return null;
+ }
+
+
+ /**
+ * Return a list of entities matching the search criteria.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param searchCriteria - String expression of the characteristics of the required relationships.
+ * @param fromEntityDetailElement - the starting element number of the entities to return.
+ * This is used when retrieving elements
+ * beyond the first page of results. Zero means start from the first element.
+ * @param limitResultsByStatus - By default, entities in all statuses are returned. However, it is possible
+ * to specify a list of statuses (eg ACTIVE) to restrict the results to. Null means all
+ * status values.
+ * @param limitResultsByClassification - List of classifications that must be present on all returned entities.
+ * @param asOfTime - Requests a historical query of the entity. Null means return the present values.
+ * @param sequencingProperty - String name of the property that is to be used to sequence the results.
+ * Null means do not sequence on a property name (see SequencingOrder).
+ * @param sequencingOrder - Enum defining how the results should be ordered.
+ * @param pageSize - the maximum number of result entities that can be returned on this request. Zero means
+ * unrestricted return results size.
+ * @return a list of entities matching the supplied criteria - null means no matching entities in the metadata
+ * collection.
+ * @throws InvalidParameterException - a parameter is invalid or null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws PropertyErrorException - the sequencing property specified is not valid for any of the requested types of
+ * entity.
+ * @throws PagingErrorException - the paging/sequencing parameters are set up incorrectly.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public ArrayList<EntityDetail> searchForEntities(String userId,
+ String searchCriteria,
+ int fromEntityDetailElement,
+ ArrayList<InstanceStatus> limitResultsByStatus,
+ ArrayList<String> limitResultsByClassification,
+ Date asOfTime,
+ String sequencingProperty,
+ SequencingOrder sequencingOrder,
+ int pageSize) throws InvalidParameterException,
+ RepositoryErrorException,
+ PropertyErrorException,
+ PagingErrorException,
+ UserNotAuthorizedException
+ {
+ return null;
+ }
+
+
+ /**
+ * Returns a boolean indicating if the relationship is stored in the metadata collection.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param guid - String unique identifier for the relationship.
+ * @return relationship details if the relationship is found in the metadata collection; otherwise return null.
+ * @throws InvalidParameterException - the guid is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public Relationship isRelationshipKnown(String userId,
+ String guid) throws InvalidParameterException,
+ RepositoryErrorException,
+ UserNotAuthorizedException
+ {
+ return null;
+ }
+
+
+ /**
+ * Return a requested relationship.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param guid - String unique identifier for the relationship.
+ * @return a relationship structure.
+ * @throws InvalidParameterException - the guid is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws RelationshipNotKnownException - the metadata collection does not have a relationship with
+ * the requested GUID stored.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public Relationship getRelationship(String userId,
+ String guid) throws InvalidParameterException,
+ RepositoryErrorException,
+ RelationshipNotKnownException,
+ UserNotAuthorizedException
+ {
+ return null;
+ }
+
+
+ /**
+ * Return a historical versionName of a relationship.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param guid - String unique identifier for the relationship.
+ * @param asOfTime - the time used to determine which versionName of the entity that is desired.
+ * @return EntityDetail structure.
+ * @throws InvalidParameterException - the guid or date is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws RelationshipNotKnownException - the requested entity instance is not known in the metadata collection
+ * at the time requested.
+ * @throws PropertyErrorException - the asOfTime property is for a future time
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public Relationship getRelationship(String userId,
+ String guid,
+ Date asOfTime) throws InvalidParameterException,
+ RepositoryErrorException,
+ RelationshipNotKnownException,
+ PropertyErrorException,
+ UserNotAuthorizedException
+ {
+ return null;
+ }
+
+
+ /**
+ * Return a list of relationships that match the requested properties by the matching criteria. The results
+ * can be broken into pages.
+ *
+ * @param userId - unique identifier for requesting user
+ * @param relationshipTypeGUID - unique identifier (guid) for the new relationship's type.
+ * @param matchProperties - list of properties used to narrow the search.
+ * @param matchCriteria - Enum defining how the properties should be matched to the relationships in the repository.
+ * @param fromEntityDetailElement - the starting element number of the entities to return.
+ * This is used when retrieving elements
+ * beyond the first page of results. Zero means start from the first element.
+ * @param limitResultsByStatus - By default, relationships in all statuses are returned. However, it is possible
+ * to specify a list of statuses (eg ACTIVE) to restrict the results to. Null means all
+ * status values.
+ * @param asOfTime - Requests a historical query of the relationships for the entity. Null means return the
+ * present values.
+ * @param sequencingProperty - String name of the property that is to be used to sequence the results.
+ * Null means do not sequence on a property name (see SequencingOrder).
+ * @param sequencingOrder - Enum defining how the results should be ordered.
+ * @param pageSize - the maximum number of result relationships that can be returned on this request. Zero means
+ * unrestricted return results size.
+ * @return a list of relationships. Null means no matching relationships.
+ * @throws InvalidParameterException - one of the parameters is invalid or null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws TypeErrorException - the type guid passed on the request is not known by the
+ * metadata collection.
+ * @throws PropertyErrorException - the properties specified are not valid for any of the requested types of
+ * relationships.
+ * @throws PagingErrorException - the paging/sequencing parameters are set up incorrectly.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public ArrayList<Relationship> findRelationshipsByProperty(String userId,
+ String relationshipTypeGUID,
+ InstanceProperties matchProperties,
+ MatchCriteria matchCriteria,
+ int fromEntityDetailElement,
+ ArrayList<InstanceStatus> limitResultsByStatus,
+ Date asOfTime,
+ String sequencingProperty,
+ SequencingOrder sequencingOrder,
+ int pageSize) throws InvalidParameterException,
+ RepositoryErrorException,
+ TypeErrorException,
+ PropertyErrorException,
+ PagingErrorException,
+ UserNotAuthorizedException
+ {
+ return null;
+ }
+
+
+ /**
+ * Return a list of relationships that match the search criteria. The results can be paged.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param searchCriteria - String expression of the characteristics of the required relationships.
+ * @param fromRelationshipElement - Element number of the results to skip to when building the results list
+ * to return. Zero means begin at the start of the results. This is used
+ * to retrieve the results over a number of pages.
+ * @param limitResultsByStatus - By default, relationships in all statuses are returned. However, it is possible
+ * to specify a list of statuses (eg ACTIVE) to restrict the results to. Null means all
+ * status values.
+ * @param asOfTime - Requests a historical query of the relationships for the entity. Null means return the
+ * present values.
+ * @param sequencingProperty - String name of the property that is to be used to sequence the results.
+ * Null means do not sequence on a property name (see SequencingOrder).
+ * @param sequencingOrder - Enum defining how the results should be ordered.
+ * @param pageSize - the maximum number of result relationships that can be returned on this request. Zero means
+ * unrestricted return results size.
+ * @return a list of relationships. Null means no matching relationships.
+ * @throws InvalidParameterException - one of the parameters is invalid or null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws PropertyErrorException - there is a problem with one of the other parameters.
+ * @throws PagingErrorException - the paging/sequencing parameters are set up incorrectly.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public ArrayList<Relationship> searchForRelationships(String userId,
+ String searchCriteria,
+ int fromRelationshipElement,
+ ArrayList<InstanceStatus> limitResultsByStatus,
+ Date asOfTime,
+ String sequencingProperty,
+ SequencingOrder sequencingOrder,
+ int pageSize) throws InvalidParameterException,
+ RepositoryErrorException,
+ PropertyErrorException,
+ PagingErrorException,
+ UserNotAuthorizedException
+ {
+ return null;
+ }
+
+
+ /**
+ * Return all of the relationships and intermediate entities that connect the startEntity with the endEntity.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param startEntityGUID - The entity that is used to anchor the query.
+ * @param endEntityGUID - the other entity that defines the scope of the query.
+ * @param limitResultsByStatus - By default, relationships in all statuses are returned. However, it is possible
+ * to specify a list of statuses (eg ACTIVE) to restrict the results to. Null means all
+ * status values.
+ * @param asOfTime - Requests a historical query of the relationships for the entity. Null means return the
+ * present values.
+ * @return InstanceGraph - the sub-graph that represents the returned linked entities and their relationships.
+ * @throws InvalidParameterException - one of the parameters is invalid or null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws EntityNotKnownException - the entity identified by either the startEntityGUID or the endEntityGUID
+ * is not found in the metadata collection.
+ * @throws PropertyErrorException - there is a problem with one of the other parameters.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public InstanceGraph getLinkingEntities(String userId,
+ String startEntityGUID,
+ String endEntityGUID,
+ ArrayList<InstanceStatus> limitResultsByStatus,
+ Date asOfTime) throws InvalidParameterException,
+ RepositoryErrorException,
+ EntityNotKnownException,
+ PropertyErrorException,
+ UserNotAuthorizedException
+ {
+ return null;
+ }
+
+
+ /**
+ * Return the entities and relationships that radiate out from the supplied entity GUID.
+ * The results are scoped both the instance type guids and the level.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param entityGUID - the starting point of the query.
+ * @param entityTypeGUIDs - list of entity types to include in the query results. Null means include
+ * all entities found, irrespective of their type.
+ * @param relationshipTypeGUIDs - list of relationship types to include in the query results. Null means include
+ * all relationships found, irrespective of their type.
+ * @param limitResultsByStatus - By default, relationships in all statuses are returned. However, it is possible
+ * to specify a list of statuses (eg ACTIVE) to restrict the results to. Null means all
+ * status values.
+ * @param limitResultsByClassification - List of classifications that must be present on all returned entities.
+ * @param asOfTime - Requests a historical query of the relationships for the entity. Null means return the
+ * present values.
+ * @param level - the number of the relationships out from the starting entity that the query will traverse to
+ * gather results.
+ * @return InstanceGraph - the sub-graph that represents the returned linked entities and their relationships.
+ * @throws InvalidParameterException - one of the parameters is invalid or null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws TypeErrorException - one or more of the type guids passed on the request is not known by the
+ * metadata collection.
+ * @throws EntityNotKnownException - the entity identified by the entityGUID is not found in the metadata collection.
+ * @throws PropertyErrorException - there is a problem with one of the other parameters.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public InstanceGraph getEntityNeighborhood(String userId,
+ String entityGUID,
+ ArrayList<String> entityTypeGUIDs,
+ ArrayList<String> relationshipTypeGUIDs,
+ ArrayList<InstanceStatus> limitResultsByStatus,
+ ArrayList<String> limitResultsByClassification,
+ Date asOfTime,
+ int level) throws InvalidParameterException,
+ RepositoryErrorException,
+ TypeErrorException,
+ EntityNotKnownException,
+ PropertyErrorException,
+ UserNotAuthorizedException
+ {
+ return null;
+ }
+
+
+ /**
+ * Return the list of entities that are of the types listed in instanceTypes and are connected, either directly or
+ * indirectly to the entity identified by startEntityGUID.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param startEntityGUID - unique identifier of the starting entity.
+ * @param instanceTypes - list of types to search for. Null means an type.
+ * @param fromEntityElement - starting element for results list. Used in paging. Zero means first element.
+ * @param limitResultsByStatus - By default, relationships in all statuses are returned. However, it is possible
+ * to specify a list of statuses (eg ACTIVE) to restrict the results to. Null means all
+ * status values.
+ * @param limitResultsByClassification - List of classifications that must be present on all returned entities.
+ * @param asOfTime - Requests a historical query of the relationships for the entity. Null means return the
+ * present values.
+ * @param sequencingProperty - String name of the property that is to be used to sequence the results.
+ * Null means do not sequence on a property name (see SequencingOrder).
+ * @param sequencingOrder - Enum defining how the results should be ordered.
+ * @param pageSize - the maximum number of result entities that can be returned on this request. Zero means
+ * unrestricted return results size.
+ * @return list of entities either directly or indirectly connected to the start entity
+ * @throws InvalidParameterException - one of the parameters is invalid or null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws TypeErrorException - the requested type is not known, or not supported in the metadata repository
+ * hosting the metadata collection.
+ * @throws EntityNotKnownException - the entity identified by the startEntityGUID
+ * is not found in the metadata collection.
+ * @throws PropertyErrorException - the sequencing property specified is not valid for any of the requested types of
+ * entity.
+ * @throws PagingErrorException - the paging/sequencing parameters are set up incorrectly.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public ArrayList<EntityDetail> getRelatedEntities(String userId,
+ String startEntityGUID,
+ ArrayList<String> instanceTypes,
+ int fromEntityElement,
+ ArrayList<InstanceStatus> limitResultsByStatus,
+ ArrayList<String> limitResultsByClassification,
+ Date asOfTime,
+ String sequencingProperty,
+ SequencingOrder sequencingOrder,
+ int pageSize) throws InvalidParameterException,
+ RepositoryErrorException,
+ TypeErrorException,
+ EntityNotKnownException,
+ PropertyErrorException,
+ PagingErrorException,
+ UserNotAuthorizedException
+ {
+ return null;
+ }
+
+
+ /* ======================================================
+ * Group 4: Maintaining entity and relationship instances
+ */
+
+ /**
+ * Create a new entity and put it in the requested state. The new entity is returned.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param entityTypeGUID - unique identifier (guid) for the new entity's type.
+ * @param initialProperties - initial list of properties for the new entity - null means no properties.
+ * @param initialClassifications - initial list of classifications for the new entity - null means no classifications.
+ * @param initialStatus - initial status - typically DRAFT, PREPARED or ACTIVE.
+ * @return EntityDetail showing the new header plus the requested properties and classifications. The entity will
+ * not have any relationships at this stage.
+ * @throws InvalidParameterException - one of the parameters is invalid or null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws TypeErrorException - the requested type is not known, or not supported in the metadata repository
+ * hosting the metadata collection.
+ * @throws PropertyErrorException - one or more of the requested properties are not defined, or have different
+ * characteristics in the TypeDef for this entity's type.
+ * @throws ClassificationErrorException - one or more of the requested classifications are either not known or
+ * not defined for this entity type.
+ * @throws StatusNotSupportedException - the metadata repository hosting the metadata collection does not support
+ * the requested status.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public EntityDetail addEntity(String userId,
+ String entityTypeGUID,
+ InstanceProperties initialProperties,
+ ArrayList<Classification> initialClassifications,
+ InstanceStatus initialStatus) throws InvalidParameterException,
+ RepositoryErrorException,
+ TypeErrorException,
+ PropertyErrorException,
+ ClassificationErrorException,
+ StatusNotSupportedException,
+ UserNotAuthorizedException
+ {
+ return null;
+ }
+
+
+ /**
+ * Create an entity proxy in the metadata collection. This is used to store relationships that span metadata
+ * repositories.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param entityProxy - details of entity to add.
+ * @throws InvalidParameterException - the entity proxy is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws TypeErrorException - the requested type is not known, or not supported in the metadata repository
+ * hosting the metadata collection.
+ * @throws PropertyErrorException - one or more of the requested properties are not defined, or have different
+ * characteristics in the TypeDef for this entity's type.
+ * @throws ClassificationErrorException - one or more of the requested classifications are either not known or
+ * not defined for this entity type.
+ * @throws StatusNotSupportedException - the metadata repository hosting the metadata collection does not support
+ * the requested status.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public void addEntityProxy(String userId,
+ EntityProxy entityProxy) throws InvalidParameterException,
+ RepositoryErrorException,
+ TypeErrorException,
+ PropertyErrorException,
+ ClassificationErrorException,
+ StatusNotSupportedException,
+ UserNotAuthorizedException
+ {
+ }
+
+
+ /**
+ * Update the status for a specific entity.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param entityGUID - unique identifier (guid) for the requested entity.
+ * @param newStatus - new InstanceStatus for the entity.
+ * @return EntityDetail showing the current entity header, properties and classifications.
+ * @throws InvalidParameterException - one of the parameters is invalid or null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws EntityNotKnownException - the entity identified by the guid is not found in the metadata collection.
+ * @throws StatusNotSupportedException - the metadata repository hosting the metadata collection does not support
+ * the requested status.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public EntityDetail updateEntityStatus(String userId,
+ String entityGUID,
+ InstanceStatus newStatus) throws InvalidParameterException,
+ Reposito
<TRUNCATED>
[22/30] atlas git commit: ATLAS-2246: OMRS Connector API plus REST
and IGC Connector skeleton - 15th February 2018
Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/enterprise/repositoryconnector/EnterpriseOMRSRepositoryConnector.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/enterprise/repositoryconnector/EnterpriseOMRSRepositoryConnector.java b/omrs/src/main/java/org/apache/atlas/omrs/enterprise/repositoryconnector/EnterpriseOMRSRepositoryConnector.java
new file mode 100644
index 0000000..f74a772
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/enterprise/repositoryconnector/EnterpriseOMRSRepositoryConnector.java
@@ -0,0 +1,357 @@
+/*
+ * 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.enterprise.repositoryconnector;
+
+import org.apache.atlas.ocf.ffdc.ConnectorCheckedException;
+import org.apache.atlas.omrs.enterprise.connectormanager.OMRSConnectorConsumer;
+import org.apache.atlas.omrs.enterprise.connectormanager.OMRSConnectorManager;
+import org.apache.atlas.omrs.ffdc.exception.RepositoryErrorException;
+import org.apache.atlas.omrs.metadatacollection.OMRSMetadataCollection;
+import org.apache.atlas.omrs.metadatacollection.repositoryconnector.OMRSRepositoryConnector;
+import org.apache.atlas.omrs.ffdc.OMRSErrorCode;
+import org.apache.atlas.omrs.ffdc.exception.OMRSRuntimeException;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+/**
+ * EnterpriseOMRSRepositoryConnector supports federating calls to multiple metadata repositories. As a result,
+ * its OMRSMetadataCollection (EnterpriseOMRSMetadataCollection) returns metadata from all repositories in the
+ * connected open metadata repository cohort(s).
+ * <p>
+ * An instance of the EnterpriseOMRSRepositoryConnector is created by each Open Metadata Access Service (OMAS)
+ * using the OCF ConnectorBroker. They use its metadata collection to retrieve and send the metadata they need.
+ * </p>
+ * <p>
+ * Each EnterpriseOMRSRepositoryConnector instance needs to maintain an up to date list of OMRS Connectors to all of the
+ * repositories in the connected open metadata repository cohort(s). It does by registering as an OMRSConnectorConsumer
+ * with the OMRSConnectorManager to be notified when connectors to new open metadata repositories are available.
+ * </p>
+ */
+public class EnterpriseOMRSRepositoryConnector extends OMRSRepositoryConnector implements OMRSConnectorConsumer
+{
+ private OMRSConnectorManager connectorManager = null;
+ private String connectorConsumerId = null;
+
+ private EnterpriseOMRSMetadataCollection enterpriseMetadataCollection = null;
+ private String enterpriseMetadataCollectionId = null;
+ private String enterpriseMetadataCollectionName = null;
+
+ private boolean connected = false;
+
+ private FederatedConnector localCohortConnector = null;
+ private ArrayList<FederatedConnector> remoteCohortConnectors = new ArrayList<>();
+
+
+ /**
+ * Constructor used by the EnterpriseOMRSConnectorProvider.
+ *
+ * @param connectorManager - provides notifications as repositories register and unregister with the
+ * cohorts.
+ * @param enterpriseMetadataCollectionName - name of the virtual metadata collection that this
+ * connector is managing.
+ */
+ public EnterpriseOMRSRepositoryConnector(OMRSConnectorManager connectorManager,
+ String enterpriseMetadataCollectionName)
+ {
+ super();
+
+ this.enterpriseMetadataCollectionName = enterpriseMetadataCollectionName;
+
+ this.connectorManager = connectorManager;
+
+ if (connectorManager != null)
+ {
+ this.connectorConsumerId = connectorManager.registerConnectorConsumer(this);
+ }
+ else
+ {
+ OMRSErrorCode errorCode = OMRSErrorCode.INVALID_COHORT_CONFIG;
+ String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage();
+
+ throw new OMRSRuntimeException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ "constructor",
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+ }
+
+
+ /**
+ * Set up the unique Id for this metadata collection.
+ *
+ * @param metadataCollectionId - String unique Id
+ */
+ public void setMetadataCollectionId(String metadataCollectionId)
+ {
+ this.enterpriseMetadataCollectionId = metadataCollectionId;
+
+ if (metadataCollectionId != null)
+ {
+ enterpriseMetadataCollection = new EnterpriseOMRSMetadataCollection(this,
+ enterpriseMetadataCollectionId,
+ enterpriseMetadataCollectionName);
+
+ connected = true;
+ }
+ }
+
+
+ /**
+ * Returns the metadata collection object that provides an OMRS abstraction of the metadata within
+ * a metadata repository. For the EnterpriseOMRSRepositoryConnector, this is the metadata collection that is
+ * configured to work across the cohort.
+ *
+ * @return OMRSMetadataCollection - metadata information retrieved from the metadata repository.
+ */
+ public OMRSMetadataCollection getMetadataCollection()
+ {
+ String methodName = "getMetadataCollection()";
+
+ if (enterpriseMetadataCollection == null)
+ {
+ OMRSErrorCode errorCode = OMRSErrorCode.INVALID_COHORT_CONFIG;
+ String errorMessage = errorCode.getErrorMessageId()
+ + errorCode.getFormattedErrorMessage();
+
+ throw new OMRSRuntimeException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ methodName,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+
+ return enterpriseMetadataCollection;
+ }
+
+ /**
+ * Free up any resources held since the connector is no longer needed.
+ *
+ * @throws ConnectorCheckedException - there is a problem disconnecting the connector.
+ */
+ public void disconnect() throws ConnectorCheckedException
+ {
+ if ((connectorManager != null) && (connectorConsumerId != null))
+ {
+ connectorManager.unregisterConnectorConsumer(connectorConsumerId);
+ }
+
+ localCohortConnector = null;
+ remoteCohortConnectors = new ArrayList<>();
+ enterpriseMetadataCollection = null;
+ connected = false;
+ }
+
+
+ /**
+ * Returns the list of metadata collections that the EnterpriseOMRSRepositoryConnector is federating queries across.
+ *
+ * This method is used by this connector's metadata collection object on each request it processes. This
+ * means it always has the most up to date list of metadata collections to work with.
+ *
+ * @return OMRSMetadataCollection ArrayList
+ * @throws RepositoryErrorException - the enterprise services are not available
+ */
+ protected ArrayList<OMRSMetadataCollection> getMetadataCollections() throws RepositoryErrorException
+ {
+ String methodName = "getMetadataCollections()";
+
+ if (connected)
+ {
+ ArrayList<OMRSMetadataCollection> cohortMetadataCollections = new ArrayList<>();
+
+ /*
+ * Make sure the local connector is first.
+ */
+ if (localCohortConnector != null)
+ {
+ cohortMetadataCollections.add(localCohortConnector.getMetadataCollection());
+ }
+
+ /*
+ * Now add the remote connectors.
+ */
+ for (FederatedConnector federatedConnector : remoteCohortConnectors)
+ {
+ cohortMetadataCollections.add(federatedConnector.getMetadataCollection());
+ }
+
+ if (cohortMetadataCollections.size() > 0)
+ {
+ return cohortMetadataCollections;
+ }
+ else
+ {
+ OMRSErrorCode errorCode = OMRSErrorCode.NO_REPOSITORIES;
+ String errorMessage = errorCode.getErrorMessageId()
+ + errorCode.getFormattedErrorMessage();
+
+ throw new RepositoryErrorException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ methodName,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+ }
+ else
+ {
+ OMRSErrorCode errorCode = OMRSErrorCode.ENTERPRISE_DISCONNECTED;
+ String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage();
+
+ throw new RepositoryErrorException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ methodName,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+ }
+
+
+ /**
+ * Save the connector to the local repository. This is passed from the OMRSConnectorManager.
+ *
+ * @param metadataCollectionId - Unique identifier for the metadata collection
+ * @param localConnector - OMRSRepositoryConnector object for the local repository.
+ */
+ public void setLocalConnector(String metadataCollectionId,
+ OMRSRepositoryConnector localConnector)
+ {
+ if (localConnector != null)
+ {
+ localCohortConnector = new FederatedConnector(metadataCollectionId,
+ localConnector,
+ localConnector.getMetadataCollection());
+ }
+ else
+ {
+ localCohortConnector = null;
+ }
+ }
+
+
+ /**
+ * Pass the connector to one of the remote repositories in the metadata repository cohort.
+ *
+ * @param metadataCollectionId - Unique identifier for the metadata collection
+ * @param remoteConnector - OMRSRepositoryConnector object providing access to the remote repository.
+ */
+ public void addRemoteConnector(String metadataCollectionId,
+ OMRSRepositoryConnector remoteConnector)
+ {
+ if (remoteConnector != null)
+ {
+ remoteCohortConnectors.add(new FederatedConnector(metadataCollectionId,
+ remoteConnector,
+ remoteConnector.getMetadataCollection()));
+ }
+ }
+
+
+ /**
+ * Pass the metadata collection id for a repository that has just left the metadata repository cohort.
+ *
+ * @param metadataCollectionId - identifier of the metadata collection that is no longer available.
+ */
+ public void removeRemoteConnector(String metadataCollectionId)
+ {
+ Iterator<FederatedConnector> iterator = remoteCohortConnectors.iterator();
+
+ while(iterator.hasNext())
+ {
+ FederatedConnector registeredConnector = iterator.next();
+
+ if (registeredConnector.getMetadataCollectionId().equals(metadataCollectionId))
+ {
+ iterator.remove();
+ }
+ }
+ }
+
+ /**
+ * Call disconnect on all registered connectors and stop calling them. The OMRS is about to shutdown.
+ */
+ public void disconnectAllConnectors()
+ {
+ // TODO
+ }
+
+
+ /**
+ * FederatedConnector is a private class for storing details of each of the connectors to the repositories
+ * in the open metadata repository cohort.
+ */
+ private class FederatedConnector
+ {
+ private String metadataCollectionId = null;
+ private OMRSRepositoryConnector connector = null;
+ private OMRSMetadataCollection metadataCollection = null;
+
+
+ /**
+ * Constructor to set up the details of a federated connector.
+ *
+ * @param metadataCollectionId - unique identifier for the metadata collection accessed through the connector
+ * @param connector - connector for the repository
+ * @param metadataCollection - metadata collection from the connection.
+ */
+ public FederatedConnector(String metadataCollectionId, OMRSRepositoryConnector connector, OMRSMetadataCollection metadataCollection)
+ {
+ this.metadataCollectionId = metadataCollectionId;
+ this.connector = connector;
+ this.metadataCollection = metadataCollection;
+ }
+
+
+ /**
+ * Return the identifier for the metadata collection accessed through the connector.
+ *
+ * @return String identifier
+ */
+ public String getMetadataCollectionId()
+ {
+ return metadataCollectionId;
+ }
+
+
+ /**
+ * Return the connector for the repository.
+ *
+ * @return OMRSRepositoryConnector object
+ */
+ public OMRSRepositoryConnector getConnector()
+ {
+ return connector;
+ }
+
+
+ /**
+ * Return the metadata collection associated with the connector.
+ *
+ * @return OMRSMetadataCollection object
+ */
+ public OMRSMetadataCollection getMetadataCollection()
+ {
+ return metadataCollection;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/OMRSEventListener.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/OMRSEventListener.java b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/OMRSEventListener.java
new file mode 100644
index 0000000..9db6892
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/OMRSEventListener.java
@@ -0,0 +1,832 @@
+/*
+ * 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.auditlog.OMRSAuditCode;
+import org.apache.atlas.omrs.auditlog.OMRSAuditLog;
+import org.apache.atlas.omrs.auditlog.OMRSAuditingComponent;
+import org.apache.atlas.omrs.eventmanagement.events.*;
+import org.apache.atlas.omrs.eventmanagement.events.v1.OMRSEventV1;
+import org.apache.atlas.omrs.topicconnectors.OMRSTopicListener;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * <p>
+ * The OMRSEventListener manages inbound events from the metadata repository cohort. There are
+ * two main groups of events: registration events that are handled by the OMRSCohortRegistry and metadata
+ * events that describe changes to TypeDefs and metadata instances. The metadata events are handled by the
+ * local connector.
+ * </p>
+ * <p>
+ * The role of the OMRSEventListener is to decide which events to process. This is controlled by the
+ * synchronization rule passed on the constructor.
+ * </p>
+ */
+public class OMRSEventListener implements OMRSTopicListener
+{
+ private String cohortName = null;
+ private String localMetadataCollectionId = null;
+
+ /*
+ * There is an event processor for each category of event. The OMRSEventListener passes appropriate events to these
+ * objects depending on the settings of its configuration.
+ */
+ private OMRSRegistryEventProcessor registryEventProcessor = null;
+ private OMRSTypeDefEventProcessor typeDefEventProcessor = null;
+ private OMRSInstanceEventProcessor instanceEventProcessor = null;
+
+ /*
+ * The audit log is used for recording events, decisions, errors and exceptions
+ */
+ private OMRSAuditLog auditLog = new OMRSAuditLog(OMRSAuditingComponent.EVENT_LISTENER);
+
+
+ private static final Logger log = LoggerFactory.getLogger(OMRSEventListener.class);
+
+
+ /**
+ * Default Constructor - saves configuration parameters.
+ *
+ * @param cohortName - name of the cohort that this event listener belongs to
+ * @param localMetadataCollectionId - unique identifier for the local metadata collection
+ * @param registryEventProcessor - processor for registry events
+ * @param typeDefEventProcessor - processor for TypeDef synchronization events
+ * @param instanceEventProcessor - processor for metadata instance replication
+ */
+ public OMRSEventListener(String cohortName,
+ String localMetadataCollectionId,
+ OMRSRegistryEventProcessor registryEventProcessor,
+ OMRSTypeDefEventProcessor typeDefEventProcessor,
+ OMRSInstanceEventProcessor instanceEventProcessor)
+ {
+ this.cohortName = cohortName;
+ this.localMetadataCollectionId = localMetadataCollectionId;
+ this.registryEventProcessor = registryEventProcessor;
+ this.typeDefEventProcessor = typeDefEventProcessor;
+ this.instanceEventProcessor = instanceEventProcessor;
+ }
+
+
+ /**
+ * Process an incoming event. This method is called by the OMRSTopicConnector. The processing is careful of nulls
+ * and ignores an event that is incorrectly formatted. The assumption is that the unformatted part of the message
+ * is an extension from a newer versionName of the protocol and can be ignored.
+ *
+ * @param event Version 1 of the OMRSEvent that defines the category and payload of the incoming event.
+ */
+ public void processEvent(OMRSEventV1 event)
+ {
+ String actionDescription = "Process Incoming Event";
+
+ /*
+ * The event should not be null but worth checking.
+ */
+ if (event != null)
+ {
+ /*
+ * If the event came from this server - then ignore it.
+ */
+ if ((localMetadataCollectionId != null) &&
+ (localMetadataCollectionId.equals(event.getOriginator().getMetadataCollectionId())))
+ {
+ if (log.isDebugEnabled())
+ {
+ log.debug("Ignoring event that this server originated");
+ }
+ }
+ else
+ {
+ /*
+ * Determine the category of event to process.
+ */
+ switch (event.getEventCategory())
+ {
+ case REGISTRY:
+ this.processRegistryEvent(new OMRSRegistryEvent(event));
+ break;
+
+ case TYPEDEF:
+ this.processTypeDefEvent(new OMRSTypeDefEvent(event));
+ break;
+
+ case INSTANCE:
+ this.processInstanceEvent(new OMRSInstanceEvent(event));
+ break;
+
+ default:
+ /*
+ * Nothing to do since this server does not understand the message type. This situation
+ * will occur if the local server is back level from another server in the cohort
+ * and the more advanced server supports new types of messages,
+ */
+ OMRSAuditCode auditCode = OMRSAuditCode.PROCESS_UNKNOWN_EVENT;
+
+ auditLog.logRecord(actionDescription,
+ auditCode.getLogMessageId(),
+ auditCode.getSeverity(),
+ auditCode.getFormattedLogMessage(),
+ "event {" + event.toString() + "}",
+ auditCode.getSystemAction(),
+ auditCode.getUserAction());
+
+ if (log.isDebugEnabled())
+ {
+ log.debug("Unknown event received :|");
+ }
+
+ }
+ }
+ }
+ else
+ {
+ /*
+ * A null event was passed - probably should not happen so log audit record.
+ */
+ OMRSAuditCode auditCode = OMRSAuditCode.NULL_OMRS_EVENT_RECEIVED;
+
+ auditLog.logRecord(actionDescription,
+ auditCode.getLogMessageId(),
+ auditCode.getSeverity(),
+ auditCode.getFormattedLogMessage(),
+ null,
+ auditCode.getSystemAction(),
+ auditCode.getUserAction());
+
+ if (log.isDebugEnabled())
+ {
+ log.debug("Null OMRS Event received :(");
+ }
+ }
+ }
+
+
+ /**
+ * The event contains a registry event. It needs to be further unpacked and passed to the appropriate
+ * registry event processor (OMRSCohortRegistry).
+ *
+ * @param registryEvent event to unpack
+ */
+ private void processRegistryEvent(OMRSRegistryEvent registryEvent)
+ {
+ if (log.isDebugEnabled())
+ {
+ log.debug("Processing registry event", registryEvent);
+ }
+
+ if (registryEvent == null)
+ {
+ if (log.isDebugEnabled())
+ {
+ log.debug("Null registry event - ignoring event");
+ }
+ }
+ else if (registryEventProcessor == null)
+ {
+ if (log.isDebugEnabled())
+ {
+ log.debug("No registry event processor - ignoring event ");
+ }
+ }
+ else /* process registry event */
+ {
+ OMRSRegistryEventType registryEventType = registryEvent.getRegistryEventType();
+ OMRSEventOriginator registryEventOriginator = registryEvent.getEventOriginator();
+
+ if ((registryEventType != null) && (registryEventOriginator != null))
+ {
+ switch (registryEventType)
+ {
+ case REGISTRATION_EVENT:
+ registryEventProcessor.processRegistrationEvent(cohortName,
+ registryEventOriginator.getMetadataCollectionId(),
+ registryEventOriginator.getServerName(),
+ registryEventOriginator.getServerType(),
+ registryEventOriginator.getOrganizationName(),
+ registryEvent.getRegistrationTimestamp(),
+ registryEvent.getRemoteConnection(),
+ registryEvent.getTypeDefSummaries());
+ break;
+
+ case RE_REGISTRATION_EVENT:
+ registryEventProcessor.processReRegistrationEvent(cohortName,
+ registryEventOriginator.getMetadataCollectionId(),
+ registryEventOriginator.getServerName(),
+ registryEventOriginator.getServerType(),
+ registryEventOriginator.getOrganizationName(),
+ registryEvent.getRegistrationTimestamp(),
+ registryEvent.getRemoteConnection(),
+ registryEvent.getTypeDefSummaries());
+ break;
+
+ case REFRESH_REGISTRATION_REQUEST:
+ registryEventProcessor.processRegistrationRefreshRequest(cohortName,
+ registryEventOriginator.getServerName(),
+ registryEventOriginator.getServerType(),
+ registryEventOriginator.getOrganizationName());
+ break;
+
+ case UN_REGISTRATION_EVENT:
+ registryEventProcessor.processUnRegistrationEvent(cohortName,
+ registryEventOriginator.getMetadataCollectionId(),
+ registryEventOriginator.getServerName(),
+ registryEventOriginator.getServerType(),
+ registryEventOriginator.getOrganizationName());
+ break;
+
+ case REGISTRATION_ERROR_EVENT:
+ OMRSRegistryEventErrorCode errorCode = registryEvent.getErrorCode();
+
+ if (errorCode != null)
+ {
+ switch(errorCode)
+ {
+ case BAD_REMOTE_CONNECTION:
+ registryEventProcessor.processBadConnectionEvent(cohortName,
+ registryEventOriginator.getMetadataCollectionId(),
+ registryEventOriginator.getServerName(),
+ registryEventOriginator.getServerType(),
+ registryEventOriginator.getOrganizationName(),
+ registryEvent.getTargetMetadataCollectionId(),
+ registryEvent.getTargetRemoteConnection(),
+ registryEvent.getErrorMessage());
+ break;
+
+ case CONFLICTING_COLLECTION_ID:
+ registryEventProcessor.processConflictingCollectionIdEvent(cohortName,
+ registryEventOriginator.getMetadataCollectionId(),
+ registryEventOriginator.getServerName(),
+ registryEventOriginator.getServerType(),
+ registryEventOriginator.getOrganizationName(),
+ registryEvent.getTargetMetadataCollectionId(),
+ registryEvent.getErrorMessage());
+ break;
+
+ default:
+ if (log.isDebugEnabled())
+ {
+ log.debug("Unknown registry event error code - ignoring event");
+ }
+ break;
+ }
+ }
+ else
+ {
+ if (log.isDebugEnabled())
+ {
+ log.debug("Null registry event error code - ignoring event");
+ }
+ }
+ break;
+
+ default:
+ /*
+ * New type of registry event that this server does not understand - ignore it
+ */
+ if (log.isDebugEnabled())
+ {
+ log.debug("Unknown registry event: " + registryEvent.toString());
+ }
+ break;
+ }
+ }
+ else
+ {
+ if (log.isDebugEnabled())
+ {
+ log.debug("Ignored registry event: " + registryEvent.toString());
+ }
+ }
+ }
+ }
+
+
+ /**
+ * Unpack and deliver a TypeDef event to the TypeDefEventProcessor
+ *
+ * @param typeDefEvent - event to unpack
+ */
+ private void processTypeDefEvent(OMRSTypeDefEvent typeDefEvent)
+ {
+ if (typeDefEvent == null)
+ {
+ if (log.isDebugEnabled())
+ {
+ log.debug("Null TypeDef event - ignoring event");
+ }
+ }
+ else if (typeDefEventProcessor == null)
+ {
+ if (log.isDebugEnabled())
+ {
+ log.debug("No TypeDef event processor - ignoring event");
+ }
+ }
+ else
+ {
+ OMRSTypeDefEventType typeDefEventType = typeDefEvent.getTypeDefEventType();
+ OMRSEventOriginator typeDefEventOriginator = typeDefEvent.getEventOriginator();
+
+ if ((typeDefEventType != null) && (typeDefEventOriginator != null))
+ {
+ switch (typeDefEventType)
+ {
+ case NEW_TYPEDEF_EVENT:
+ typeDefEventProcessor.processNewTypeDefEvent(cohortName,
+ typeDefEventOriginator.getMetadataCollectionId(),
+ typeDefEventOriginator.getServerName(),
+ typeDefEventOriginator.getServerType(),
+ typeDefEventOriginator.getOrganizationName(),
+ typeDefEvent.getTypeDef());
+ break;
+
+ case NEW_ATTRIBUTE_TYPEDEF_EVENT:
+ typeDefEventProcessor.processNewAttributeTypeDefEvent(cohortName,
+ typeDefEventOriginator.getMetadataCollectionId(),
+ typeDefEventOriginator.getServerName(),
+ typeDefEventOriginator.getServerType(),
+ typeDefEventOriginator.getOrganizationName(),
+ typeDefEvent.getAttributeTypeDef());
+ break;
+
+ case UPDATED_TYPEDEF_EVENT:
+ typeDefEventProcessor.processUpdatedTypeDefEvent(cohortName,
+ typeDefEventOriginator.getMetadataCollectionId(),
+ typeDefEventOriginator.getServerName(),
+ typeDefEventOriginator.getServerType(),
+ typeDefEventOriginator.getOrganizationName(),
+ typeDefEvent.getTypeDefPatch());
+ break;
+
+ case DELETED_TYPEDEF_EVENT:
+ typeDefEventProcessor.processDeletedTypeDefEvent(cohortName,
+ typeDefEventOriginator.getMetadataCollectionId(),
+ typeDefEventOriginator.getServerName(),
+ typeDefEventOriginator.getServerType(),
+ typeDefEventOriginator.getOrganizationName(),
+ typeDefEvent.getTypeDefGUID(),
+ typeDefEvent.getTypeDefName());
+ break;
+
+ case DELETED_ATTRIBUTE_TYPEDEF_EVENT:
+ typeDefEventProcessor.processDeletedAttributeTypeDefEvent(cohortName,
+ typeDefEventOriginator.getMetadataCollectionId(),
+ typeDefEventOriginator.getServerName(),
+ typeDefEventOriginator.getServerType(),
+ typeDefEventOriginator.getOrganizationName(),
+ typeDefEvent.getTypeDefGUID(),
+ typeDefEvent.getTypeDefName());
+ break;
+
+ case RE_IDENTIFIED_TYPEDEF_EVENT:
+ typeDefEventProcessor.processReIdentifiedTypeDefEvent(cohortName,
+ typeDefEventOriginator.getMetadataCollectionId(),
+ typeDefEventOriginator.getServerName(),
+ typeDefEventOriginator.getServerType(),
+ typeDefEventOriginator.getOrganizationName(),
+ typeDefEvent.getOriginalTypeDefSummary(),
+ typeDefEvent.getTypeDef());
+ break;
+
+ case RE_IDENTIFIED_ATTRIBUTE_TYPEDEF_EVENT:
+ typeDefEventProcessor.processReIdentifiedAttributeTypeDefEvent(cohortName,
+ typeDefEventOriginator.getMetadataCollectionId(),
+ typeDefEventOriginator.getServerName(),
+ typeDefEventOriginator.getServerType(),
+ typeDefEventOriginator.getOrganizationName(),
+ typeDefEvent.getOriginalAttributeTypeDef(),
+ typeDefEvent.getAttributeTypeDef());
+
+ case TYPEDEF_ERROR_EVENT:
+ OMRSTypeDefEventErrorCode errorCode = typeDefEvent.getErrorCode();
+
+ if (errorCode != null)
+ {
+ switch(errorCode)
+ {
+ case CONFLICTING_TYPEDEFS:
+ typeDefEventProcessor.processTypeDefConflictEvent(cohortName,
+ typeDefEventOriginator.getMetadataCollectionId(),
+ typeDefEventOriginator.getServerName(),
+ typeDefEventOriginator.getServerType(),
+ typeDefEventOriginator.getOrganizationName(),
+ typeDefEvent.getOriginalTypeDefSummary(),
+ typeDefEvent.getOtherMetadataCollectionId(),
+ typeDefEvent.getOtherTypeDefSummary(),
+ typeDefEvent.getErrorMessage());
+ break;
+
+ case CONFLICTING_ATTRIBUTE_TYPEDEFS:
+ typeDefEventProcessor.processAttributeTypeDefConflictEvent(cohortName,
+ typeDefEventOriginator.getMetadataCollectionId(),
+ typeDefEventOriginator.getServerName(),
+ typeDefEventOriginator.getServerType(),
+ typeDefEventOriginator.getOrganizationName(),
+ typeDefEvent.getOriginalAttributeTypeDef(),
+ typeDefEvent.getOtherMetadataCollectionId(),
+ typeDefEvent.getOtherAttributeTypeDef(),
+ typeDefEvent.getErrorMessage());
+
+ case TYPEDEF_PATCH_MISMATCH:
+ typeDefEventProcessor.processTypeDefPatchMismatchEvent(cohortName,
+ typeDefEventOriginator.getMetadataCollectionId(),
+ typeDefEventOriginator.getServerName(),
+ typeDefEventOriginator.getServerType(),
+ typeDefEventOriginator.getOrganizationName(),
+ typeDefEvent.getTargetMetadataCollectionId(),
+ typeDefEvent.getTargetTypeDefSummary(),
+ typeDefEvent.getOtherTypeDef(),
+ typeDefEvent.getErrorMessage());
+ break;
+
+ default:
+ if (log.isDebugEnabled())
+ {
+ log.debug("Unknown TypeDef event error code - ignoring event");
+ }
+ break;
+ }
+ }
+ else
+ {
+ if (log.isDebugEnabled())
+ {
+ log.debug("Ignored TypeDef event - null error code");
+ }
+ }
+ break;
+
+ default:
+ if (log.isDebugEnabled())
+ {
+ log.debug("Ignored TypeDef event - unknown type");
+ }
+ break;
+ }
+ }
+ }
+ }
+
+
+ /**
+ * Unpack and deliver an instance event to the InstanceEventProcessor
+ *
+ * @param instanceEvent - event to unpack
+ */
+ private void processInstanceEvent(OMRSInstanceEvent instanceEvent)
+ {
+ if (log.isDebugEnabled())
+ {
+ log.debug("Processing instance event", instanceEvent);
+ }
+
+ if (instanceEvent == null)
+ {
+ if (log.isDebugEnabled())
+ {
+ log.debug("Null instance event - ignoring event");
+ }
+ }
+ else
+ {
+ OMRSInstanceEventType instanceEventType = instanceEvent.getInstanceEventType();
+ OMRSEventOriginator instanceEventOriginator = instanceEvent.getEventOriginator();
+
+ if ((instanceEventType != null) && (instanceEventOriginator != null))
+ {
+ switch (instanceEventType)
+ {
+ case NEW_ENTITY_EVENT:
+ instanceEventProcessor.processNewEntityEvent(cohortName,
+ instanceEventOriginator.getMetadataCollectionId(),
+ instanceEventOriginator.getServerName(),
+ instanceEventOriginator.getServerType(),
+ instanceEventOriginator.getOrganizationName(),
+ instanceEvent.getEntity());
+ break;
+
+ case UPDATED_ENTITY_EVENT:
+ instanceEventProcessor.processUpdatedEntityEvent(cohortName,
+ instanceEventOriginator.getMetadataCollectionId(),
+ instanceEventOriginator.getServerName(),
+ instanceEventOriginator.getServerType(),
+ instanceEventOriginator.getOrganizationName(),
+ instanceEvent.getEntity());
+ break;
+
+ case CLASSIFIED_ENTITY_EVENT:
+ instanceEventProcessor.processClassifiedEntityEvent(cohortName,
+ instanceEventOriginator.getMetadataCollectionId(),
+ instanceEventOriginator.getServerName(),
+ instanceEventOriginator.getServerType(),
+ instanceEventOriginator.getOrganizationName(),
+ instanceEvent.getEntity());
+ break;
+
+ case RECLASSIFIED_ENTITY_EVENT:
+ instanceEventProcessor.processReclassifiedEntityEvent(cohortName,
+ instanceEventOriginator.getMetadataCollectionId(),
+ instanceEventOriginator.getServerName(),
+ instanceEventOriginator.getServerType(),
+ instanceEventOriginator.getOrganizationName(),
+ instanceEvent.getEntity());
+ break;
+
+ case DECLASSIFIED_ENTITY_EVENT:
+ instanceEventProcessor.processDeclassifiedEntityEvent(cohortName,
+ instanceEventOriginator.getMetadataCollectionId(),
+ instanceEventOriginator.getServerName(),
+ instanceEventOriginator.getServerType(),
+ instanceEventOriginator.getOrganizationName(),
+ instanceEvent.getEntity());
+ break;
+
+ case DELETED_ENTITY_EVENT:
+ instanceEventProcessor.processDeletedEntityEvent(cohortName,
+ instanceEventOriginator.getMetadataCollectionId(),
+ instanceEventOriginator.getServerName(),
+ instanceEventOriginator.getServerType(),
+ instanceEventOriginator.getOrganizationName(),
+ instanceEvent.getTypeDefGUID(),
+ instanceEvent.getTypeDefName(),
+ instanceEvent.getInstanceGUID());
+ break;
+
+ case PURGED_ENTITY_EVENT:
+ instanceEventProcessor.processPurgedEntityEvent(cohortName,
+ instanceEventOriginator.getMetadataCollectionId(),
+ instanceEventOriginator.getServerName(),
+ instanceEventOriginator.getServerType(),
+ instanceEventOriginator.getOrganizationName(),
+ instanceEvent.getTypeDefGUID(),
+ instanceEvent.getTypeDefName(),
+ instanceEvent.getInstanceGUID());
+ break;
+
+ case UNDONE_ENTITY_EVENT:
+ instanceEventProcessor.processUndoneEntityEvent(cohortName,
+ instanceEventOriginator.getMetadataCollectionId(),
+ instanceEventOriginator.getServerName(),
+ instanceEventOriginator.getServerType(),
+ instanceEventOriginator.getOrganizationName(),
+ instanceEvent.getEntity());
+ break;
+
+ case RESTORED_ENTITY_EVENT:
+ instanceEventProcessor.processRestoredEntityEvent(cohortName,
+ instanceEventOriginator.getMetadataCollectionId(),
+ instanceEventOriginator.getServerName(),
+ instanceEventOriginator.getServerType(),
+ instanceEventOriginator.getOrganizationName(),
+ instanceEvent.getEntity());
+ break;
+
+ case REFRESH_ENTITY_REQUEST:
+ instanceEventProcessor.processRefreshEntityRequested(cohortName,
+ instanceEventOriginator.getMetadataCollectionId(),
+ instanceEventOriginator.getServerName(),
+ instanceEventOriginator.getServerType(),
+ instanceEventOriginator.getOrganizationName(),
+ instanceEvent.getTypeDefGUID(),
+ instanceEvent.getTypeDefName(),
+ instanceEvent.getInstanceGUID(),
+ instanceEvent.getHomeMetadataCollectionId());
+ break;
+
+ case REFRESHED_ENTITY_EVENT:
+ instanceEventProcessor.processRefreshEntityEvent(cohortName,
+ instanceEventOriginator.getMetadataCollectionId(),
+ instanceEventOriginator.getServerName(),
+ instanceEventOriginator.getServerType(),
+ instanceEventOriginator.getOrganizationName(),
+ instanceEvent.getEntity());
+ break;
+
+ case RE_HOMED_ENTITY_EVENT:
+ instanceEventProcessor.processReHomedEntityEvent(cohortName,
+ instanceEventOriginator.getMetadataCollectionId(),
+ instanceEventOriginator.getServerName(),
+ instanceEventOriginator.getServerType(),
+ instanceEventOriginator.getOrganizationName(),
+ instanceEvent.getOriginalHomeMetadataCollectionId(),
+ instanceEvent.getEntity());
+ break;
+
+ case RETYPED_ENTITY_EVENT:
+ instanceEventProcessor.processReTypedEntityEvent(cohortName,
+ instanceEventOriginator.getMetadataCollectionId(),
+ instanceEventOriginator.getServerName(),
+ instanceEventOriginator.getServerType(),
+ instanceEventOriginator.getOrganizationName(),
+ instanceEvent.getOriginalTypeDefSummary(),
+ instanceEvent.getEntity());
+ break;
+
+ case RE_IDENTIFIED_ENTITY_EVENT:
+ instanceEventProcessor.processReIdentifiedEntityEvent(cohortName,
+ instanceEventOriginator.getMetadataCollectionId(),
+ instanceEventOriginator.getServerName(),
+ instanceEventOriginator.getServerType(),
+ instanceEventOriginator.getOrganizationName(),
+ instanceEvent.getOriginalInstanceGUID(),
+ instanceEvent.getEntity());
+ break;
+
+ case NEW_RELATIONSHIP_EVENT:
+ instanceEventProcessor.processNewRelationshipEvent(cohortName,
+ instanceEventOriginator.getMetadataCollectionId(),
+ instanceEventOriginator.getServerName(),
+ instanceEventOriginator.getServerType(),
+ instanceEventOriginator.getOrganizationName(),
+ instanceEvent.getRelationship());
+ break;
+
+ case UPDATED_RELATIONSHIP_EVENT:
+ instanceEventProcessor.processUpdatedRelationshipEvent(cohortName,
+ instanceEventOriginator.getMetadataCollectionId(),
+ instanceEventOriginator.getServerName(),
+ instanceEventOriginator.getServerType(),
+ instanceEventOriginator.getOrganizationName(),
+ instanceEvent.getRelationship());
+ break;
+
+ case UNDONE_RELATIONSHIP_EVENT:
+ instanceEventProcessor.processUndoneRelationshipEvent(cohortName,
+ instanceEventOriginator.getMetadataCollectionId(),
+ instanceEventOriginator.getServerName(),
+ instanceEventOriginator.getServerType(),
+ instanceEventOriginator.getOrganizationName(),
+ instanceEvent.getRelationship());
+ break;
+
+ case DELETED_RELATIONSHIP_EVENT:
+ instanceEventProcessor.processDeletedRelationshipEvent(cohortName,
+ instanceEventOriginator.getMetadataCollectionId(),
+ instanceEventOriginator.getServerName(),
+ instanceEventOriginator.getServerType(),
+ instanceEventOriginator.getOrganizationName(),
+ instanceEvent.getTypeDefGUID(),
+ instanceEvent.getTypeDefName(),
+ instanceEvent.getInstanceGUID());
+ break;
+
+ case PURGED_RELATIONSHIP_EVENT:
+ instanceEventProcessor.processPurgedEntityEvent(cohortName,
+ instanceEventOriginator.getMetadataCollectionId(),
+ instanceEventOriginator.getServerName(),
+ instanceEventOriginator.getServerType(),
+ instanceEventOriginator.getOrganizationName(),
+ instanceEvent.getTypeDefGUID(),
+ instanceEvent.getTypeDefName(),
+ instanceEvent.getInstanceGUID());
+ break;
+
+ case RESTORED_RELATIONSHIP_EVENT:
+ instanceEventProcessor.processRestoredRelationshipEvent(cohortName,
+ instanceEventOriginator.getMetadataCollectionId(),
+ instanceEventOriginator.getServerName(),
+ instanceEventOriginator.getServerType(),
+ instanceEventOriginator.getOrganizationName(),
+ instanceEvent.getRelationship());
+ break;
+
+ case REFRESH_RELATIONSHIP_REQUEST:
+ instanceEventProcessor.processRefreshRelationshipRequest(cohortName,
+ instanceEventOriginator.getMetadataCollectionId(),
+ instanceEventOriginator.getServerName(),
+ instanceEventOriginator.getServerType(),
+ instanceEventOriginator.getOrganizationName(),
+ instanceEvent.getTypeDefGUID(),
+ instanceEvent.getTypeDefName(),
+ instanceEvent.getInstanceGUID(),
+ instanceEvent.getHomeMetadataCollectionId());
+ break;
+
+ case REFRESHED_RELATIONSHIP_EVENT:
+ instanceEventProcessor.processRefreshRelationshipEvent(cohortName,
+ instanceEventOriginator.getMetadataCollectionId(),
+ instanceEventOriginator.getServerName(),
+ instanceEventOriginator.getServerType(),
+ instanceEventOriginator.getOrganizationName(),
+ instanceEvent.getRelationship());
+ break;
+
+ case RE_IDENTIFIED_RELATIONSHIP_EVENT:
+ instanceEventProcessor.processReIdentifiedRelationshipEvent(cohortName,
+ instanceEventOriginator.getMetadataCollectionId(),
+ instanceEventOriginator.getServerName(),
+ instanceEventOriginator.getServerType(),
+ instanceEventOriginator.getOrganizationName(),
+ instanceEvent.getOriginalInstanceGUID(),
+ instanceEvent.getRelationship());
+ break;
+
+ case RE_HOMED_RELATIONSHIP_EVENT:
+ instanceEventProcessor.processReHomedRelationshipEvent(cohortName,
+ instanceEventOriginator.getMetadataCollectionId(),
+ instanceEventOriginator.getServerName(),
+ instanceEventOriginator.getServerType(),
+ instanceEventOriginator.getOrganizationName(),
+ instanceEvent.getOriginalHomeMetadataCollectionId(),
+ instanceEvent.getRelationship());
+ break;
+
+ case RETYPED_RELATIONSHIP_EVENT:
+ instanceEventProcessor.processReTypedRelationshipEvent(cohortName,
+ instanceEventOriginator.getMetadataCollectionId(),
+ instanceEventOriginator.getServerName(),
+ instanceEventOriginator.getServerType(),
+ instanceEventOriginator.getOrganizationName(),
+ instanceEvent.getOriginalTypeDefSummary(),
+ instanceEvent.getRelationship());
+ break;
+
+ case INSTANCE_ERROR_EVENT:
+ OMRSInstanceEventErrorCode errorCode = instanceEvent.getErrorCode();
+
+ if (errorCode != null)
+ {
+ switch(errorCode)
+ {
+ case CONFLICTING_INSTANCES:
+ instanceEventProcessor.processConflictingInstancesEvent(cohortName,
+ instanceEventOriginator.getMetadataCollectionId(),
+ instanceEventOriginator.getServerName(),
+ instanceEventOriginator.getServerType(),
+ instanceEventOriginator.getOrganizationName(),
+ instanceEvent.getTargetMetadataCollectionId(),
+ instanceEvent.getTargetTypeDefSummary(),
+ instanceEvent.getTargetInstanceGUID(),
+ instanceEvent.getOtherMetadataCollectionId(),
+ instanceEvent.getOtherOrigin(),
+ instanceEvent.getOtherTypeDefSummary(),
+ instanceEvent.getOtherInstanceGUID(),
+ instanceEvent.getErrorMessage());
+ break;
+
+ case CONFLICTING_TYPE:
+ instanceEventProcessor.processConflictingTypeEvent(cohortName,
+ instanceEventOriginator.getMetadataCollectionId(),
+ instanceEventOriginator.getServerName(),
+ instanceEventOriginator.getServerType(),
+ instanceEventOriginator.getOrganizationName(),
+ instanceEvent.getTargetMetadataCollectionId(),
+ instanceEvent.getTargetTypeDefSummary(),
+ instanceEvent.getTargetInstanceGUID(),
+ instanceEvent.getOtherTypeDefSummary(),
+ instanceEvent.getErrorMessage());
+ break;
+
+ default:
+ if (log.isDebugEnabled())
+ {
+ log.debug("Unknown instance event error code - ignoring event");
+ }
+ break;
+ }
+ }
+ else
+ {
+ if (log.isDebugEnabled())
+ {
+ log.debug("Ignored Instance event - null error code");
+ }
+ }
+ break;
+
+ default:
+ if (log.isDebugEnabled())
+ {
+ log.debug("Ignored TypeDef event - unknown type");
+ }
+ break;
+ }
+ }
+ else
+ {
+ if (log.isDebugEnabled())
+ {
+ log.debug("Ignored instance event - null type");
+ }
+ }
+ }
+ }
+}
+
+
+
[28/30] atlas git commit: ATLAS-2246: OMRS Connector API plus REST
and IGC Connector skeleton - 15th February 2018
Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/OMRSArchiveBuilder.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/OMRSArchiveBuilder.java b/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/OMRSArchiveBuilder.java
new file mode 100644
index 0000000..ab2b2f6
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/OMRSArchiveBuilder.java
@@ -0,0 +1,338 @@
+/*
+ * 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;
+
+import 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 org.apache.atlas.omrs.metadatacollection.properties.typedefs.*;
+
+import java.util.*;
+
+/**
+ * OMRSArchiveBuilder creates an in-memory copy of an open metadata archive that can be saved to disk or processed
+ * by a server.
+ */
+public class OMRSArchiveBuilder
+{
+ /*
+ * Archive properties supplied on the constructor
+ */
+ private OpenMetadataArchiveProperties archiveProperties = null;
+
+ /*
+ * Hash maps for accumulating TypeDefs and instances as the content of the archive is built up.
+ */
+ private Map<String, PrimitiveDef> primitiveDefMap = new HashMap<>();
+ private Map<String, CollectionDef> collectionDefMap = new HashMap<>();
+ private Map<String, EnumDef> enumDefMap = new HashMap<>();
+ private Map<String, ClassificationDef> classificationDefMap = new HashMap<>();
+ private Map<String, EntityDef> entityDefMap = new HashMap<>();
+ private Map<String, RelationshipDef> relationshipDefMap = new HashMap<>();
+ private Map<String, TypeDefPatch> typeDefPatchMap = new HashMap<>();
+ private Map<String, EntityDetail> entityDetailMap = new HashMap<>();
+ private Map<String, Relationship> relationshipMap = new HashMap<>();
+
+
+ /**
+ * Typical constructor passes parameters used to build the open metadata archive's property header.
+ *
+ * @param archiveGUID - unique identifier for this open metadata archive.
+ * @param archiveName - name of the open metadata archive.
+ * @param archiveDescription - description of the open metadata archive.
+ * @param archiveType - enum describing the type of archive this is.
+ * @param originatorName - name of the originator (person or organization) of the archive.
+ * @param creationDate - data that this archive was created.
+ * @param dependsOnArchives - list of GUIDs for archives that this archive depends on (null for no dependencies).
+ */
+ public OMRSArchiveBuilder(String archiveGUID,
+ String archiveName,
+ String archiveDescription,
+ OpenMetadataArchiveType archiveType,
+ String originatorName,
+ Date creationDate,
+ ArrayList<String> dependsOnArchives)
+ {
+ this.archiveProperties = new OpenMetadataArchiveProperties();
+
+ this.archiveProperties.setArchiveGUID(archiveGUID);
+ this.archiveProperties.setArchiveName(archiveName);
+ this.archiveProperties.setArchiveDescription(archiveDescription);
+ this.archiveProperties.setArchiveType(archiveType);
+ this.archiveProperties.setOriginatorName(originatorName);
+ this.archiveProperties.setCreationDate(creationDate);
+ this.archiveProperties.setDependsOnArchives(dependsOnArchives);
+ }
+
+
+ /**
+ * Add a new PrimitiveDef to the archive.
+ *
+ * @param primitiveDef - type to add
+ */
+ public void addPrimitiveDef(PrimitiveDef primitiveDef)
+ {
+ if (primitiveDef != null)
+ {
+ primitiveDefMap.put(primitiveDef.getName(), primitiveDef);
+ }
+ }
+
+
+ /**
+ * Add a new CollectionDef to the archive.
+ *
+ * @param collectionDef - type to add
+ */
+ public void addCollectionDef(CollectionDef collectionDef)
+ {
+ if (collectionDef != null)
+ {
+ collectionDefMap.put(collectionDef.getName(), collectionDef);
+ }
+ }
+
+
+ /**
+ * Add a new EnumDef to the archive.
+ *
+ * @param enumDef - type to add
+ */
+ public void addEnumDef(EnumDef enumDef)
+ {
+ if (enumDef != null)
+ {
+ enumDefMap.put(enumDef.getName(), enumDef);
+ }
+ }
+
+
+ /**
+ * Add a new ClassificationDef to the archive.
+ *
+ * @param classificationDef - type to add
+ */
+ public void addClassificationDef(ClassificationDef classificationDef)
+ {
+ if (classificationDef != null)
+ {
+ classificationDefMap.put(classificationDef.getName(), classificationDef);
+ }
+ }
+
+
+ /**
+ * Add a new EntityDef to the archive.
+ *
+ * @param entityDef - type to add
+ */
+ public void addEntityDef(EntityDef entityDef)
+ {
+ if (entityDef != null)
+ {
+ EntityDef previousDef = entityDefMap.put(entityDef.getName(), entityDef);
+
+ if (previousDef != null)
+ {
+ // TODO log a duplicate
+ }
+ }
+ }
+
+
+ /**
+ * Retrieve the entityDef - or null if it is not defined.
+ *
+ * @param entityDefName - name of the entity
+ * @return the retrieved Entity def
+ */
+ public EntityDef getEntityDef(String entityDefName)
+ {
+ if (entityDefName != null)
+ {
+ EntityDef retrievedEntityDef = entityDefMap.get(entityDefName);
+
+ if (retrievedEntityDef != null)
+ {
+ return retrievedEntityDef;
+ }
+ else
+ {
+ // TODO Throw exception
+ return null; /* temporary */
+ }
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+
+ /**
+ * Add a new RelationshipDef to the archive.
+ *
+ * @param relationshipDef - type to add
+ */
+ public void addRelationshipDef(RelationshipDef relationshipDef)
+ {
+ if (relationshipDef != null)
+ {
+ relationshipDefMap.put(relationshipDef.getName(), relationshipDef);
+ }
+ }
+
+
+ /**
+ * Add a new entity to the archive.
+ *
+ * @param entity - instance to add
+ */
+ public void addEntity(EntityDetail entity)
+ {
+ if (entity != null)
+ {
+ entityDetailMap.put(entity.getGUID(), entity);
+ }
+ }
+
+
+ /**
+ * Add a new relationship to the archive.
+ *
+ * @param relationship - instance to add
+ */
+ public void addRelationship(Relationship relationship)
+ {
+ if (relationship != null)
+ {
+ relationshipMap.put(relationship.getGUID(), relationship);
+ }
+ }
+
+
+ /**
+ * Once the content of the archive has been added to the archive builder, an archive object can be retrieved.
+ *
+ * @return open metadata archive object with all of the supplied content in it.
+ */
+ public OpenMetadataArchive getOpenMetadataArchive()
+ {
+ OpenMetadataArchive archive = new OpenMetadataArchive();
+
+ /*
+ * Set up the archive properties
+ */
+ archive.setArchiveProperties(this.archiveProperties);
+
+ /*
+ * Set up the TypeStore. The types are added in a strict order to ensure that the dependencies are resolved.
+ */
+ ArrayList<AttributeTypeDef> attributeTypeDefs = null;
+ ArrayList<TypeDef> typeDefs = new ArrayList<>();
+ ArrayList<TypeDefPatch> typeDefPatches = new ArrayList<>();
+
+ if (! primitiveDefMap.isEmpty())
+ {
+ attributeTypeDefs.addAll(primitiveDefMap.values());
+ }
+ if (! collectionDefMap.isEmpty())
+ {
+ attributeTypeDefs.addAll(collectionDefMap.values());
+ }
+ if (! enumDefMap.isEmpty())
+ {
+ attributeTypeDefs.addAll(enumDefMap.values());
+ }
+ if (! entityDefMap.isEmpty())
+ {
+ typeDefs.addAll(entityDefMap.values());
+ }
+ if (! classificationDefMap.isEmpty())
+ {
+ typeDefs.addAll(classificationDefMap.values());
+ }
+ if (! relationshipDefMap.isEmpty())
+ {
+ typeDefs.addAll(relationshipDefMap.values());
+ }
+
+ if (! typeDefPatchMap.isEmpty())
+ {
+ typeDefPatches.addAll(typeDefPatchMap.values());
+ }
+
+ if ((! typeDefs.isEmpty()) || (! typeDefPatches.isEmpty()))
+ {
+ OpenMetadataArchiveTypeStore typeStore = new OpenMetadataArchiveTypeStore();
+
+ if (! attributeTypeDefs.isEmpty())
+ {
+ typeStore.setAttributeTypeDefs(attributeTypeDefs);
+ }
+
+ if (! typeDefs.isEmpty())
+ {
+ typeStore.setNewTypeDefs(typeDefs);
+ }
+
+ if (! typeDefPatches.isEmpty())
+ {
+ typeStore.setTypeDefPatches(typeDefPatches);
+ }
+
+ archive.setArchiveTypeStore(typeStore);
+ }
+
+
+ /*
+ * Finally set up the instance store
+ */
+ ArrayList<EntityDetail> entities = new ArrayList<>();
+ ArrayList<Relationship> relationships = new ArrayList<>();
+
+ if (! entityDetailMap.isEmpty())
+ {
+ entities.addAll(entityDetailMap.values());
+ }
+ if (! relationshipMap.isEmpty())
+ {
+ relationships.addAll(relationshipMap.values());
+ }
+
+ if ((! entities.isEmpty()) || (! relationships.isEmpty()))
+ {
+ OpenMetadataArchiveInstanceStore instanceStore = new OpenMetadataArchiveInstanceStore();
+
+ if (! entities.isEmpty())
+ {
+ instanceStore.setEntities(entities);
+ }
+
+ if (! relationships.isEmpty())
+ {
+ instanceStore.setRelationships(relationships);
+ }
+
+ archive.setArchiveInstanceStore(instanceStore);
+ }
+
+ return archive;
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/OMRSArchiveManager.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/OMRSArchiveManager.java b/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/OMRSArchiveManager.java
new file mode 100644
index 0000000..437bd7b
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/OMRSArchiveManager.java
@@ -0,0 +1,348 @@
+/*
+ * 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;
+
+import org.apache.atlas.omrs.archivemanager.opentypes.OpenMetadataTypesArchive;
+import org.apache.atlas.omrs.archivemanager.store.OpenMetadataArchiveStore;
+import org.apache.atlas.omrs.archivemanager.properties.OpenMetadataArchive;
+import org.apache.atlas.omrs.archivemanager.properties.OpenMetadataArchiveInstanceStore;
+import org.apache.atlas.omrs.archivemanager.properties.OpenMetadataArchiveProperties;
+import org.apache.atlas.omrs.archivemanager.properties.OpenMetadataArchiveTypeStore;
+import org.apache.atlas.omrs.auditlog.OMRSAuditLog;
+import org.apache.atlas.omrs.auditlog.OMRSAuditingComponent;
+import org.apache.atlas.omrs.eventmanagement.events.OMRSInstanceEventProcessor;
+import org.apache.atlas.omrs.eventmanagement.events.OMRSTypeDefEventProcessor;
+import org.apache.atlas.omrs.localrepository.repositorycontentmanager.OMRSRepositoryContentManager;
+import org.apache.atlas.omrs.metadatacollection.properties.instances.EntityDetail;
+import org.apache.atlas.omrs.metadatacollection.properties.instances.Relationship;
+import org.apache.atlas.omrs.metadatacollection.properties.typedefs.TypeDef;
+import org.apache.atlas.omrs.metadatacollection.properties.typedefs.TypeDefPatch;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+
+/**
+ * OMRSArchiveManager manages the loading and unloading of open metadata archives from the local OMRS repository.
+ * An open metadata archive provides pre-built definitions for types and metadata instances.
+ */
+public class OMRSArchiveManager
+{
+ ArrayList<OpenMetadataArchiveStore> openMetadataArchiveStores = new ArrayList<>();
+ OMRSRepositoryContentManager repositoryContentManager = null;
+ OMRSInstanceEventProcessor localInstanceEventProcessor = null;
+
+
+ /*
+ * The audit log provides a verifiable record of the open metadata archives that have been loaded into
+ * the open metadata repository. The Logger is for standard debug.
+ */
+ private static final OMRSAuditLog auditLog = new OMRSAuditLog(OMRSAuditingComponent.ARCHIVE_MANAGER);
+ private static final Logger log = LoggerFactory.getLogger(OMRSArchiveManager.class);
+
+
+ /**
+ * Constructor to save the initial list of open metadata archives from the server startup configuration.
+ * These will be processed as soon as the event processors are supplied from the local repository.
+ *
+ * @param startUpOpenMetadataArchives - initial list of open metadata archives provided in startup configuration
+ */
+ public OMRSArchiveManager(ArrayList<OpenMetadataArchiveStore> startUpOpenMetadataArchives)
+ {
+ if (startUpOpenMetadataArchives != null)
+ {
+ for (OpenMetadataArchiveStore archiveStore : startUpOpenMetadataArchives)
+ {
+ this.openMetadataArchiveStores.add(archiveStore);
+ }
+ }
+ }
+
+
+ /**
+ * Close down any open archives.
+ */
+ public void close()
+ {
+ for (OpenMetadataArchiveStore archiveStore : openMetadataArchiveStores)
+ {
+ if (archiveStore != null)
+ {
+ archiveStore.closeArchive();
+ }
+ }
+ }
+
+
+ /**
+ * The local repository is accessed through its inbound event processors. A server will always have
+ * the local Content Manager and TypeDef Processor but the local Instance Processor is only available
+ * if the local server has a metadata repository defined.
+ *
+ * @param repositoryContentManager - typeDef processor for the local repository
+ * @param instanceProcessor - instance processor for the local repository
+ */
+ public void setLocalRepository(OMRSRepositoryContentManager repositoryContentManager,
+ OMRSInstanceEventProcessor instanceProcessor)
+ {
+ this.repositoryContentManager = repositoryContentManager;
+ this.localInstanceEventProcessor = instanceProcessor;
+
+ /*
+ * The repository content manager is seeded with all of the open metadata types.
+ */
+ processOpenMetadataTypes();
+
+ /*
+ * Once the open metadata types are in place, the archive stores are processed.
+ */
+ for (OpenMetadataArchiveStore archiveStore : this.openMetadataArchiveStores)
+ {
+ processOpenMetadataArchiveStore(archiveStore, repositoryContentManager, instanceProcessor);
+ }
+ }
+
+
+ /**
+ * Add a new archive to the local repository. If there are problems processing the archive, an exception is thrown.
+ * This method allows archives to be loaded into a running server.
+ *
+ * @param archiveStore - new open metadata archive to process
+ */
+ public void addOpenMetadataArchive(OpenMetadataArchiveStore archiveStore)
+ {
+ this.processOpenMetadataArchiveStore(archiveStore, repositoryContentManager, localInstanceEventProcessor);
+ this.openMetadataArchiveStores.add(archiveStore);
+ }
+
+
+ /**
+ * Unpack and process the contents an open metadata archive store, passing its contents to the local
+ * repository (if it exists).
+ */
+ private void processOpenMetadataTypes()
+ {
+ OpenMetadataTypesArchive openMetadataTypesArchive = new OpenMetadataTypesArchive();
+ OpenMetadataArchive openMetadataTypes = openMetadataTypesArchive.getOpenMetadataArchive();
+
+ repositoryContentManager.setOpenMetadataTypesOriginGUID(openMetadataTypesArchive.getArchiveGUID());
+ processOpenMetadataArchive(openMetadataTypes, repositoryContentManager, localInstanceEventProcessor);
+ }
+
+ /**
+ * Unpack and process the contents an open metadata archive store, passing its contents to the local
+ * repository (if it exists).
+ *
+ * @param archiveStore - open metadata archive store to process
+ */
+ private void processOpenMetadataArchiveStore(OpenMetadataArchiveStore archiveStore,
+ OMRSTypeDefEventProcessor typeDefProcessor,
+ OMRSInstanceEventProcessor instanceProcessor)
+ {
+ if (archiveStore != null)
+ {
+ /*
+ * Each archive store has a header, a section of new type definitions (TypeDefs) and a section of
+ * metadata instances.
+ */
+ OpenMetadataArchive archiveContent = archiveStore.getArchiveContents();
+
+ if (archiveContent == null)
+ {
+ // TODO log Error
+ }
+ else
+ {
+ processOpenMetadataArchive(archiveContent, typeDefProcessor, instanceProcessor);
+ }
+ }
+ else
+ {
+ // TODO log empty Archive store
+ }
+ }
+
+
+ /**
+ * Step through the content of an open metadata archive, passing its contents to the local repository (if it
+ * exists).
+ *
+ * @param archiveContent - open metadata archive to process
+ */
+ private void processOpenMetadataArchive(OpenMetadataArchive archiveContent,
+ OMRSTypeDefEventProcessor typeDefProcessor,
+ OMRSInstanceEventProcessor instanceProcessor)
+ {
+ OpenMetadataArchiveProperties archiveProperties = archiveContent.getArchiveProperties();
+ OpenMetadataArchiveTypeStore archiveTypeStore = archiveContent.getArchiveTypeStore();
+ OpenMetadataArchiveInstanceStore archiveInstanceStore = archiveContent.getArchiveInstanceStore();
+
+ // TODO Log that the open metadata archive is being processed
+
+ if (archiveProperties != null)
+ {
+ if (archiveTypeStore != null)
+ {
+ this.processTypeDefStore(archiveProperties, archiveTypeStore, typeDefProcessor);
+ }
+
+ if (archiveInstanceStore != null)
+ {
+ this.processInstanceStore(archiveProperties, archiveInstanceStore, instanceProcessor);
+ }
+ }
+ else
+ {
+ // TODO Log that the archive is invalid
+ }
+
+
+ // TODO log that processing complete
+ }
+
+
+ /**
+ * The TypeStore is in two parts. First there is an optional list of patches to existing TypeDefs.
+ * Then an optional list of new TypeDefs. It is possible that this archive has been processed before
+ * and so any duplicates detected are ignored. However, conflicting TypeDefs are detected.
+ * Any problems found in applying the archive contents are recorded on the audit log.
+ *
+ * @param archiveProperties - properties of the archive used for logging
+ * @param archiveTypeStore - TypeStore from the archive
+ */
+ private void processTypeDefStore(OpenMetadataArchiveProperties archiveProperties,
+ OpenMetadataArchiveTypeStore archiveTypeStore,
+ OMRSTypeDefEventProcessor typeDefProcessor)
+ {
+ ArrayList<TypeDefPatch> typeDefPatches = archiveTypeStore.getTypeDefPatches();
+ ArrayList<TypeDef> newTypeDefs = archiveTypeStore.getNewTypeDefs();
+
+ if (typeDefProcessor != null)
+ {
+ String sourceName = OMRSAuditingComponent.ARCHIVE_MANAGER.getComponentName();
+ String originatorMetadataCollectionId = archiveProperties.getArchiveGUID();
+ String originatorServerName = archiveProperties.getArchiveName();
+ String originatorServerType = null;
+ String originatorOrganizationName = archiveProperties.getOriginatorName();
+
+ if (archiveProperties.getArchiveType() != null)
+ {
+ originatorServerType = archiveProperties.getArchiveType().getArchiveTypeName();
+ }
+
+ if (typeDefPatches != null)
+ {
+ for (TypeDefPatch typeDefPatch : typeDefPatches)
+ {
+ if (typeDefPatch != null)
+ {
+ typeDefProcessor.processUpdatedTypeDefEvent(sourceName,
+ originatorMetadataCollectionId,
+ originatorServerName,
+ originatorServerType,
+ originatorOrganizationName,
+ typeDefPatch);
+ }
+ }
+ }
+
+ if (newTypeDefs != null)
+ {
+ for (TypeDef newTypeDef : newTypeDefs)
+ {
+ if (newTypeDef != null)
+ {
+ typeDefProcessor.processNewTypeDefEvent(sourceName,
+ originatorMetadataCollectionId,
+ originatorServerName,
+ originatorServerType,
+ originatorOrganizationName,
+ newTypeDef);
+ }
+ }
+ }
+ }
+ }
+
+
+ /**
+ * The InstanceStore is in two parts - an optional list of entities followed by an optional list
+ * of relationships. It is possible that this archive has been processed before
+ * and so any duplicates detected are ignored. However, conflicting instances are detected.
+ * Any problems found in applying the archive contents are recorded on the audit log.
+ *
+ * @param archiveProperties - properties describing the archive used in logging
+ * @param archiveInstanceStore - the instance store to process
+ * @param instanceProcessor - the processor to add the instances to the local repository. It may be null
+ * if there is no local repository configured for this server.
+ */
+ private void processInstanceStore(OpenMetadataArchiveProperties archiveProperties,
+ OpenMetadataArchiveInstanceStore archiveInstanceStore,
+ OMRSInstanceEventProcessor instanceProcessor)
+ {
+ ArrayList<EntityDetail> entities = archiveInstanceStore.getEntities();
+ ArrayList<Relationship> relationships = archiveInstanceStore.getRelationships();
+
+ if (instanceProcessor != null)
+ {
+ String sourceName = OMRSAuditingComponent.ARCHIVE_MANAGER.getComponentName();
+ String originatorMetadataCollectionId = archiveProperties.getArchiveGUID();
+ String originatorServerName = archiveProperties.getArchiveName();
+ String originatorServerType = null;
+ String originatorOrganizationName = archiveProperties.getOriginatorName();
+
+ if (archiveProperties.getArchiveType() != null)
+ {
+ originatorServerType = archiveProperties.getArchiveType().getArchiveTypeName();
+ }
+
+ if (entities != null)
+ {
+ for (EntityDetail entity : entities)
+ {
+ if (entity != null)
+ {
+ instanceProcessor.processNewEntityEvent(sourceName,
+ originatorMetadataCollectionId,
+ originatorServerName,
+ originatorServerType,
+ originatorOrganizationName,
+ entity);
+ }
+ }
+ }
+
+
+ if (relationships != null)
+ {
+ for (Relationship relationship : relationships)
+ {
+ if (relationship != null)
+ {
+ instanceProcessor.processNewRelationshipEvent(sourceName,
+ originatorMetadataCollectionId,
+ originatorServerName,
+ originatorServerType,
+ originatorOrganizationName,
+ relationship);
+ }
+ }
+ }
+ }
+ }
+}
[10/30] atlas git commit: ATLAS-2246: OMRS Connector API plus REST
and IGC Connector skeleton - 15th February 2018
Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositorycontentmanager/OMRSRepositoryContentManager.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositorycontentmanager/OMRSRepositoryContentManager.java b/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositorycontentmanager/OMRSRepositoryContentManager.java
new file mode 100644
index 0000000..c146be6
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositorycontentmanager/OMRSRepositoryContentManager.java
@@ -0,0 +1,2056 @@
+/*
+ * 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.localrepository.repositorycontentmanager;
+
+import org.apache.atlas.omrs.auditlog.OMRSAuditCode;
+import org.apache.atlas.omrs.auditlog.OMRSAuditLog;
+import org.apache.atlas.omrs.auditlog.OMRSAuditingComponent;
+import org.apache.atlas.omrs.eventmanagement.*;
+import org.apache.atlas.omrs.eventmanagement.events.OMRSTypeDefEventProcessor;
+import org.apache.atlas.omrs.ffdc.OMRSErrorCode;
+import org.apache.atlas.omrs.ffdc.exception.*;
+import org.apache.atlas.omrs.localrepository.repositoryconnector.LocalOMRSRepositoryConnector;
+import org.apache.atlas.omrs.metadatacollection.OMRSMetadataCollection;
+import org.apache.atlas.omrs.metadatacollection.properties.instances.EntityDetail;
+import org.apache.atlas.omrs.metadatacollection.properties.instances.InstanceStatus;
+import org.apache.atlas.omrs.metadatacollection.properties.instances.InstanceType;
+import org.apache.atlas.omrs.metadatacollection.properties.instances.Relationship;
+import org.apache.atlas.omrs.metadatacollection.properties.typedefs.*;
+import org.apache.atlas.omrs.metadatacollection.repositoryconnector.OMRSRepositoryConnector;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * OMRSRepositoryContentManager supports an in-memory cache of TypeDefs for the local server. It is used by the OMRS
+ * components for constructing metadata instances with valid types. It ensures that the TypeDefs used in other
+ * members of the open metadata repository cohorts that the local server is also a member of are consistent with the
+ * local repository.
+ *
+ * OMRSRepositoryContentManager plays a central role in ensuring the integrity of the metadata in the local repository.
+ * It is called from multiple components at different points in the processing. It presents a different interface
+ * to each of these components that is specialized to their needs.
+ * <ul>
+ * <li>
+ * OMRSTypeDefEventProcessor - processes inbound events from remote members of the open metadata
+ * repository cohorts that the local repository is connected to. These incoming TypeDef events need to
+ * be validated against the types used locally and either saved or discarded depending on the exchange rule
+ * setting.
+ * </li>
+ * <li>
+ * OMRSTypeDefManager - provides maintenance methods for managing the TypeDefs in the local cache.
+ * </li>
+ * <li>
+ * OMRSTypeDefHelper - provides methods to help OMRS connectors and adapters manage TypeDefs.
+ * </li>
+ * <li>
+ * OMRSTypeDefValidator - provides methods to validate TypeDefs.
+ * </li>
+ * <li>
+ * OMRSInstanceValidator - provides methods to help validate instances.
+ * </li>
+ * </ul>
+ */
+public class OMRSRepositoryContentManager implements OMRSTypeDefEventProcessor,
+ OMRSTypeDefManager,
+ OMRSTypeDefHelper,
+ OMRSTypeDefValidator,
+ OMRSInstanceValidator
+{
+ private String localMetadataCollectionId = null;
+ private LocalOMRSRepositoryConnector localRepositoryConnector = null;
+ private OMRSRepositoryEventManager outboundRepositoryEventManager = null;
+ private OMRSRepositoryConnector realLocalConnector = null;
+ private OMRSRepositoryEventExchangeRule saveExchangeRule = null;
+ private String openTypesOriginGUID = null;
+ private HashMap<String, TypeDef> knownTypes = new HashMap<>();
+ private HashMap<String, AttributeTypeDef> knownAttributeTypes = new HashMap<>();
+ private HashMap<String, TypeDef> activeTypes = null;
+ private HashMap<String, AttributeTypeDef> activeAttributeTypes = null;
+
+
+
+ /*
+ * The audit log provides a verifiable record of the open metadata archives that have been loaded into
+ * the open metadata repository. The Logger is for standard debug.
+ */
+ private static final OMRSAuditLog auditLog = new OMRSAuditLog(OMRSAuditingComponent.TYPEDEF_MANAGER);
+ private static final Logger log = LoggerFactory.getLogger(OMRSRepositoryContentManager.class);
+
+
+
+ /**
+ * Default constructor
+ */
+ public OMRSRepositoryContentManager()
+ {
+
+ }
+
+
+ /**
+ * Saves all of the information necessary to process incoming TypeDef events.
+ *
+ * @param localRepositoryConnector - connector to the local repository
+ * @param realLocalConnector - connector to the real local repository - used for processing TypeDef events
+ * @param saveExchangeRule - rule that determines which events to process.
+ * @param outboundRepositoryEventManager - event manager to call for outbound events - used to send out reports
+ * of conflicting TypeDefs
+ */
+ public void setupEventProcessor(LocalOMRSRepositoryConnector localRepositoryConnector,
+ OMRSRepositoryConnector realLocalConnector,
+ OMRSRepositoryEventExchangeRule saveExchangeRule,
+ OMRSRepositoryEventManager outboundRepositoryEventManager)
+ {
+ this.localRepositoryConnector = localRepositoryConnector;
+ this.realLocalConnector = realLocalConnector;
+ this.saveExchangeRule = saveExchangeRule;
+ this.localMetadataCollectionId = localRepositoryConnector.getMetadataCollectionId();
+ this.outboundRepositoryEventManager = outboundRepositoryEventManager;
+ }
+
+
+ /**
+ * Save the unique identifier of the open metadata archive. This is stored in the origin property of
+ * all of the open metadata types. It is needed to support the isOpenType() method.
+ *
+ * @param openMetadataTypesGUID - unique identifier for the open metadata type's archive
+ */
+ public void setOpenMetadataTypesOriginGUID(String openMetadataTypesGUID)
+ {
+ openTypesOriginGUID = openMetadataTypesGUID;
+ }
+
+
+ /*
+ * ========================
+ * OMRSTypeDefManager
+ */
+
+ /**
+ * Cache a definition of a new TypeDef. This method assumes the TypeDef has been successfully added to the
+ * local repository already and all that is needed is to maintain the cached list of types
+ *
+ * @param sourceName - source of the request (used for logging)
+ * @param newTypeDef - TypeDef structure describing the new TypeDef.
+ */
+ public void addTypeDef(String sourceName, TypeDef newTypeDef)
+ {
+ if (this.validTypeDef(sourceName, newTypeDef))
+ {
+ knownTypes.put(newTypeDef.getName(), newTypeDef);
+ if (localRepositoryConnector != null)
+ {
+ activeTypes.put(newTypeDef.getName(), newTypeDef);
+
+ if (log.isDebugEnabled())
+ {
+ log.debug("New Active Type " + newTypeDef.getName() + " from " + sourceName, newTypeDef);
+ }
+
+ // TODO log new active type
+ }
+ }
+ }
+
+
+ /**
+ * Cache a definition of a new AttributeTypeDef.
+ *
+ * @param sourceName - source of the request (used for logging)
+ * @param newAttributeTypeDef - AttributeTypeDef structure describing the new TypeDef.
+ */
+ public void addAttributeTypeDef(String sourceName, AttributeTypeDef newAttributeTypeDef)
+ {
+
+ }
+
+ /**
+ * Update one or more properties of a cached TypeDef. This method assumes the TypeDef has been successfully
+ * updated in the local repository already and all that is needed is to maintain the cached list of types
+ *
+ * @param sourceName - source of the request (used for logging)
+ * @param typeDef - TypeDef structure.
+ */
+ public void updateTypeDef(String sourceName, TypeDef typeDef)
+ {
+ if (this.validTypeDef(sourceName, typeDef))
+ {
+ knownTypes.put(typeDef.getName(), typeDef);
+ if (localRepositoryConnector != null)
+ {
+ activeTypes.put(typeDef.getName(), typeDef);
+
+ if (log.isDebugEnabled())
+ {
+ log.debug("Updated Active Type " + typeDef.getName() + " from " + sourceName, typeDef);
+ }
+ }
+ }
+ }
+
+
+ /**
+ * Delete a cached TypeDef.
+ *
+ * @param sourceName - source of the request (used for logging)
+ * @param obsoleteTypeDefGUID - String unique identifier for the TypeDef.
+ * @param obsoleteTypeDefName - String unique name for the TypeDef.
+ */
+ public void deleteTypeDef(String sourceName,
+ String obsoleteTypeDefGUID,
+ String obsoleteTypeDefName)
+ {
+ if (this.validTypeId(sourceName, obsoleteTypeDefGUID, obsoleteTypeDefName))
+ {
+ knownTypes.remove(obsoleteTypeDefName);
+
+ if (localRepositoryConnector != null)
+ {
+ activeTypes.remove(obsoleteTypeDefName);
+
+ if (log.isDebugEnabled())
+ {
+ log.debug("Deleted Active Type " + obsoleteTypeDefName + " from " + sourceName);
+ }
+ }
+ }
+ }
+
+
+ /**
+ * Delete a cached AttributeTypeDef.
+ *
+ * @param sourceName - source of the request (used for logging)
+ * @param obsoleteTypeDefGUID - String unique identifier for the AttributeTypeDef.
+ * @param obsoleteTypeDefName - String unique name for the AttributeTypeDef.
+ */
+ public void deleteAttributeTypeDef(String sourceName,
+ String obsoleteTypeDefGUID,
+ String obsoleteTypeDefName)
+ {
+
+ }
+
+
+ /**
+ * Change the identifiers for a TypeDef.
+ *
+ * @param sourceName - source of the request (used for logging).
+ * @param originalTypeDefGUID - TypeDef's original unique identifier.
+ * @param originalTypeDefName - TypeDef's original unique name.
+ * @param newTypeDef - updated TypeDef with new identifiers.
+ */
+ public void reIdentifyTypeDef(String sourceName,
+ String originalTypeDefGUID,
+ String originalTypeDefName,
+ TypeDef newTypeDef)
+ {
+ // TODO
+ }
+
+
+ /**
+ * Change the identifiers for an AttributeTypeDef.
+ *
+ * @param sourceName - source of the request (used for logging).
+ * @param originalAttributeTypeDefGUID - AttributeTypeDef's original unique identifier.
+ * @param originalAttributeTypeDefName - AttributeTypeDef's original unique name.
+ * @param newAttributeTypeDef - updated AttributeTypeDef with new identifiers
+ */
+ public void reIdentifyAttributeTypeDef(String sourceName,
+ String originalAttributeTypeDefGUID,
+ String originalAttributeTypeDefName,
+ AttributeTypeDef newAttributeTypeDef)
+ {
+ // TODO
+ }
+
+
+ /**
+ * Return the list of property names defined for this TypeDef.
+ *
+ * @param sourceName - source of the request (used for logging)
+ * @param typeDef - type definition to work with.
+ * @return list of String property names
+ * @throws TypeErrorException - there is an issue with the TypeDef.
+ */
+ private ArrayList<String> getPropertyNames(String sourceName, TypeDef typeDef) throws TypeErrorException
+ {
+ final String methodName = "getPropertyNames()";
+ ArrayList<String> propertyNames = null;
+
+ if (validTypeDef(sourceName, typeDef))
+ {
+ ArrayList<TypeDefAttribute> propertiesDefinition = typeDef.getPropertiesDefinition();
+
+ if ((propertiesDefinition != null) && (propertiesDefinition.size() > 0))
+ {
+ propertyNames = new ArrayList<>();
+
+ for (TypeDefAttribute propertyDefinition : propertiesDefinition)
+ {
+ if (propertyDefinition != null)
+ {
+ String propertyName = propertyDefinition.getAttributeName();
+
+ if (propertyName != null)
+ {
+ if (log.isDebugEnabled())
+ {
+ log.debug(typeDef.getName() + " from " + sourceName + " has property " + propertyName);
+ }
+ propertyNames.add(propertyName);
+ }
+ else
+ {
+ OMRSErrorCode errorCode = OMRSErrorCode.BAD_TYPEDEF_ATTRIBUTE_NAME;
+ String errorMessage = errorCode.getErrorMessageId()
+ + errorCode.getFormattedErrorMessage(sourceName);
+
+ throw new TypeErrorException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ methodName,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+ }
+ else
+ {
+ OMRSErrorCode errorCode = OMRSErrorCode.NULL_TYPEDEF_ATTRIBUTE;
+ String errorMessage = errorCode.getErrorMessageId()
+ + errorCode.getFormattedErrorMessage(sourceName);
+
+ throw new TypeErrorException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ methodName,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+ }
+
+ /*
+ * If no property names have been extracted then remove the array.
+ */
+ if (propertyNames.size() == 0)
+ {
+ propertyNames = null;
+ }
+ }
+ }
+ else
+ {
+ OMRSErrorCode errorCode = OMRSErrorCode.BAD_TYPEDEF;
+ String errorMessage = errorCode.getErrorMessageId()
+ + errorCode.getFormattedErrorMessage(sourceName);
+
+ throw new TypeErrorException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ methodName,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+
+ return propertyNames;
+ }
+
+
+ /**
+ * Return identifiers for the TypeDef that matches the supplied type name. If the type name is not recognized,
+ * null is returned.
+ *
+ * @param sourceName - source of the request (used for logging)
+ * @param category - category of the instance type required.
+ * @param typeName - String type name.
+ * @return InstanceType object containing TypeDef properties such as unique identifier (guid),
+ * typeDef name and version name
+ * @throws TypeErrorException - the type name is not a recognized type or is of the wrong category or there is
+ * a problem with the cached TypeDef.
+ */
+ public InstanceType getInstanceType(String sourceName,
+ TypeDefCategory category,
+ String typeName) throws TypeErrorException
+ {
+ final String methodName = "getInstanceType()";
+
+ if (isValidTypeCategory(sourceName, category, typeName))
+ {
+ TypeDef typeDef = knownTypes.get(typeName);
+
+ if (typeDef != null)
+ {
+ InstanceType instanceType = new InstanceType();
+
+ instanceType.setTypeDefCategory(category);
+ instanceType.setTypeDefGUID(typeDef.getGUID());
+ instanceType.setTypeDefName(typeDef.getName());
+ instanceType.setTypeDefVersion(typeDef.getVersion());
+ instanceType.setTypeDefDescription(typeDef.getDescription());
+ instanceType.setTypeDefDescriptionGUID(typeDef.getDescriptionGUID());
+
+ /*
+ * Extract the properties for this TypeDef. These will be augmented with property names
+ * from the super type(s).
+ */
+ ArrayList<String> propertyNames = this.getPropertyNames(sourceName, typeDef);
+
+ /*
+ * If propertyNames is null, it means the TypeDef has no attributes. However the superType
+ * may have attributes and so we need an array to accumulate the attributes into.
+ */
+ if (propertyNames == null)
+ {
+ propertyNames = new ArrayList<>();
+ }
+
+ /*
+ * Work up the TypeDef hierarchy extracting the property names and super type names.
+ */
+ ArrayList<TypeDefLink> superTypes = new ArrayList<>();
+ TypeDefLink superTypeLink = typeDef.getSuperType();
+
+ while (superTypeLink != null)
+ {
+ String superTypeName = superTypeLink.getName();
+
+ if (superTypeName != null)
+ {
+ if (log.isDebugEnabled())
+ {
+ log.debug(typeName + " from " + sourceName + " has super type " + superTypeName);
+ }
+
+ superTypes.add(superTypeLink);
+
+ TypeDef superTypeDef = knownTypes.get(superTypeName);
+
+ if (superTypeDef != null)
+ {
+ ArrayList<String> superTypePropertyNames = this.getPropertyNames(sourceName, superTypeDef);
+
+ if (superTypePropertyNames != null)
+ {
+ propertyNames.addAll(0, superTypePropertyNames);
+ }
+ }
+
+ superTypeLink = superTypeDef.getSuperType();
+ }
+ else
+ {
+ superTypeLink = null;
+ }
+ }
+
+ /*
+ * Make sure empty lists are converted to nulls
+ */
+
+ if (superTypes.size() > 0)
+ {
+ instanceType.setTypeDefSuperTypes(superTypes);
+ }
+
+ if (propertyNames.size() > 0)
+ {
+ instanceType.setValidInstanceProperties(propertyNames);
+ }
+ }
+ }
+ else
+ {
+ OMRSErrorCode errorCode = OMRSErrorCode.BAD_CATEGORY_FOR_TYPEDEF_ATTRIBUTE;
+ String errorMessage = errorCode.getErrorMessageId()
+ + errorCode.getFormattedErrorMessage(sourceName, typeName, category.getTypeName());
+
+ throw new TypeErrorException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ methodName,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+
+ return null;
+ }
+
+
+ /**
+ * Return a boolean indicating that the type name matches the category.
+ *
+ * @param sourceName - source of the request (used for logging)
+ * @param category - TypeDefCategory enum value to test
+ * @param typeName - type name to test
+ * @return - boolean flag indicating that the type name is of the specified category
+ * @throws TypeErrorException - the type name is not a recognized type or there is
+ * a problem with the cached TypeDef.
+ */
+ public boolean isValidTypeCategory(String sourceName,
+ TypeDefCategory category,
+ String typeName) throws TypeErrorException
+ {
+ if (category == null)
+ {
+ // TODO throw logic error
+ }
+
+ if (typeName == null)
+ {
+ // TODO throw logic error
+ }
+
+ TypeDef typeDef = knownTypes.get(typeName);
+
+ if (typeDef != null)
+ {
+ TypeDefCategory retrievedTypeDefCategory = typeDef.getCategory();
+
+ if (retrievedTypeDefCategory != null)
+ {
+ if (category.getTypeCode() == retrievedTypeDefCategory.getTypeCode())
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ else
+ {
+ // TODO Throw logic error
+ }
+ }
+
+ return false;
+ }
+
+
+ /**
+ * Return boolean indicating if a classification type can be applied to a specified entity. This
+ * uses the list of valid entity types located in the ClassificationDef.
+ *
+ * @param sourceName - source of the request (used for logging)
+ * @param classificationTypeName - name of the classification's type (ClassificationDef)
+ * @param entityTypeName - name of the entity's type (EntityDef)
+ * @return boolean indicating if the classification is valid for the entity.
+ */
+ public boolean isValidClassificationForEntity(String sourceName,
+ String classificationTypeName,
+ String entityTypeName)
+ {
+ try
+ {
+ if ((isValidTypeCategory(sourceName, TypeDefCategory.CLASSIFICATION_DEF, classificationTypeName)) &&
+ (isValidTypeCategory(sourceName, TypeDefCategory.ENTITY_DEF, entityTypeName)))
+ {
+ ClassificationDef classificationTypeDef = (ClassificationDef)knownTypes.get(classificationTypeName);
+
+ if (classificationTypeDef != null)
+ {
+ ArrayList<TypeDefLink> entityDefs = classificationTypeDef.getValidEntityDefs();
+
+ if (entityDefs == null)
+ {
+ /*
+ * The classification has no restrictions on which entities it can be attached to.
+ */
+ return true;
+ }
+ else
+ {
+ /*
+ * The classification can only be attached to the entities listed. Note an empty list
+ * means the classification can not be attached to any entity and it is effectively useless.
+ */
+ for (TypeDefLink allowedEntity : entityDefs)
+ {
+ if (allowedEntity != null)
+ {
+ if (entityTypeName.equals(allowedEntity.getName()))
+ {
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+ }
+ else
+ {
+ // TODO log audit record - logic error
+ return false;
+ }
+ }
+ else
+ {
+ return false;
+ }
+ }
+ catch (TypeErrorException typeError)
+ {
+ // TODO log audit record - invalid Types
+ return false;
+ }
+ catch (ClassCastException castError)
+ {
+ // TODO log audit record - logic error - category not matching TypeDef instance type
+ return false;
+ }
+ }
+
+
+ /**
+ * Return the list of valid InstanceStatus states that instances of this type can handle.
+ *
+ * @param sourceName - source of the request (used for logging)
+ * @param typeName - name of the type
+ * @return list of InstanceStatus enums
+ * @throws TypeErrorException - the type name is not recognized.
+ */
+ public ArrayList<InstanceStatus> getValidStatusList(String sourceName, String typeName) throws TypeErrorException
+ {
+ if (typeName == null)
+ {
+ // TODO throw TypeError Exception
+ }
+
+ TypeDef typeDef = knownTypes.get(typeName);
+
+ if (typeDef == null)
+ {
+ // TODO throw TypeError exception
+ }
+
+ return typeDef.getValidInstanceStatusList();
+ }
+
+
+ /**
+ * Return the initial status value to use for an instance of the supplied type.
+ *
+ * @param sourceName - source of the request (used for logging)
+ * @param typeName - name of the type to extract the initial status from.
+ * @return InstanceStatus enum
+ * @throws TypeErrorException - the type name is not recognized.
+ */
+ public InstanceStatus getInitialStatus(String sourceName, String typeName) throws TypeErrorException
+ {
+ if (typeName == null)
+ {
+ // TODO throw TypeError Exception
+ }
+
+ TypeDef typeDef = knownTypes.get(typeName);
+
+ if (typeDef == null)
+ {
+ // TODO throw TypeError exception
+ }
+
+ return typeDef.getInitialStatus();
+ }
+
+
+ /**
+ * Return the URL string to use for direct access to the metadata instance. This can be used for
+ * entities and relationships. However, not all servers support direct access, in which case, this
+ * URL is null.
+ *
+ * @param sourceName - source of the request (used for logging)
+ * @param guid - unique identifier for the instance.
+ * @return String URL with placeholder for variables such as userId.
+ */
+ public String getInstanceURL(String sourceName, String guid)
+ {
+ // TODO Need to work out what instance URL's look like for OMRS instances. These URLs will be supported
+ // TODO by the REST API
+ return null;
+ }
+
+
+ /*
+ * ========================
+ * OMRSTypeDefHelper
+ */
+
+ /**
+ * Return the TypeDef identified by the name supplied by the caller. This is used in the connectors when
+ * validating the actual types of the repository with the known open metadata types - looking specifically
+ * for types of the same name but with different content.
+ *
+ * @param sourceName - source of the request (used for logging)
+ * @param typeDefName - unique name for the TypeDef
+ * @return TypeDef object or null if TypeDef is not known.
+ */
+ public TypeDef getTypeDefByName (String sourceName,
+ String typeDefName)
+ {
+ return knownTypes.get(typeDefName);
+ }
+
+
+ /**
+ * Return the AttributeTypeDef identified by the name supplied by the caller. This is used in the connectors when
+ * validating the actual types of the repository with the known open metadata types - looking specifically
+ * for types of the same name but with different content.
+ *
+ * @param sourceName - source of the request (used for logging)
+ * @param attributeTypeDefName - unique name for the TypeDef
+ * @return AttributeTypeDef object or null if AttributeTypeDef is not known.
+ */
+ public AttributeTypeDef getAttributeTypeDefByName (String sourceName,
+ String attributeTypeDefName)
+ {
+ return knownAttributeTypes.get(attributeTypeDefName);
+ }
+
+
+ /**
+ * Return the TypeDef identified by the guid and name supplied by the caller. This call is used when
+ * retrieving a type that should exist. For example, retrieving the type of a metadata instance.
+ *
+ * @param sourceName - source of the request (used for logging)
+ * @param typeDefGUID - unique identifier for the TypeDef
+ * @param typeDefName - unique name for the TypeDef
+ * @return TypeDef object
+ * @throws TypeErrorException - unknown or invalid type
+ */
+ public TypeDef getTypeDef (String sourceName,
+ String typeDefGUID,
+ String typeDefName) throws TypeErrorException
+ {
+ if (validTypeId(sourceName, typeDefGUID, typeDefName))
+ {
+ return knownTypes.get(typeDefName);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+
+ /**
+ * Return the AttributeTypeDef identified by the guid and name supplied by the caller. This call is used when
+ * retrieving a type that should exist. For example, retrieving the type definition of a metadata instance's
+ * property.
+ *
+ * @param sourceName - source of the request (used for logging)
+ * @param attributeTypeDefGUID - unique identifier for the AttributeTypeDef
+ * @param attributeTypeDefName - unique name for the AttributeTypeDef
+ * @return TypeDef object
+ * @throws TypeErrorException - unknown or invalid type
+ */
+ public AttributeTypeDef getAttributeTypeDef (String sourceName,
+ String attributeTypeDefGUID,
+ String attributeTypeDefName) throws TypeErrorException
+ {
+ return null;
+ }
+
+
+ /**
+ * Returns an updated TypeDef that has had the supplied patch applied. It throws an exception if any part of
+ * the patch is incompatible with the original TypeDef. For example, if there is a mismatch between
+ * the type or version that either represents.
+ *
+ * @param sourceName - source of the TypeDef (used for logging)
+ * @param typeDefPatch - patch to apply
+ * @return updated TypeDef
+ * @throws PatchErrorException - the patch is either badly formatted, or does not apply to the supplied TypeDef
+ */
+ public TypeDef applyPatch(String sourceName, TypeDefPatch typeDefPatch) throws PatchErrorException
+ {
+ TypeDef originalTypeDef = null;
+ TypeDef clonedTypeDef = null;
+ TypeDef updatedTypeDef = null;
+
+ /*
+ * Begin with simple validation of the typeDef patch.
+ */
+ if (typeDefPatch != null)
+ {
+ // TODO patch error
+ }
+
+ long newVersion = typeDefPatch.getUpdateToVersion();
+ if (newVersion <= typeDefPatch.getApplyToVersion())
+ {
+ // TODO PatchError
+ }
+
+ TypeDefPatchAction patchAction = typeDefPatch.getAction();
+ if (patchAction == null)
+ {
+ // TODO patch error
+ }
+
+ /*
+ * Locate the current definition for the TypeDef
+ */
+ try
+ {
+ originalTypeDef = this.getTypeDef(sourceName, typeDefPatch.getTypeDefGUID(), typeDefPatch.getTypeName());
+ }
+ catch (TypeErrorException typeError)
+ {
+ // TODO - wrap TypeError in Patch Error
+ }
+
+ /*
+ * Is the version compatible?
+ */
+ if (originalTypeDef.getVersion() != typeDefPatch.getApplyToVersion())
+ {
+ // TODO throw PatchException - incompatible versions
+ }
+
+ /*
+ * OK to perform the update. Need to create a new TypeDef object. TypeDef is an abstract class
+ * so need to use the TypeDefCategory to create a new object of the correct type.
+ */
+ TypeDefCategory category = originalTypeDef.getCategory();
+ if (category == null)
+ {
+ // TODO Throw PatchError - base type is messed up
+ }
+
+ try
+ {
+ switch (category)
+ {
+ case ENTITY_DEF:
+ clonedTypeDef = new EntityDef((EntityDef) originalTypeDef);
+ break;
+
+ case RELATIONSHIP_DEF:
+ clonedTypeDef = new RelationshipDef((RelationshipDef) originalTypeDef);
+ break;
+
+ case CLASSIFICATION_DEF:
+ clonedTypeDef = new ClassificationDef((ClassificationDef) originalTypeDef);
+ break;
+ }
+ }
+ catch (ClassCastException castError)
+ {
+ // TODO Throw PatchError - base type is messed up
+ }
+
+ /*
+ * Now we have a new TypeDef - just need to make the changes. The Action
+ */
+ if (clonedTypeDef != null)
+ {
+ switch (patchAction)
+ {
+ case ADD_ATTRIBUTES:
+ updatedTypeDef = this.patchTypeDefAttributes(clonedTypeDef, typeDefPatch.getTypeDefAttributes());
+ break;
+
+ case ADD_OPTIONS:
+ updatedTypeDef = this.patchTypeDefNewOptions(clonedTypeDef, typeDefPatch.getTypeDefOptions());
+ break;
+
+ case UPDATE_OPTIONS:
+ updatedTypeDef = this.patchTypeDefUpdateOptions(clonedTypeDef, typeDefPatch.getTypeDefOptions());
+ break;
+
+ case DELETE_OPTIONS:
+ updatedTypeDef = this.patchTypeDefDeleteOptions(clonedTypeDef, typeDefPatch.getTypeDefOptions());
+ break;
+
+ case ADD_EXTERNAL_STANDARDS:
+ updatedTypeDef = this.patchTypeDefAddExternalStandards(clonedTypeDef,
+ typeDefPatch.getExternalStandardMappings(),
+ typeDefPatch.getTypeDefAttributes());
+ break;
+
+ case UPDATE_EXTERNAL_STANDARDS:
+ updatedTypeDef = this.patchTypeDefUpdateExternalStandards(clonedTypeDef,
+ typeDefPatch.getExternalStandardMappings(),
+ typeDefPatch.getTypeDefAttributes());
+ break;
+
+ case DELETE_EXTERNAL_STANDARDS:
+ updatedTypeDef = this.patchTypeDefDeleteExternalStandards(clonedTypeDef,
+ typeDefPatch.getExternalStandardMappings(),
+ typeDefPatch.getTypeDefAttributes());
+ break;
+
+ case UPDATE_DESCRIPTIONS:
+ updatedTypeDef = this.patchTypeDefNewDescriptions(clonedTypeDef,
+ typeDefPatch.getDescription(),
+ typeDefPatch.getDescriptionGUID(),
+ typeDefPatch.getTypeDefAttributes());
+ break;
+ }
+ }
+
+
+ if (updatedTypeDef != null)
+ {
+ updatedTypeDef.setVersion(typeDefPatch.getUpdateToVersion());
+ updatedTypeDef.setVersionName(typeDefPatch.getNewVersionName());
+ }
+
+ return updatedTypeDef;
+ }
+
+
+ /**
+ * Add the supplied attributes to the properties definition for the cloned typedef.
+ *
+ * @param clonedTypeDef - TypeDef object to update
+ * @param typeDefAttributes - new attributes to add.
+ * @return updated TypeDef
+ * @throws PatchErrorException - problem adding attributes
+ */
+ private TypeDef patchTypeDefAttributes(TypeDef clonedTypeDef,
+ ArrayList<TypeDefAttribute> typeDefAttributes) throws PatchErrorException
+ {
+ ArrayList<TypeDefAttribute> propertyDefinitions = clonedTypeDef.getPropertiesDefinition();
+
+ if (propertyDefinitions == null)
+ {
+ propertyDefinitions = new ArrayList<>();
+ }
+
+ for (TypeDefAttribute newAttribute : typeDefAttributes)
+ {
+ if (newAttribute != null)
+ {
+ String attributeName = newAttribute.getAttributeName();
+ AttributeTypeDef attributeType = newAttribute.getAttributeType();
+
+ if ((attributeName != null) && (attributeType != null))
+ {
+ if (propertyDefinitions.contains(newAttribute))
+ {
+ // TODO Patch error - Duplicate Attribute
+ }
+ else
+ {
+ propertyDefinitions.add(newAttribute);
+ }
+ }
+ else
+ {
+ // TODO Patch Error - Invalid Attribute in patch
+ }
+ }
+ }
+
+ if (propertyDefinitions.size() > 0)
+ {
+ clonedTypeDef.setPropertiesDefinition(propertyDefinitions);
+ }
+ else
+ {
+ clonedTypeDef.setPropertiesDefinition(null);
+ }
+
+ return clonedTypeDef;
+ }
+
+
+ /**
+ *
+ * @param clonedTypeDef - TypeDef object to update
+ * @param typeDefOptions - new options to add
+ * @return updated TypeDef
+ * @throws PatchErrorException - problem adding options
+ */
+ private TypeDef patchTypeDefNewOptions(TypeDef clonedTypeDef,
+ Map<String, String> typeDefOptions) throws PatchErrorException
+ {
+ // TODO
+ return null;
+ }
+
+
+ /**
+ *
+ * @param clonedTypeDef - TypeDef object to update
+ * @param typeDefOptions - options to update
+ * @return updated TypeDef
+ * @throws PatchErrorException - problem updating options
+ */
+ private TypeDef patchTypeDefUpdateOptions(TypeDef clonedTypeDef,
+ Map<String, String> typeDefOptions) throws PatchErrorException
+ {
+ // TODO
+ return null;
+ }
+
+
+ /**
+ *
+ * @param clonedTypeDef - TypeDef object to update
+ * @param typeDefOptions - options to delete
+ * @return updated TypeDef
+ * @throws PatchErrorException - problem deleting options
+ */
+ private TypeDef patchTypeDefDeleteOptions(TypeDef clonedTypeDef,
+ Map<String, String> typeDefOptions) throws PatchErrorException
+ {
+ // TODO
+ return null;
+ }
+
+
+ /**
+ * Add new mappings to external standards to the TypeDef.
+ *
+ * @param clonedTypeDef - TypeDef object to update
+ * @param externalStandardMappings - new mappings to add
+ * @return updated TypeDef
+ * @throws PatchErrorException - problem adding mapping(s)
+ */
+ private TypeDef patchTypeDefAddExternalStandards(TypeDef clonedTypeDef,
+ ArrayList<ExternalStandardMapping> externalStandardMappings,
+ ArrayList<TypeDefAttribute> typeDefAttributes) throws PatchErrorException
+ {
+ // TODO
+ return null;
+ }
+
+
+ /**
+ * Update the supplied mappings from the TypeDef.
+ *
+ * @param clonedTypeDef - TypeDef object to update
+ * @param externalStandardMappings - mappings to update
+ * @return updated TypeDef
+ * @throws PatchErrorException - problem updating mapping(s)
+ */
+ private TypeDef patchTypeDefUpdateExternalStandards(TypeDef clonedTypeDef,
+ ArrayList<ExternalStandardMapping> externalStandardMappings,
+ ArrayList<TypeDefAttribute> typeDefAttributes) throws PatchErrorException
+ {
+ // TODO
+ return null;
+ }
+
+
+ /**
+ * Delete the supplied mappings from the TypeDef.
+ *
+ * @param clonedTypeDef - TypeDef object to update
+ * @param externalStandardMappings - list of mappings to delete
+ * @return updated TypeDef
+ * @throws PatchErrorException - problem deleting mapping(s)
+ */
+ private TypeDef patchTypeDefDeleteExternalStandards(TypeDef clonedTypeDef,
+ ArrayList<ExternalStandardMapping> externalStandardMappings,
+ ArrayList<TypeDefAttribute> typeDefAttributes) throws PatchErrorException
+ {
+ // TODO
+ return null;
+ }
+
+
+ /**
+ * Update the descriptions for the TypeDef or any of its attributes. If the description values are null, they are
+ * not changes in the TypeDef. This means there is no way to clear a description - just update it for a better one.
+ *
+ * @param clonedTypeDef - TypeDef object to update
+ * @param description - new description
+ * @param descriptionGUID - new unique identifier for glossary term that provides detailed description of TypeDef
+ * @return updated TypeDef
+ * @throws PatchErrorException - problem adding new description
+ */
+ private TypeDef patchTypeDefNewDescriptions(TypeDef clonedTypeDef,
+ String description,
+ String descriptionGUID,
+ ArrayList<TypeDefAttribute> typeDefAttributes) throws PatchErrorException
+ {
+ if (description != null)
+ {
+ clonedTypeDef.setDescription(description);
+ }
+ if (descriptionGUID != null)
+ {
+ clonedTypeDef.setDescriptionGUID(descriptionGUID);
+ }
+
+ if (typeDefAttributes != null)
+ {
+ ArrayList<TypeDefAttribute> propertiesDefinition = clonedTypeDef.getPropertiesDefinition();
+
+ if (propertiesDefinition == null)
+ {
+ // TODO throw patch error - attempting to Patch TypeDef with no properties
+ }
+
+ for (TypeDefAttribute patchTypeDefAttribute : typeDefAttributes)
+ {
+ if (patchTypeDefAttribute != null)
+ {
+ String patchTypeDefAttributeName = patchTypeDefAttribute.getAttributeName();
+
+ if (patchTypeDefAttributeName != null)
+ {
+ for (TypeDefAttribute existingProperty : propertiesDefinition)
+ {
+ if (existingProperty != null)
+ {
+ if (patchTypeDefAttributeName.equals(existingProperty.getAttributeName()))
+ {
+
+ }
+ }
+ else
+ {
+ // TODO throw Patch Error because basic Type is messed up
+ }
+ }
+ }
+ else
+ {
+ // TODO throw Patch Error null attribute name
+ }
+ }
+ else
+ {
+ // TODO throw Patch Error null attribute included
+ }
+ }
+ }
+
+ return clonedTypeDef;
+ }
+
+ /*
+ * =======================
+ * OMRSTypeDefValidator
+ */
+
+ /**
+ * Return a summary list of the TypeDefs supported by the local metadata repository. This is
+ * broadcast to the other servers/repositories in the cohort during the membership registration exchanges
+ * managed by the cohort registries.
+ *
+ * @return TypeDefSummary list
+ */
+ public ArrayList<TypeDefSummary> getLocalTypeDefs()
+ {
+ ArrayList<TypeDefSummary> activeTypeDefSummaries = null;
+
+ if (activeTypes != null)
+ {
+ activeTypeDefSummaries = new ArrayList<>();
+
+ for (TypeDef activeType : activeTypes.values())
+ {
+ activeTypeDefSummaries.add(activeType);
+ }
+ }
+
+ return activeTypeDefSummaries;
+ }
+
+
+ /**
+ * Return a boolean flag indicating whether the list of TypeDefs passed are compatible with the
+ * local metadata repository. A true response means it is ok; false means conflicts have been found.
+ *
+ * A valid TypeDef is one that:
+ * <ul>
+ * <li>
+ * Matches name, GUID and version to a TypeDef in the local repository, or
+ * </li>
+ * <li>
+ * Is not defined in the local repository.
+ * </li>
+ * </ul>
+ *
+ * @param sourceName - source of the request (used for logging)
+ * @param typeDefSummaries - list of summary information about the TypeDefs.
+ */
+ public void validateAgainstLocalTypeDefs(String sourceName, ArrayList<TypeDefSummary> typeDefSummaries)
+ {
+
+ // TODO if invalid typeDefs are detected, they are logged and TypeDef conflict messages are sent to
+ // the typeDefEventProcessor methods to distributed
+ }
+
+
+ /**
+ * Return a boolean flag indicating whether the list of TypeDefs passed are compatible with the
+ * all known typedefs.
+ *
+ * A valid TypeDef is one that matches name, GUID and version to the full list of TypeDefs.
+ * If a new TypeDef is present, it is added to the enterprise list.
+ *
+ * @param sourceName - source of the TypeDef (used for logging)
+ * @param typeDefs - list of TypeDefs.
+ * @return boolean flag
+ */
+ public boolean validateEnterpriseTypeDefs(String sourceName, ArrayList<TypeDef> typeDefs)
+ {
+ return true;
+ }
+
+ /**
+ * Return boolean indicating whether the TypeDef is one of the standard open metadata types.
+ *
+ * @param sourceName - source of the TypeDef (used for logging)
+ * @param typeDefGUID - unique identifier of the type
+ * @param typeDefName - unique name of the type
+ * @return boolean result
+ */
+ public boolean isOpenType(String sourceName, String typeDefGUID, String typeDefName)
+ {
+ if (isKnownType(sourceName, typeDefGUID, typeDefName))
+ {
+ TypeDef typeDef = knownTypes.get(typeDefName);
+
+ if (typeDef == null)
+ {
+ return false;
+ }
+
+ if (openTypesOriginGUID != null)
+ {
+ if (openTypesOriginGUID.equals(typeDef.getOrigin()))
+ {
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+
+
+ /**
+ * Return boolean indicating whether the TypeDef is known, either as an open type, or one defined
+ * by one or more of the members of the cohort.
+ *
+ * @param sourceName - source of the TypeDef (used for logging)
+ * @param typeDefGUID - unique identifier of the type
+ * @param typeDefName - unique name of the type
+ * @return boolean result
+ */
+ public boolean isKnownType(String sourceName, String typeDefGUID, String typeDefName)
+ {
+ if (typeDefName == null)
+ {
+ return false;
+ }
+
+ TypeDef typeDef = knownTypes.get(typeDefName);
+
+ if (typeDef == null)
+ {
+ return false;
+ }
+
+ if (typeDefGUID != null)
+ {
+ if (typeDefGUID.equals(typeDef.getGUID()))
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ else
+ {
+ return true;
+ }
+ }
+
+
+ /**
+ * Return boolean indicating whether the TypeDef is in use in the repository.
+ *
+ * @param sourceName - source of the TypeDef (used for logging)
+ * @param typeDefGUID - unique identifier of the type
+ * @param typeDefName - unique name of the type
+ * @return boolean result
+ */
+ public boolean isActiveType(String sourceName, String typeDefGUID, String typeDefName)
+ {
+ if (typeDefName == null)
+ {
+ return false;
+ }
+
+ TypeDef typeDef = activeTypes.get(typeDefName);
+
+ if (typeDef == null)
+ {
+ return false;
+ }
+
+ if (typeDefGUID != null)
+ {
+ if (typeDefGUID.equals(typeDef.getGUID()))
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ else
+ {
+ return true;
+ }
+ }
+
+ /**
+ * Return boolean indicating whether the TypeDef identifiers are valid or not.
+ *
+ * @param sourceName - source of the TypeDef (used for logging)
+ * @param typeDefGUID - unique identifier of the TypeDef
+ * @param typeDefName - unique name of the TypeDef
+ * @return boolean result
+ */
+ public boolean validTypeId(String sourceName,
+ String typeDefGUID,
+ String typeDefName)
+ {
+ if (typeDefName == null)
+ {
+ // TODO Log error
+ return false;
+ }
+
+ if (typeDefGUID == null)
+ {
+ // TODO Log warning - probably caused by local repository connector not setting up GUID properly
+ return false;
+ }
+
+ TypeDef typeDef = knownTypes.get(typeDefName);
+
+ if (typeDef == null)
+ {
+ // TODO log unknown type
+ return false;
+ }
+
+ if (! typeDefGUID.equals(typeDef.getGUID()))
+ {
+ // TODO log type mismatch
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Return boolean indicating whether the TypeDef identifiers are valid or not.
+ *
+ * @param sourceName - source of the TypeDef (used for logging)
+ * @param typeDefGUID - unique identifier of the TypeDef
+ * @param typeDefName - unique name of the TypeDef
+ * @return boolean result
+ */
+ public boolean validTypeId(String sourceName,
+ String typeDefGUID,
+ String typeDefName,
+ TypeDefCategory category)
+ {
+ if (! validTypeId(sourceName, typeDefGUID, typeDefName))
+ {
+ /*
+ * Error already logged.
+ */
+ return false;
+ }
+
+ TypeDef typeDef = knownTypes.get(typeDefName);
+ TypeDefCategory knownTypeDefCategory = typeDef.getCategory();
+
+ if (knownTypeDefCategory == null)
+ {
+ // TODO log messed up cache
+ return false;
+ }
+
+ if (category.getTypeCode() != knownTypeDefCategory.getTypeCode())
+ {
+ // TODO log type mismatch
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Return boolean indicating whether the TypeDef identifiers are valid or not.
+ *
+ * @param sourceName - source of the TypeDef (used for logging)
+ * @param typeDefGUID - unique identifier of the TypeDef
+ * @param typeDefName - unique name of the TypeDef
+ * @param typeDefVersion - versionName of the type
+ * @param typeDefCategory - category of the instance described by this TypeDef.
+ * @return boolean result
+ */
+ public boolean validTypeId(String sourceName,
+ String typeDefGUID,
+ String typeDefName,
+ long typeDefVersion,
+ TypeDefCategory typeDefCategory)
+ {
+ if (! validTypeId(sourceName, typeDefGUID, typeDefName, typeDefCategory))
+ {
+ return false;
+ }
+
+ TypeDef typeDef = knownTypes.get(typeDefName);
+
+ if (typeDef == null)
+ {
+ // Log logic error
+ return false;
+ }
+
+ if (typeDef.getVersion() != typeDefVersion)
+ {
+ // TODO log warning to say version mismatch
+ return false;
+ }
+
+ return true;
+ }
+
+
+ /**
+ * Return boolean indicating whether the supplied TypeDef is valid or not.
+ *
+ * @param sourceName - source of the TypeDef (used for logging)
+ * @param typeDef - TypeDef to test
+ * @return boolean result
+ */
+ public boolean validTypeDef(String sourceName,
+ TypeDef typeDef)
+ {
+ if (typeDef == null)
+ {
+ // TODO log null TypeDef
+ return false;
+ }
+
+ if (validTypeId(sourceName,
+ typeDef.getGUID(),
+ typeDef.getName(),
+ typeDef.getVersion(),
+ typeDef.getCategory()))
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+
+ /**
+ * Return boolean indicating whether the supplied TypeDefSummary is valid or not.
+ *
+ * @param sourceName - source of the TypeDefSummary (used for logging)
+ * @param typeDefSummary - TypeDefSummary to test.
+ * @return boolean result.
+ */
+ public boolean validTypeDefSummary(String sourceName,
+ TypeDefSummary typeDefSummary)
+ {
+ if (typeDefSummary != null)
+ {
+ if (validTypeId(sourceName,
+ typeDefSummary.getGUID(),
+ typeDefSummary.getName(),
+ typeDefSummary.getVersion(),
+ typeDefSummary.getCategory()))
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+
+ /*
+ * ===========================
+ * OMRSTypeDefEventProcessor
+ */
+
+
+ /**
+ * A new TypeDef has been defined either in an archive, or in another member of the cohort.
+ *
+ * This new TypeDef can be added to the repository if it does not clash with an existing typeDef and the local
+ * repository supports dynamic type definitions.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param typeDef - details of the new TypeDef
+ */
+ public void processNewTypeDefEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ TypeDef typeDef)
+ {
+
+
+ OMRSMetadataCollection metadataCollection = null;
+
+ if (localRepositoryConnector != null)
+ {
+ localRepositoryConnector.getMetadataCollection();
+ }
+
+ if (metadataCollection != null)
+ {
+ try
+ {
+ /*
+ * VerifyTypeDef returns true if the typeDef is known and matches the supplied definition.
+ * It returns false if the type is supportable but has not yet been defined.
+ * It throws TypeDefNotSupportedException if the typeDef is not supported and can not
+ * be dynamically defined by the local repository.
+ */
+ if (! metadataCollection.verifyTypeDef(null, typeDef))
+ {
+ metadataCollection.addTypeDef(null, typeDef);
+
+ /*
+ * Update the active TypeDefs as this new TypeDef has been accepted by the local repository.
+ */
+ activeTypes.put(typeDef.getName(), typeDef);
+ }
+ }
+ catch (TypeDefNotSupportedException fixedTypeSystemResponse)
+ {
+
+
+ if (log.isDebugEnabled())
+ {
+ log.debug("TypeDef not added because repository does not support dynamic type definitions", typeDef);
+ log.debug("TypeDefNotSupportedException:", fixedTypeSystemResponse);
+
+ }
+ }
+ catch (RepositoryErrorException error)
+ {
+ // TODO log an error to say that the repository is not available
+
+ if (log.isDebugEnabled())
+ {
+ log.debug("TypeDef not added because repository is not available", typeDef);
+ log.debug("RepositoryErrorException:", error);
+
+ }
+ }
+ catch (TypeDefConflictException error)
+ {
+ // TODO log an error to say that the TypeDef conflicts with a TypeDef already stored.
+
+ if (log.isDebugEnabled())
+ {
+ log.debug("TypeDef not added because it conflicts with another TypeDef already in the repository", typeDef);
+ log.debug("TypeDefConflictException:", error);
+ }
+ }
+ catch (InvalidTypeDefException error)
+ {
+ // TODO log an error to say that the TypeDef contains bad values.
+
+ if (log.isDebugEnabled())
+ {
+ log.debug("TypeDef not added because repository is not available", typeDef);
+ log.debug("InvalidTypeDefException:", error);
+ }
+ }
+ catch (TypeDefKnownException error)
+ {
+ // TODO log an error to say that a logic error has occurred
+
+ if (log.isDebugEnabled())
+ {
+ log.debug("TypeDef not added because repository has a logic error", typeDef);
+ log.debug("TypeDefKnownException:", error);
+
+ }
+ }
+ catch (Throwable error)
+ {
+ // TODO log an error to say that an unexpected error has occurred
+
+ if (log.isDebugEnabled())
+ {
+ log.debug("TypeDef not added because repository has an unexpected error", typeDef);
+ log.debug("Throwable:", error);
+ }
+ }
+ }
+ }
+
+
+ /**
+ * A new AttributeTypeDef has been defined in an open metadata repository.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param attributeTypeDef - details of the new AttributeTypeDef.
+ */
+ public void processNewAttributeTypeDefEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ AttributeTypeDef attributeTypeDef)
+ {
+ // TODO
+ }
+
+
+ /**
+ * An existing TypeDef has been updated in a remote metadata repository.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param typeDefPatch - details of the new versionName of the TypeDef
+ */
+ public void processUpdatedTypeDefEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ TypeDefPatch typeDefPatch)
+ {
+ OMRSMetadataCollection metadataCollection = localRepositoryConnector.getMetadataCollection();
+
+ if (metadataCollection != null)
+ {
+ try
+ {
+ TypeDef updatedTypeDef = metadataCollection.updateTypeDef(null, typeDefPatch);
+
+ if (log.isDebugEnabled())
+ {
+ log.debug("Patch successfully applied", updatedTypeDef);
+ }
+ }
+ catch (RepositoryErrorException error)
+ {
+ // TODO log an error to say that the repository is not available
+
+ if (log.isDebugEnabled())
+ {
+ log.debug("Patch not applied because repository is not available", typeDefPatch);
+ }
+ }
+ catch (TypeDefNotKnownException error)
+ {
+ // TODO log an error to say that the TypeDef is not known
+
+ if (log.isDebugEnabled())
+ {
+ log.debug("Patch not applied because TypeDef does not exist", typeDefPatch);
+ log.debug("TypeDefNotKnownException:", error);
+ }
+ }
+ catch (PatchErrorException error)
+ {
+ // TODO log an error to say that the TypeDef patch is invalid
+
+ if (log.isDebugEnabled())
+ {
+ log.debug("Patch not applied because it is invalid", typeDefPatch);
+ log.debug("PatchErrorException:", error);
+ }
+ }
+ catch (Throwable error)
+ {
+ // TODO log a generic error
+
+ if (log.isDebugEnabled())
+ {
+ log.debug("Patch not applied because of an error", typeDefPatch);
+ log.debug("Throwable:", error);
+ }
+ }
+ }
+ }
+
+
+ /**
+ * An existing TypeDef has been deleted in a remote metadata repository. Both the name and the
+ * GUID are provided to ensure the right TypeDef is deleted in other cohort member repositories.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param typeDefGUID - unique identifier of the TypeDef
+ * @param typeDefName - unique name of the TypeDef
+ */
+ public void processDeletedTypeDefEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ String typeDefGUID,
+ String typeDefName)
+ {
+ // TODO
+ }
+
+
+ /**
+ * An existing AttributeTypeDef has been deleted in an open metadata repository. Both the name and the
+ * GUID are provided to ensure the right AttributeTypeDef is deleted in other cohort member repositories.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param attributeTypeDefGUID - unique identifier of the AttributeTypeDef
+ * @param attributeTypeDefName - unique name of the AttributeTypeDef
+ */
+ public void processDeletedAttributeTypeDefEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ String attributeTypeDefGUID,
+ String attributeTypeDefName)
+ {
+ // TODO
+ }
+
+
+ /**
+ * Process an event that changes either the name or guid of a TypeDef. It is resolving a Conflicting TypeDef Error.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param originalTypeDefSummary - details of the original TypeDef
+ * @param typeDef - updated TypeDef with new identifiers inside.
+ */
+ public void processReIdentifiedTypeDefEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ TypeDefSummary originalTypeDefSummary,
+ TypeDef typeDef)
+ {
+
+ }
+
+
+ /**
+ * Process an event that changes either the name or guid of an AttributeTypeDef.
+ * It is resolving a Conflicting AttributeTypeDef Error.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param originalAttributeTypeDef - description of original AttributeTypeDef
+ * @param attributeTypeDef - updated AttributeTypeDef with new identifiers inside.
+ */
+ public void processReIdentifiedAttributeTypeDefEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ AttributeTypeDef originalAttributeTypeDef,
+ AttributeTypeDef attributeTypeDef)
+ {
+ // TODO
+ }
+
+
+ /**
+ * Process a detected conflict in type definitions (TypeDefs) used in the cohort.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param originatorTypeDefSummary - details of the TypeDef in the event originator
+ * @param otherMetadataCollectionId - the metadataCollection using the conflicting TypeDef
+ * @param conflictingTypeDefSummary - the details of the TypeDef in the other metadata collection
+ * @param errorMessage - details of the error that occurs when the connection is used.
+ */
+ public void processTypeDefConflictEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ TypeDefSummary originatorTypeDefSummary,
+ String otherMetadataCollectionId,
+ TypeDefSummary conflictingTypeDefSummary,
+ String errorMessage)
+ {
+ // TODO
+ }
+
+
+ /**
+ * Process a detected conflict in the attribute type definitions (AttributeTypeDefs) used in the cohort.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param originatorAttributeTypeDef- description of the AttributeTypeDef in the event originator.
+ * @param otherMetadataCollectionId - the metadataCollection using the conflicting AttributeTypeDef.
+ * @param conflictingAttributeTypeDef - description of the AttributeTypeDef in the other metadata collection.
+ * @param errorMessage - details of the error that occurs when the connection is used.
+ */
+ public void processAttributeTypeDefConflictEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ AttributeTypeDef originatorAttributeTypeDef,
+ String otherMetadataCollectionId,
+ AttributeTypeDef conflictingAttributeTypeDef,
+ String errorMessage)
+ {
+ // TODO
+ }
+
+
+ /**
+ * A TypeDef from another member in the cohort is at a different versionName than the local repository. This may
+ * create some inconsistencies in the different copies of instances of this type in different members of the
+ * cohort. The recommended action is to update all TypeDefs to the latest versionName.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param targetMetadataCollectionId - identifier of the metadata collection that is reporting a TypeDef at a
+ * different level to the local repository.
+ * @param targetTypeDefSummary - details of the target TypeDef
+ * @param otherTypeDef - details of the TypeDef in the local repository.
+ */
+ public void processTypeDefPatchMismatchEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ String targetMetadataCollectionId,
+ TypeDefSummary targetTypeDefSummary,
+ TypeDef otherTypeDef,
+ String errorMessage)
+ {
+
+ }
+
+
+ /*
+ * =====================
+ * OMRSInstanceValidator
+ */
+
+ /**
+ * Test that the supplied entity is valid.
+ *
+ * @param sourceName - source of the entity (used for logging)
+ * @param entity - entity to test
+ * @return boolean result
+ */
+ public boolean validEntity(String sourceName,
+ EntityDetail entity)
+ {
+ if (entity == null)
+ {
+ // TODO log null entity
+ return false;
+ }
+
+ InstanceType instanceType = entity.getType();
+
+ if (instanceType == null)
+ {
+ // TODO log null type
+ return false;
+ }
+
+ if (! validInstanceId(sourceName,
+ instanceType.getTypeDefGUID(),
+ instanceType.getTypeDefName(),
+ instanceType.getTypeDefCategory(),
+ entity.getGUID()))
+ {
+ /*
+ * Error messages already logged.
+ */
+ return false;
+ }
+
+ String homeMetadataCollectionId = entity.getMetadataCollectionId();
+
+ if (homeMetadataCollectionId == null)
+ {
+ // TODO log error
+ return false;
+ }
+
+ return true;
+ }
+
+
+ /**
+ * Test that the supplied relationship is valid.
+ *
+ * @param sourceName - source of the relationship (used for logging)
+ * @param relationship - relationship to test
+ * @return boolean result
+ */
+ public boolean validRelationship(String sourceName,
+ Relationship relationship)
+ {
+ if (relationship == null)
+ {
+ // TODO log null relationship
+ return false;
+ }
+
+ InstanceType instanceType = relationship.getType();
+
+ if (instanceType == null)
+ {
+ // TODO log null type
+ return false;
+ }
+
+ if (! validInstanceId(sourceName,
+ instanceType.getTypeDefGUID(),
+ instanceType.getTypeDefName(),
+ instanceType.getTypeDefCategory(),
+ relationship.getGUID()))
+ {
+ /*
+ * Error messages already logged.
+ */
+ return false;
+ }
+
+ String homeMetadataCollectionId = relationship.getMetadataCollectionId();
+
+ if (homeMetadataCollectionId == null)
+ {
+ // TODO log error
+ return false;
+ }
+
+ return true;
+ }
+
+
+ /**
+ * Verify that the identifiers for an instance are correct.
+ *
+ * @param sourceName - source of the instance (used for logging)
+ * @param typeDefGUID - unique identifier for the type.
+ * @param typeDefName - unique name for the type.
+ * @param category - expected category of the instance.
+ * @param instanceGUID - unique identifier for the instance.
+ * @return boolean indicating whether the identifiers are ok.
+ */
+ public boolean validInstanceId(String sourceName,
+ String typeDefGUID,
+ String typeDefName,
+ TypeDefCategory category,
+ String instanceGUID)
+ {
+ if (instanceGUID == null)
+ {
+ // TODO - log null guid
+ return false;
+ }
+
+ if (! validTypeId(sourceName,
+ typeDefGUID,
+ typeDefName,
+ category))
+ {
+ /*
+ * Error messages already logged
+ */
+ return false;
+ }
+
+ return true;
+ }
+}
[14/30] atlas git commit: ATLAS-2246: OMRS Connector API plus REST
and IGC Connector skeleton - 15th February 2018
Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/OMRSConnectorErrorException.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/OMRSConnectorErrorException.java b/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/OMRSConnectorErrorException.java
new file mode 100644
index 0000000..eae658a
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/OMRSConnectorErrorException.java
@@ -0,0 +1,184 @@
+/*
+ * 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.ffdc.exception;
+
+/**
+ * OMRSConnectorErrorException is used for all runtime exceptions generated by the Open Metadata Repository Services (OMRS)
+ * components that indicate a problem with one of its connectors. It is typically wrapping an OCF checked exception.
+ */
+public class OMRSConnectorErrorException extends OMRSRuntimeException
+{
+ /*
+ * These default values are only seen if this exception is initialized using one of its superclass constructors.
+ */
+ private int reportedHTTPCode = 500;
+ private String reportingClassName = "<Unknown>";
+ private String reportingActionDescription = "<Unknown>";
+ private String reportedErrorMessage = "<Unknown>";
+ private String reportedSystemAction = "<Unknown>";
+ private String reportedUserAction = "<Unknown>";
+ private Throwable [] reportedCaughtExceptions = null;
+
+
+ /**
+ * This is the typical constructor used for creating an OMRSLogicErrorException.
+ *
+ * @param httpCode - http response code to use if this exception flows over a REST call
+ * @param className - name of class reporting error
+ * @param actionDescription - description of function it was performing when error detected
+ * @param errorMessage - description of error
+ * @param systemAction - actions of the system as a result of the error
+ * @param userAction - instructions for correcting the error
+ */
+ public OMRSConnectorErrorException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction)
+ {
+ super(httpCode, className, actionDescription, errorMessage, systemAction, userAction);
+
+ this.reportedHTTPCode = httpCode;
+ this.reportingClassName = className;
+ this.reportingActionDescription = actionDescription;
+ this.reportedErrorMessage = errorMessage;
+ this.reportedSystemAction = systemAction;
+ this.reportedUserAction = userAction;
+ }
+
+
+ /**
+ * This is the constructor used for creating a OMRSLogicErrorException when an unexpected exception has been caught.
+ *
+ * @param httpCode - http response code to use if this exception flows over a REST call
+ * @param className - name of class reporting error
+ * @param actionDescription - description of function it was performing when error detected
+ * @param errorMessage - description of error
+ * @param systemAction - actions of the system as a result of the error
+ * @param userAction - instructions for correcting the error
+ * @param caughtError - previous error causing this exception
+ */
+ public OMRSConnectorErrorException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction, Throwable caughtError)
+ {
+ super(httpCode, className, actionDescription, errorMessage, systemAction, userAction, caughtError);
+
+ this.reportedHTTPCode = httpCode;
+ this.reportingClassName = className;
+ this.reportingActionDescription = actionDescription;
+ this.reportedErrorMessage = errorMessage;
+ this.reportedSystemAction = systemAction;
+ this.reportedUserAction = userAction;
+ this.reportedCaughtExceptions = new Throwable[1];
+ this.reportedCaughtExceptions[0] = caughtError;
+ }
+
+ /**
+ * This is the constructor used for creating a OMRSLogicErrorException when multiple unexpected errors
+ * have been caught.
+ *
+ * @param httpCode - http response code to use if this exception flows over a rest call
+ * @param className - name of class reporting error
+ * @param actionDescription - description of function it was performing when error detected
+ * @param errorMessage - description of error
+ * @param systemAction - actions of the system as a result of the error
+ * @param userAction - instructions for correcting the error
+ * @param caughtErrors - previous errors causing this exception
+ */
+ public OMRSConnectorErrorException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction, Throwable[] caughtErrors)
+ {
+ super(httpCode, className, actionDescription, errorMessage, systemAction, userAction, caughtErrors);
+
+ this.reportedHTTPCode = httpCode;
+ this.reportingClassName = className;
+ this.reportingActionDescription = actionDescription;
+ this.reportedErrorMessage = errorMessage;
+ this.reportedSystemAction = systemAction;
+ this.reportedUserAction = userAction;
+ this.reportedCaughtExceptions = caughtErrors;
+ }
+
+ /**
+ * Return the HTTP response code to use with this exception.
+ *
+ * @return reportedHTTPCode
+ */
+ public int getReportedHTTPCode()
+ {
+ return reportedHTTPCode;
+ }
+
+ /**
+ * The class that created this exception.
+ *
+ * @return reportingClassName
+ */
+ public String getReportingClassName()
+ {
+ return reportingClassName;
+ }
+
+
+ /**
+ * The type of request that the class was performing when the condition occurred that resulted in this
+ * exception.
+ *
+ * @return reportingActionDescription
+ */
+ public String getReportingActionDescription()
+ {
+ return reportingActionDescription;
+ }
+
+
+ /**
+ * A formatted short description of the cause of the condition that resulted in this exception.
+ *
+ * @return reportedErrorMessage
+ */
+ public String getErrorMessage()
+ {
+ return reportedErrorMessage;
+ }
+
+
+ /**
+ * A description of the action that the system took as a result of the error condition.
+ *
+ * @return reportedSystemAction
+ */
+ public String getReportedSystemAction()
+ {
+ return reportedSystemAction;
+ }
+
+
+ /**
+ * A description of the action necessary to correct the error.
+ *
+ * @return reportedUserAction
+ */
+ public String getReportedUserAction()
+ {
+ return reportedUserAction;
+ }
+
+
+ /**
+ * An exception that was caught and wrapped by this exception. If a null is returned, then this exception is
+ * newly created and not the result of a previous exception.
+ *
+ * @return reportedCaughtException
+ */
+ public Throwable[] getReportedCaughtExceptions() { return reportedCaughtExceptions; }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/OMRSLogicErrorException.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/OMRSLogicErrorException.java b/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/OMRSLogicErrorException.java
new file mode 100644
index 0000000..7935140
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/OMRSLogicErrorException.java
@@ -0,0 +1,185 @@
+/*
+ * 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.ffdc.exception;
+
+/**
+ * OMRSLogicErrorException is used for all runtime exceptions generated by the Open Metadata Repository Services (OMRS)
+ * components that indicate a logic error. Effectively this exception should never be seen.
+ * It is used in conjunction with the OMRSErrorCode to provide first failure data capture for these errors.
+ */
+public class OMRSLogicErrorException extends OMRSRuntimeException
+{
+ /*
+ * These default values are only seen if this exception is initialized using one of its superclass constructors.
+ */
+ private int reportedHTTPCode = 500;
+ private String reportingClassName = "<Unknown>";
+ private String reportingActionDescription = "<Unknown>";
+ private String reportedErrorMessage = "<Unknown>";
+ private String reportedSystemAction = "<Unknown>";
+ private String reportedUserAction = "<Unknown>";
+ private Throwable [] reportedCaughtExceptions = null;
+
+
+ /**
+ * This is the typical constructor used for creating an OMRSLogicErrorException.
+ *
+ * @param httpCode - http response code to use if this exception flows over a REST call
+ * @param className - name of class reporting error
+ * @param actionDescription - description of function it was performing when error detected
+ * @param errorMessage - description of error
+ * @param systemAction - actions of the system as a result of the error
+ * @param userAction - instructions for correcting the error
+ */
+ public OMRSLogicErrorException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction)
+ {
+ super(httpCode, className, actionDescription, errorMessage, systemAction, userAction);
+
+ this.reportedHTTPCode = httpCode;
+ this.reportingClassName = className;
+ this.reportingActionDescription = actionDescription;
+ this.reportedErrorMessage = errorMessage;
+ this.reportedSystemAction = systemAction;
+ this.reportedUserAction = userAction;
+ }
+
+
+ /**
+ * This is the constructor used for creating a OMRSLogicErrorException when an unexpected exception has been caught.
+ *
+ * @param httpCode - http response code to use if this exception flows over a REST call
+ * @param className - name of class reporting error
+ * @param actionDescription - description of function it was performing when error detected
+ * @param errorMessage - description of error
+ * @param systemAction - actions of the system as a result of the error
+ * @param userAction - instructions for correcting the error
+ * @param caughtError - previous error causing this exception
+ */
+ public OMRSLogicErrorException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction, Throwable caughtError)
+ {
+ super(httpCode, className, actionDescription, errorMessage, systemAction, userAction, caughtError);
+
+ this.reportedHTTPCode = httpCode;
+ this.reportingClassName = className;
+ this.reportingActionDescription = actionDescription;
+ this.reportedErrorMessage = errorMessage;
+ this.reportedSystemAction = systemAction;
+ this.reportedUserAction = userAction;
+ this.reportedCaughtExceptions = new Throwable[1];
+ this.reportedCaughtExceptions[0] = caughtError;
+ }
+
+ /**
+ * This is the constructor used for creating a OMRSLogicErrorException when multiple unexpected errors
+ * have been caught.
+ *
+ * @param httpCode - http response code to use if this exception flows over a rest call
+ * @param className - name of class reporting error
+ * @param actionDescription - description of function it was performing when error detected
+ * @param errorMessage - description of error
+ * @param systemAction - actions of the system as a result of the error
+ * @param userAction - instructions for correcting the error
+ * @param caughtErrors - previous errors causing this exception
+ */
+ public OMRSLogicErrorException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction, Throwable[] caughtErrors)
+ {
+ super(httpCode, className, actionDescription, errorMessage, systemAction, userAction, caughtErrors);
+
+ this.reportedHTTPCode = httpCode;
+ this.reportingClassName = className;
+ this.reportingActionDescription = actionDescription;
+ this.reportedErrorMessage = errorMessage;
+ this.reportedSystemAction = systemAction;
+ this.reportedUserAction = userAction;
+ this.reportedCaughtExceptions = caughtErrors;
+ }
+
+ /**
+ * Return the HTTP response code to use with this exception.
+ *
+ * @return reportedHTTPCode
+ */
+ public int getReportedHTTPCode()
+ {
+ return reportedHTTPCode;
+ }
+
+ /**
+ * The class that created this exception.
+ *
+ * @return reportingClassName
+ */
+ public String getReportingClassName()
+ {
+ return reportingClassName;
+ }
+
+
+ /**
+ * The type of request that the class was performing when the condition occurred that resulted in this
+ * exception.
+ *
+ * @return reportingActionDescription
+ */
+ public String getReportingActionDescription()
+ {
+ return reportingActionDescription;
+ }
+
+
+ /**
+ * A formatted short description of the cause of the condition that resulted in this exception.
+ *
+ * @return reportedErrorMessage
+ */
+ public String getErrorMessage()
+ {
+ return reportedErrorMessage;
+ }
+
+
+ /**
+ * A description of the action that the system took as a result of the error condition.
+ *
+ * @return reportedSystemAction
+ */
+ public String getReportedSystemAction()
+ {
+ return reportedSystemAction;
+ }
+
+
+ /**
+ * A description of the action necessary to correct the error.
+ *
+ * @return reportedUserAction
+ */
+ public String getReportedUserAction()
+ {
+ return reportedUserAction;
+ }
+
+
+ /**
+ * An exception that was caught and wrapped by this exception. If a null is returned, then this exception is
+ * newly created and not the result of a previous exception.
+ *
+ * @return reportedCaughtException
+ */
+ public Throwable[] getReportedCaughtExceptions() { return reportedCaughtExceptions; }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/OMRSRuntimeException.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/OMRSRuntimeException.java b/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/OMRSRuntimeException.java
new file mode 100644
index 0000000..c72aaf6
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/OMRSRuntimeException.java
@@ -0,0 +1,181 @@
+/*
+ * 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.ffdc.exception;
+
+/**
+ * OMRSRuntimeException is used for all runtime exceptions generated by the Open Metadata Repository Services (OMRS).
+ * It is used in conjunction with the OMRSErrorCode to provide first failure data capture for these errors.
+ */
+public class OMRSRuntimeException extends RuntimeException
+{
+ /*
+ * These default values are only seen if this exception is initialized using one of its superclass constructors.
+ */
+ private int reportedHTTPCode = 500;
+ private String reportingClassName = "<Unknown>";
+ private String reportingActionDescription = "<Unknown>";
+ private String reportedErrorMessage = "<Unknown>";
+ private String reportedSystemAction = "<Unknown>";
+ private String reportedUserAction = "<Unknown>";
+ private Throwable [] reportedCaughtExceptions = null;
+
+
+ /**
+ * This is the typical constructor used for creating an OMRSRuntimeException.
+ *
+ * @param httpCode - http response code to use if this exception flows over a REST call
+ * @param className - name of class reporting error
+ * @param actionDescription - description of function it was performing when error detected
+ * @param errorMessage - description of error
+ * @param systemAction - actions of the system as a result of the error
+ * @param userAction - instructions for correcting the error
+ */
+ public OMRSRuntimeException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction)
+ {
+ super(errorMessage);
+ this.reportedHTTPCode = httpCode;
+ this.reportingClassName = className;
+ this.reportingActionDescription = actionDescription;
+ this.reportedErrorMessage = errorMessage;
+ this.reportedSystemAction = systemAction;
+ this.reportedUserAction = userAction;
+ }
+
+
+ /**
+ * This is the constructor used for creating a OMRSRuntimeException when an unexpected error has been caught.
+ *
+ * @param httpCode - http response code to use if this exception flows over a REST call
+ * @param className - name of class reporting error
+ * @param actionDescription - description of function it was performing when error detected
+ * @param errorMessage - description of error
+ * @param systemAction - actions of the system as a result of the error
+ * @param userAction - instructions for correcting the error
+ * @param caughtError - previous error causing this exception
+ */
+ public OMRSRuntimeException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction, Throwable caughtError)
+ {
+ super(errorMessage, caughtError);
+ this.reportedHTTPCode = httpCode;
+ this.reportingClassName = className;
+ this.reportingActionDescription = actionDescription;
+ this.reportedErrorMessage = errorMessage;
+ this.reportedSystemAction = systemAction;
+ this.reportedUserAction = userAction;
+ this.reportedCaughtExceptions = new Throwable[1];
+ this.reportedCaughtExceptions[0] = caughtError;
+ }
+
+ /**
+ * This is the constructor used for creating a OMRSRuntimeException when multiple unexpected errors
+ * have been caught.
+ *
+ * @param httpCode - http response code to use if this exception flows over a rest call
+ * @param className - name of class reporting error
+ * @param actionDescription - description of function it was performing when error detected
+ * @param errorMessage - description of error
+ * @param systemAction - actions of the system as a result of the error
+ * @param userAction - instructions for correcting the error
+ * @param caughtErrors - previous errors causing this exception
+ */
+ public OMRSRuntimeException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction, Throwable[] caughtErrors)
+ {
+ super(errorMessage, caughtErrors[0]);
+ this.reportedHTTPCode = httpCode;
+ this.reportingClassName = className;
+ this.reportingActionDescription = actionDescription;
+ this.reportedErrorMessage = errorMessage;
+ this.reportedSystemAction = systemAction;
+ this.reportedUserAction = userAction;
+ this.reportedCaughtExceptions = caughtErrors;
+ }
+
+ /**
+ * Return the HTTP response code to use with this exception.
+ *
+ * @return reportedHTTPCode
+ */
+ public int getReportedHTTPCode()
+ {
+ return reportedHTTPCode;
+ }
+
+ /**
+ * The class that created this exception.
+ *
+ * @return reportingClassName
+ */
+ public String getReportingClassName()
+ {
+ return reportingClassName;
+ }
+
+
+ /**
+ * The type of request that the class was performing when the condition occurred that resulted in this
+ * exception.
+ *
+ * @return reportingActionDescription
+ */
+ public String getReportingActionDescription()
+ {
+ return reportingActionDescription;
+ }
+
+
+ /**
+ * A formatted short description of the cause of the condition that resulted in this exception.
+ *
+ * @return reportedErrorMessage
+ */
+ public String getErrorMessage()
+ {
+ return reportedErrorMessage;
+ }
+
+
+ /**
+ * A description of the action that the system took as a result of the error condition.
+ *
+ * @return reportedSystemAction
+ */
+ public String getReportedSystemAction()
+ {
+ return reportedSystemAction;
+ }
+
+
+ /**
+ * A description of the action necessary to correct the error.
+ *
+ * @return reportedUserAction
+ */
+ public String getReportedUserAction()
+ {
+ return reportedUserAction;
+ }
+
+
+ /**
+ * An exception that was caught and wrapped by this exception. If a null is returned, then this exception is
+ * newly created and not the result of a previous exception.
+ *
+ * @return reportedCaughtException
+ */
+ public Throwable[] getReportedCaughtExceptions() { return reportedCaughtExceptions; }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/PagingErrorException.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/PagingErrorException.java b/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/PagingErrorException.java
new file mode 100644
index 0000000..5e91a58
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/PagingErrorException.java
@@ -0,0 +1,57 @@
+/*
+ * 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.ffdc.exception;
+
+/**
+ * The PagingErrorException is thrown by an OMRS Connector when the caller has passed invalid paging attributes
+ * on a search call.
+ */
+public class PagingErrorException extends OMRSCheckedExceptionBase
+{
+ /**
+ * This is the typical constructor used for creating a PagingErrorException.
+ *
+ * @param httpCode - http response code to use if this exception flows over a REST call
+ * @param className - name of class reporting error
+ * @param actionDescription - description of function it was performing when error detected
+ * @param errorMessage - description of error
+ * @param systemAction - actions of the system as a result of the error
+ * @param userAction - instructions for correcting the error
+ */
+ public PagingErrorException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction)
+ {
+ super(httpCode, className, actionDescription, errorMessage, systemAction, userAction);
+ }
+
+
+ /**
+ * This is the constructor used for creating a PagingErrorException that resulted from a previous error.
+ *
+ * @param httpCode - http response code to use if this exception flows over a REST call
+ * @param className - name of class reporting error
+ * @param actionDescription - description of function it was performing when error detected
+ * @param errorMessage - description of error
+ * @param systemAction - actions of the system as a result of the error
+ * @param userAction - instructions for correcting the error
+ * @param caughtError - the error that resulted in this exception.
+ * */
+ public PagingErrorException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction, Throwable caughtError)
+ {
+ super(httpCode, className, actionDescription, errorMessage, systemAction, userAction, caughtError);
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/PatchErrorException.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/PatchErrorException.java b/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/PatchErrorException.java
new file mode 100644
index 0000000..80e806b
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/PatchErrorException.java
@@ -0,0 +1,60 @@
+/*
+ * 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.ffdc.exception;
+
+/**
+ * PatchErrorException provides a checked exception for reporting that a typedef can not be updated because there are
+ * problems with the supplied TypeDefPatch. The OMRSErrorCode adds specific details for the cause/effect of the error.
+ */
+public class PatchErrorException extends OMRSCheckedExceptionBase
+{
+ /**
+ * This is the typical constructor for creating an PatchErrorException. It captures the essential details
+ * about the error, where it occurred and how to fix it.
+ *
+ * @param httpCode code to use across a REST interface
+ * @param className name of class reporting error
+ * @param actionDescription description of function it was performing when error detected
+ * @param errorMessage description of error
+ * @param systemAction actions of the system as a result of the error
+ * @param userAction instructions for correcting the error
+ */
+ public PatchErrorException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction)
+ {
+ super(httpCode, className, actionDescription, errorMessage, systemAction, userAction);
+ }
+
+
+ /**
+ * This constructor is used when an unexpected exception has been caught that needs to be wrapped in a
+ * PatchErrorException in order to add the essential details about the error, where it occurred and
+ * how to fix it.
+ *
+ * @param httpCode code to use across a REST interface
+ * @param className name of class reporting error
+ * @param actionDescription description of function it was performing when error detected
+ * @param errorMessage description of error
+ * @param systemAction actions of the system as a result of the error
+ * @param userAction instructions for correcting the error
+ * @param caughtException the exception/error that caused this exception to be raised
+ */
+ public PatchErrorException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction, Throwable caughtException)
+ {
+ super(httpCode, className, actionDescription, errorMessage, systemAction, userAction, caughtException);
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/PropertyErrorException.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/PropertyErrorException.java b/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/PropertyErrorException.java
new file mode 100644
index 0000000..9be99c2
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/PropertyErrorException.java
@@ -0,0 +1,57 @@
+/*
+ * 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.ffdc.exception;
+
+/**
+ * The PropertyErrorException is thrown by an OMRS Connector when the properties defined for a specific entity
+ * or relationship instance do not match the TypeDefs for the metadata collection.
+ */
+public class PropertyErrorException extends OMRSCheckedExceptionBase
+{
+ /**
+ * This is the typical constructor used for creating a PropertyErrorException.
+ *
+ * @param httpCode - http response code to use if this exception flows over a REST call
+ * @param className - name of class reporting error
+ * @param actionDescription - description of function it was performing when error detected
+ * @param errorMessage - description of error
+ * @param systemAction - actions of the system as a result of the error
+ * @param userAction - instructions for correcting the error
+ */
+ public PropertyErrorException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction)
+ {
+ super(httpCode, className, actionDescription, errorMessage, systemAction, userAction);
+ }
+
+
+ /**
+ * This is the constructor used for creating a PropertyErrorException that resulted from a previous error.
+ *
+ * @param httpCode - http response code to use if this exception flows over a REST call
+ * @param className - name of class reporting error
+ * @param actionDescription - description of function it was performing when error detected
+ * @param errorMessage - description of error
+ * @param systemAction - actions of the system as a result of the error
+ * @param userAction - instructions for correcting the error
+ * @param caughtError - the error that resulted in this exception.
+ * */
+ public PropertyErrorException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction, Throwable caughtError)
+ {
+ super(httpCode, className, actionDescription, errorMessage, systemAction, userAction, caughtError);
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/RelationshipConflictException.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/RelationshipConflictException.java b/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/RelationshipConflictException.java
new file mode 100644
index 0000000..c0b76c9
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/RelationshipConflictException.java
@@ -0,0 +1,60 @@
+/*
+ * 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.ffdc.exception;
+
+/**
+ * RelationshipConflictException provides a checked exception for reporting that a relationship can not be added because
+ * it conflicts with a relationship already stored. The OMRSErrorCode adds specific details for the cause/effect of the error.
+ */
+public class RelationshipConflictException extends OMRSCheckedExceptionBase
+{
+ /**
+ * This is the typical constructor for creating a RelationshipConflictException. It captures the essential details
+ * about the error, where it occurred and how to fix it.
+ *
+ * @param httpCode code to use across a REST interface
+ * @param className name of class reporting error
+ * @param actionDescription description of function it was performing when error detected
+ * @param errorMessage description of error
+ * @param systemAction actions of the system as a result of the error
+ * @param userAction instructions for correcting the error
+ */
+ public RelationshipConflictException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction)
+ {
+ super(httpCode, className, actionDescription, errorMessage, systemAction, userAction);
+ }
+
+
+ /**
+ * This constructor is used when an unexpected exception has been caught that needs to be wrapped in a
+ * RelationshipConflictException in order to add the essential details about the error, where it occurred and
+ * how to fix it.
+ *
+ * @param httpCode code to use across a REST interface
+ * @param className name of class reporting error
+ * @param actionDescription description of function it was performing when error detected
+ * @param errorMessage description of error
+ * @param systemAction actions of the system as a result of the error
+ * @param userAction instructions for correcting the error
+ * @param caughtException the exception/error that caused this exception to be raised
+ */
+ public RelationshipConflictException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction, Throwable caughtException)
+ {
+ super(httpCode, className, actionDescription, errorMessage, systemAction, userAction, caughtException);
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/RelationshipKnownException.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/RelationshipKnownException.java b/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/RelationshipKnownException.java
new file mode 100644
index 0000000..bf8559f
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/RelationshipKnownException.java
@@ -0,0 +1,57 @@
+/*
+ * 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.ffdc.exception;
+
+/**
+ * The RelationshipKnownException is thrown by an OMRS Connector when a specific relationship instance is added but this
+ * relationship is already stored in the metadata collection.
+ */
+public class RelationshipKnownException extends OMRSCheckedExceptionBase
+{
+ /**
+ * This is the typical constructor used for creating a RelationshipKnownException.
+ *
+ * @param httpCode - http response code to use if this exception flows over a REST call
+ * @param className - name of class reporting error
+ * @param actionDescription - description of function it was performing when error detected
+ * @param errorMessage - description of error
+ * @param systemAction - actions of the system as a result of the error
+ * @param userAction - instructions for correcting the error
+ */
+ public RelationshipKnownException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction)
+ {
+ super(httpCode, className, actionDescription, errorMessage, systemAction, userAction);
+ }
+
+
+ /**
+ * This is the constructor used for creating a RelationshipKnownException that resulted from a previous error.
+ *
+ * @param httpCode - http response code to use if this exception flows over a REST call
+ * @param className - name of class reporting error
+ * @param actionDescription - description of function it was performing when error detected
+ * @param errorMessage - description of error
+ * @param systemAction - actions of the system as a result of the error
+ * @param userAction - instructions for correcting the error
+ * @param caughtError - the error that resulted in this exception.
+ * */
+ public RelationshipKnownException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction, Throwable caughtError)
+ {
+ super(httpCode, className, actionDescription, errorMessage, systemAction, userAction, caughtError);
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/RelationshipNotDeletedException.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/RelationshipNotDeletedException.java b/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/RelationshipNotDeletedException.java
new file mode 100644
index 0000000..bc3f5c0
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/RelationshipNotDeletedException.java
@@ -0,0 +1,58 @@
+/*
+ * 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.ffdc.exception;
+
+/**
+ * RelationshipNotDeletedException is thrown by an OMRS Connector when a request is made to purge or restore a specific
+ * relationship instance and the entity is not in DELETED status.
+ *
+ */
+public class RelationshipNotDeletedException extends OMRSCheckedExceptionBase
+{
+ /**
+ * This is the typical constructor used for creating an RelationshipNotDeletedException.
+ *
+ * @param httpCode - http response code to use if this exception flows over a REST call
+ * @param className - name of class reporting error
+ * @param actionDescription - description of function it was performing when error detected
+ * @param errorMessage - description of error
+ * @param systemAction - actions of the system as a result of the error
+ * @param userAction - instructions for correcting the error
+ */
+ public RelationshipNotDeletedException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction)
+ {
+ super(httpCode, className, actionDescription, errorMessage, systemAction, userAction);
+ }
+
+
+ /**
+ * This is the constructor used for creating an RelationshipNotDeletedException that resulted from a previous error.
+ *
+ * @param httpCode - http response code to use if this exception flows over a REST call
+ * @param className - name of class reporting error
+ * @param actionDescription - description of function it was performing when error detected
+ * @param errorMessage - description of error
+ * @param systemAction - actions of the system as a result of the error
+ * @param userAction - instructions for correcting the error
+ * @param caughtError - the error that resulted in this exception.
+ * */
+ public RelationshipNotDeletedException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction, Throwable caughtError)
+ {
+ super(httpCode, className, actionDescription, errorMessage, systemAction, userAction, caughtError);
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/RelationshipNotKnownException.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/RelationshipNotKnownException.java b/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/RelationshipNotKnownException.java
new file mode 100644
index 0000000..209e675
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/RelationshipNotKnownException.java
@@ -0,0 +1,61 @@
+/*
+ * 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.ffdc.exception;
+
+/**
+ * RelationshipNotKnownException provides a checked exception for reporting when a requested relationship
+ * instance can not be found in the metadata collection.
+ * The OMRSErrorCode adds specific details for the cause/effect of the error.
+ */
+public class RelationshipNotKnownException extends OMRSCheckedExceptionBase
+{
+ /**
+ * This is the typical constructor for creating a RelationshipNotKnownException. It captures the essential details
+ * about the error, where it occurred and how to fix it.
+ *
+ * @param httpCode code to use across a REST interface
+ * @param className name of class reporting error
+ * @param actionDescription description of function it was performing when error detected
+ * @param errorMessage description of error
+ * @param systemAction actions of the system as a result of the error
+ * @param userAction instructions for correcting the error
+ */
+ public RelationshipNotKnownException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction)
+ {
+ super(httpCode, className, actionDescription, errorMessage, systemAction, userAction);
+ }
+
+
+ /**
+ * This constructor is used when an unexpected exception has been caught that needs to be wrapped in a
+ * RelationshipNotKnownException in order to add the essential details about the error, where it occurred and
+ * how to fix it.
+ *
+ * @param httpCode code to use across a REST interface
+ * @param className name of class reporting error
+ * @param actionDescription description of function it was performing when error detected
+ * @param errorMessage description of error
+ * @param systemAction actions of the system as a result of the error
+ * @param userAction instructions for correcting the error
+ * @param caughtException the exception/error that caused this exception to be raised
+ */
+ public RelationshipNotKnownException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction, Throwable caughtException)
+ {
+ super(httpCode, className, actionDescription, errorMessage, systemAction, userAction, caughtException);
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/RepositoryErrorException.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/RepositoryErrorException.java b/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/RepositoryErrorException.java
new file mode 100644
index 0000000..85d8821
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/RepositoryErrorException.java
@@ -0,0 +1,61 @@
+/*
+ * 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.ffdc.exception;
+
+/**
+ * RepositoryErrorException provides a checked exception for reporting situations where the metadata
+ * repository hosting a metadata collection is unable to perform a request.
+ * The OMRSErrorCode adds specific details for the cause/effect of the error.
+ */
+public class RepositoryErrorException extends OMRSCheckedExceptionBase
+{
+ /**
+ * This is the typical constructor for creating a RepositoryErrorException. It captures the essential details
+ * about the error, where it occurred and how to fix it.
+ *
+ * @param httpCode code to use across a REST interface
+ * @param className name of class reporting error
+ * @param actionDescription description of function it was performing when error detected
+ * @param errorMessage description of error
+ * @param systemAction actions of the system as a result of the error
+ * @param userAction instructions for correcting the error
+ */
+ public RepositoryErrorException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction)
+ {
+ super(httpCode, className, actionDescription, errorMessage, systemAction, userAction);
+ }
+
+
+ /**
+ * This constructor is used when an unexpected exception has been caught that needs to be wrapped in a
+ * RepositoryErrorException in order to add the essential details about the error, where it occurred and
+ * how to fix it.
+ *
+ * @param httpCode code to use across a REST interface
+ * @param className name of class reporting error
+ * @param actionDescription description of function it was performing when error detected
+ * @param errorMessage description of error
+ * @param systemAction actions of the system as a result of the error
+ * @param userAction instructions for correcting the error
+ * @param caughtException the exception/error that caused this exception to be raised
+ */
+ public RepositoryErrorException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction, Throwable caughtException)
+ {
+ super(httpCode, className, actionDescription, errorMessage, systemAction, userAction, caughtException);
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/StatusNotSupportedException.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/StatusNotSupportedException.java b/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/StatusNotSupportedException.java
new file mode 100644
index 0000000..916edf1
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/StatusNotSupportedException.java
@@ -0,0 +1,61 @@
+/*
+ * 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.ffdc.exception;
+
+/**
+ * StatusNotSupportedException provides a checked exception for reporting that the metadata repository hosting
+ * a metadata collection is not able to support the requested status.
+ * The OMRSErrorCode adds specific details for the cause/effect of the error.
+ */
+public class StatusNotSupportedException extends OMRSCheckedExceptionBase
+{
+ /**
+ * This is the typical constructor for creating an StatusNotSupportedException. It captures the essential details
+ * about the error, where it occurred and how to fix it.
+ *
+ * @param httpCode code to use across a REST interface
+ * @param className name of class reporting error
+ * @param actionDescription description of function it was performing when error detected
+ * @param errorMessage description of error
+ * @param systemAction actions of the system as a result of the error
+ * @param userAction instructions for correcting the error
+ */
+ public StatusNotSupportedException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction)
+ {
+ super(httpCode, className, actionDescription, errorMessage, systemAction, userAction);
+ }
+
+
+ /**
+ * This constructor is used when an unexpected exception has been caught that needs to be wrapped in an
+ * StatusNotSupportedException in order to add the essential details about the error, where it occurred and
+ * how to fix it.
+ *
+ * @param httpCode code to use across a REST interface
+ * @param className name of class reporting error
+ * @param actionDescription description of function it was performing when error detected
+ * @param errorMessage description of error
+ * @param systemAction actions of the system as a result of the error
+ * @param userAction instructions for correcting the error
+ * @param caughtException the exception/error that caused this exception to be raised
+ */
+ public StatusNotSupportedException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction, Throwable caughtException)
+ {
+ super(httpCode, className, actionDescription, errorMessage, systemAction, userAction, caughtException);
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/TypeDefConflictException.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/TypeDefConflictException.java b/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/TypeDefConflictException.java
new file mode 100644
index 0000000..5831538
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/TypeDefConflictException.java
@@ -0,0 +1,60 @@
+/*
+ * 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.ffdc.exception;
+
+/**
+ * TypeDefConflictException provides a checked exception for reporting that a typedef can not be added because
+ * it conflicts with a TypeDef already stored. The OMRSErrorCode adds specific details for the cause/effect of the error.
+ */
+public class TypeDefConflictException extends OMRSCheckedExceptionBase
+{
+ /**
+ * This is the typical constructor for creating a TypeDefConflictException. It captures the essential details
+ * about the error, where it occurred and how to fix it.
+ *
+ * @param httpCode code to use across a REST interface
+ * @param className name of class reporting error
+ * @param actionDescription description of function it was performing when error detected
+ * @param errorMessage description of error
+ * @param systemAction actions of the system as a result of the error
+ * @param userAction instructions for correcting the error
+ */
+ public TypeDefConflictException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction)
+ {
+ super(httpCode, className, actionDescription, errorMessage, systemAction, userAction);
+ }
+
+
+ /**
+ * This constructor is used when an unexpected exception has been caught that needs to be wrapped in a
+ * TypeDefConflictException in order to add the essential details about the error, where it occurred and
+ * how to fix it.
+ *
+ * @param httpCode code to use across a REST interface
+ * @param className name of class reporting error
+ * @param actionDescription description of function it was performing when error detected
+ * @param errorMessage description of error
+ * @param systemAction actions of the system as a result of the error
+ * @param userAction instructions for correcting the error
+ * @param caughtException the exception/error that caused this exception to be raised
+ */
+ public TypeDefConflictException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction, Throwable caughtException)
+ {
+ super(httpCode, className, actionDescription, errorMessage, systemAction, userAction, caughtException);
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/TypeDefInUseException.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/TypeDefInUseException.java b/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/TypeDefInUseException.java
new file mode 100644
index 0000000..9f9019e
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/TypeDefInUseException.java
@@ -0,0 +1,60 @@
+/*
+ * 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.ffdc.exception;
+
+/**
+ * TypeDefInUseException provides a checked exception for reporting that a typedef can not be deleted because there are
+ * instances currently using it. The OMRSErrorCode adds specific details for the cause/effect of the error.
+ */
+public class TypeDefInUseException extends OMRSCheckedExceptionBase
+{
+ /**
+ * This is the typical constructor for creating an TypeDefInUseException. It captures the essential details
+ * about the error, where it occurred and how to fix it.
+ *
+ * @param httpCode code to use across a REST interface
+ * @param className name of class reporting error
+ * @param actionDescription description of function it was performing when error detected
+ * @param errorMessage description of error
+ * @param systemAction actions of the system as a result of the error
+ * @param userAction instructions for correcting the error
+ */
+ public TypeDefInUseException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction)
+ {
+ super(httpCode, className, actionDescription, errorMessage, systemAction, userAction);
+ }
+
+
+ /**
+ * This constructor is used when an unexpected exception has been caught that needs to be wrapped in a
+ * TypeDefInUseException in order to add the essential details about the error, where it occurred and
+ * how to fix it.
+ *
+ * @param httpCode code to use across a REST interface
+ * @param className name of class reporting error
+ * @param actionDescription description of function it was performing when error detected
+ * @param errorMessage description of error
+ * @param systemAction actions of the system as a result of the error
+ * @param userAction instructions for correcting the error
+ * @param caughtException the exception/error that caused this exception to be raised
+ */
+ public TypeDefInUseException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction, Throwable caughtException)
+ {
+ super(httpCode, className, actionDescription, errorMessage, systemAction, userAction, caughtException);
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/TypeDefKnownException.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/TypeDefKnownException.java b/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/TypeDefKnownException.java
new file mode 100644
index 0000000..96f2374
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/TypeDefKnownException.java
@@ -0,0 +1,60 @@
+/*
+ * 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.ffdc.exception;
+
+/**
+ * TypeDefKnownException provides a checked exception for reporting that a type definition (TypeDef) can not be added because
+ * it is already known to the repository. The OMRSErrorCode adds specific details for the cause/effect of the error.
+ */
+public class TypeDefKnownException extends OMRSCheckedExceptionBase
+{
+ /**
+ * This is the typical constructor for creating an TypeDefKnownException. It captures the essential details
+ * about the error, where it occurred and how to fix it.
+ *
+ * @param httpCode code to use across a REST interface
+ * @param className name of class reporting error
+ * @param actionDescription description of function it was performing when error detected
+ * @param errorMessage description of error
+ * @param systemAction actions of the system as a result of the error
+ * @param userAction instructions for correcting the error
+ */
+ public TypeDefKnownException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction)
+ {
+ super(httpCode, className, actionDescription, errorMessage, systemAction, userAction);
+ }
+
+
+ /**
+ * This constructor is used when an unexpected exception has been caught that needs to be wrapped in a
+ * TypeDefKnownException in order to add the essential details about the error, where it occurred and
+ * how to fix it.
+ *
+ * @param httpCode code to use across a REST interface
+ * @param className name of class reporting error
+ * @param actionDescription description of function it was performing when error detected
+ * @param errorMessage description of error
+ * @param systemAction actions of the system as a result of the error
+ * @param userAction instructions for correcting the error
+ * @param caughtException the exception/error that caused this exception to be raised
+ */
+ public TypeDefKnownException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction, Throwable caughtException)
+ {
+ super(httpCode, className, actionDescription, errorMessage, systemAction, userAction, caughtException);
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/TypeDefNotKnownException.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/TypeDefNotKnownException.java b/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/TypeDefNotKnownException.java
new file mode 100644
index 0000000..063dfdc
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/TypeDefNotKnownException.java
@@ -0,0 +1,60 @@
+/*
+ * 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.ffdc.exception;
+
+/**
+ * TypeDefNotKnownException provides a checked exception for reporting that a requested typedef can not be found.
+ * The OMRSErrorCode adds specific details for the cause/effect of the error.
+ */
+public class TypeDefNotKnownException extends OMRSCheckedExceptionBase
+{
+ /**
+ * This is the typical constructor for creating a TypeDefNotKnownException. It captures the essential details
+ * about the error, where it occurred and how to fix it.
+ *
+ * @param httpCode code to use across a REST interface
+ * @param className name of class reporting error
+ * @param actionDescription description of function it was performing when error detected
+ * @param errorMessage description of error
+ * @param systemAction actions of the system as a result of the error
+ * @param userAction instructions for correcting the error
+ */
+ public TypeDefNotKnownException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction)
+ {
+ super(httpCode, className, actionDescription, errorMessage, systemAction, userAction);
+ }
+
+
+ /**
+ * This constructor is used when an unexpected exception has been caught that needs to be wrapped in a
+ * TypeDefNotKnownException in order to add the essential details about the error, where it occurred and
+ * how to fix it.
+ *
+ * @param httpCode code to use across a REST interface
+ * @param className name of class reporting error
+ * @param actionDescription description of function it was performing when error detected
+ * @param errorMessage description of error
+ * @param systemAction actions of the system as a result of the error
+ * @param userAction instructions for correcting the error
+ * @param caughtException the exception/error that caused this exception to be raised
+ */
+ public TypeDefNotKnownException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction, Throwable caughtException)
+ {
+ super(httpCode, className, actionDescription, errorMessage, systemAction, userAction, caughtException);
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/TypeDefNotSupportedException.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/TypeDefNotSupportedException.java b/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/TypeDefNotSupportedException.java
new file mode 100644
index 0000000..46bf124
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/TypeDefNotSupportedException.java
@@ -0,0 +1,60 @@
+/*
+ * 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.ffdc.exception;
+
+/**
+ * TypeDefNotSupportedException provides a checked exception for reporting that a typedef can not be added because
+ * the local repository can not support it. The OMRSErrorCode adds specific details for the cause/effect of the error.
+ */
+public class TypeDefNotSupportedException extends OMRSCheckedExceptionBase
+{
+ /**
+ * This is the typical constructor for creating a TypeDefNotSupportedException. It captures the essential details
+ * about the error, where it occurred and how to fix it.
+ *
+ * @param httpCode code to use across a REST interface
+ * @param className name of class reporting error
+ * @param actionDescription description of function it was performing when error detected
+ * @param errorMessage description of error
+ * @param systemAction actions of the system as a result of the error
+ * @param userAction instructions for correcting the error
+ */
+ public TypeDefNotSupportedException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction)
+ {
+ super(httpCode, className, actionDescription, errorMessage, systemAction, userAction);
+ }
+
+
+ /**
+ * This constructor is used when an unexpected exception has been caught that needs to be wrapped in a
+ * TypeDefNotSupportedException in order to add the essential details about the error, where it occurred and
+ * how to fix it.
+ *
+ * @param httpCode code to use across a REST interface
+ * @param className name of class reporting error
+ * @param actionDescription description of function it was performing when error detected
+ * @param errorMessage description of error
+ * @param systemAction actions of the system as a result of the error
+ * @param userAction instructions for correcting the error
+ * @param caughtException the exception/error that caused this exception to be raised
+ */
+ public TypeDefNotSupportedException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction, Throwable caughtException)
+ {
+ super(httpCode, className, actionDescription, errorMessage, systemAction, userAction, caughtException);
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/TypeErrorException.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/TypeErrorException.java b/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/TypeErrorException.java
new file mode 100644
index 0000000..e56f824
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/TypeErrorException.java
@@ -0,0 +1,57 @@
+/*
+ * 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.ffdc.exception;
+
+/**
+ * The TypeErrorException is thrown by an OMRS Connector when the requested type for an instance is not represented by
+ * a known TypeDef.
+ */
+public class TypeErrorException extends OMRSCheckedExceptionBase
+{
+ /**
+ * This is the typical constructor used for creating a TypeErrorException.
+ *
+ * @param httpCode - http response code to use if this exception flows over a REST call
+ * @param className - name of class reporting error
+ * @param actionDescription - description of function it was performing when error detected
+ * @param errorMessage - description of error
+ * @param systemAction - actions of the system as a result of the error
+ * @param userAction - instructions for correcting the error
+ */
+ public TypeErrorException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction)
+ {
+ super(httpCode, className, actionDescription, errorMessage, systemAction, userAction);
+ }
+
+
+ /**
+ * This is the constructor used for creating a TypeErrorException that resulted from a previous error.
+ *
+ * @param httpCode - http response code to use if this exception flows over a REST call
+ * @param className - name of class reporting error
+ * @param actionDescription - description of function it was performing when error detected
+ * @param errorMessage - description of error
+ * @param systemAction - actions of the system as a result of the error
+ * @param userAction - instructions for correcting the error
+ * @param caughtError - the error that resulted in this exception.
+ * */
+ public TypeErrorException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction, Throwable caughtError)
+ {
+ super(httpCode, className, actionDescription, errorMessage, systemAction, userAction, caughtError);
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/UserNotAuthorizedException.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/UserNotAuthorizedException.java b/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/UserNotAuthorizedException.java
new file mode 100644
index 0000000..3404056
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/UserNotAuthorizedException.java
@@ -0,0 +1,57 @@
+/*
+ * 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.ffdc.exception;
+
+/**
+ * The UserNotAuthorizedException is thrown by an OMRS Connector when the supplied UserId is not permitted to
+ * perform a specific operation on the metadata collection.
+ */
+public class UserNotAuthorizedException extends OMRSCheckedExceptionBase
+{
+ /**
+ * This is the typical constructor used for creating a UserNotAuthorizedException.
+ *
+ * @param httpCode - http response code to use if this exception flows over a REST call
+ * @param className - name of class reporting error
+ * @param actionDescription - description of function it was performing when error detected
+ * @param errorMessage - description of error
+ * @param systemAction - actions of the system as a result of the error
+ * @param userAction - instructions for correcting the error
+ */
+ public UserNotAuthorizedException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction)
+ {
+ super(httpCode, className, actionDescription, errorMessage, systemAction, userAction);
+ }
+
+
+ /**
+ * This is the constructor used for creating a UserNotAuthorizedException that resulted from a previous error.
+ *
+ * @param httpCode - http response code to use if this exception flows over a REST call
+ * @param className - name of class reporting error
+ * @param actionDescription - description of function it was performing when error detected
+ * @param errorMessage - description of error
+ * @param systemAction - actions of the system as a result of the error
+ * @param userAction - instructions for correcting the error
+ * @param caughtError - the error that resulted in this exception.
+ * */
+ public UserNotAuthorizedException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction, Throwable caughtError)
+ {
+ super(httpCode, className, actionDescription, errorMessage, systemAction, userAction, caughtError);
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/localrepository/OMRSLocalRepository.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/localrepository/OMRSLocalRepository.java b/omrs/src/main/java/org/apache/atlas/omrs/localrepository/OMRSLocalRepository.java
new file mode 100644
index 0000000..459eaa9
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/localrepository/OMRSLocalRepository.java
@@ -0,0 +1,83 @@
+/*
+ * 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.localrepository;
+
+import org.apache.atlas.ocf.properties.Connection;
+import org.apache.atlas.omrs.eventmanagement.events.OMRSInstanceEventProcessor;
+import org.apache.atlas.omrs.eventmanagement.OMRSRepositoryEventManager;
+import org.apache.atlas.omrs.eventmanagement.events.OMRSTypeDefEventProcessor;
+import org.apache.atlas.omrs.localrepository.repositorycontentmanager.OMRSTypeDefValidator;
+
+
+/**
+ * OMRSLocalRepository is an interface used by the OMRS components to retrieve information about the local
+ * repository, to register listeners and to get access to the connector for the local repository.
+ */
+public interface OMRSLocalRepository
+{
+ /**
+ * Returns the unique identifier (guid) of the local repository's metadata collection.
+ *
+ * @return String guid
+ */
+ String getMetadataCollectionId();
+
+
+ /**
+ * Returns the Connection to the local repository that can be used by remote servers to create
+ * an OMRS repository connector to call this server in order to access the local repository.
+ *
+ * @return Connection object
+ */
+ Connection getLocalRepositoryRemoteConnection();
+
+
+ /**
+ * Return the TypeDefManager. This is used to validate that a list of type definitions (TypeDefs) are
+ * compatible with the local repository.
+ *
+ * @return OMRSTypeDefValidator object for the local repository.
+ */
+ OMRSTypeDefValidator getTypeDefValidator();
+
+
+ /**
+ * Return the event manager that the local repository uses to
+ *
+ * @return outbound repository event manager
+ */
+ OMRSRepositoryEventManager getOutboundRepositoryEventManager();
+
+
+ /**
+ * Return the TypeDef event processor that should be passed all incoming TypeDef events received
+ * from the cohorts that this server is a member of.
+ *
+ * @return OMRSTypeDefEventProcessor for the local repository.
+ */
+ OMRSTypeDefEventProcessor getIncomingTypeDefEventProcessor();
+
+
+ /**
+ * Return the instance event processor that should be passed all incoming instance events received
+ * from the cohorts that this server is a member of.
+ *
+ * @return OMRSInstanceEventProcessor for the local repository.
+ */
+ OMRSInstanceEventProcessor getIncomingInstanceEventProcessor();
+}
[03/30] atlas git commit: ATLAS-2246: OMRS Connector API plus REST
and IGC Connector skeleton - 15th February 2018
Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/TypeDefPatch.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/TypeDefPatch.java b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/TypeDefPatch.java
new file mode 100644
index 0000000..b6dcf23
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/TypeDefPatch.java
@@ -0,0 +1,399 @@
+/*
+ * 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.metadatacollection.properties.typedefs;
+
+import org.apache.atlas.omrs.metadatacollection.properties.instances.InstanceStatus;
+
+import java.util.ArrayList;
+import java.util.Map;
+
+
+/**
+ * TypeDefPatch describes a change (patch) to a typeDef's properties, options, external standards mappings or
+ * list of valid instance statuses.
+ * A patch can be applied to an EntityDef, RelationshipDef or ClassificationDef.
+ * Changes to a TypeDef's category or superclasses requires a new type definition.
+ * In addition it is not possible to delete an attribute through a patch.
+ */
+public class TypeDefPatch extends TypeDefElementHeader
+{
+ private TypeDefPatchAction action = null;
+ private String typeDefGUID = null;
+ private String typeName = null;
+ private long applyToVersion = 0L;
+ private long updateToVersion = 0L;
+ private String newVersionName = null;
+ private String description = null;
+ private String descriptionGUID = null;
+ private ArrayList<TypeDefAttribute> typeDefAttributes = null;
+ private Map<String, String> typeDefOptions = null;
+ private ArrayList<ExternalStandardMapping> externalStandardMappings = null;
+ private ArrayList<InstanceStatus> validInstanceStatusList = null;
+
+ private static final long serialVersionUID = 1L;
+
+
+ /**
+ * Default constructor relies on the initialization of variables in their declaration.
+ */
+ public TypeDefPatch()
+ {
+ }
+
+
+ /**
+ * Return the type of action that this patch requires.
+ *
+ * @return TypeDefPatchAction enum
+ */
+ public TypeDefPatchAction getAction() {
+ return action;
+ }
+
+
+ /**
+ * Set up the type of action that this patch requires.
+ *
+ * @param action - TypeDefPatchAction enum
+ */
+ public void setAction(TypeDefPatchAction action) {
+ this.action = action;
+ }
+
+
+ /**
+ * Return the unique identifier for the affected TypeDef.
+ *
+ * @return String guid
+ */
+ public String getTypeDefGUID()
+ {
+ return typeDefGUID;
+ }
+
+
+ /**
+ * Set up the unique identifier for the affected TypeDef.
+ *
+ * @param typeDefGUID - String guid
+ */
+ public void setTypeDefGUID(String typeDefGUID)
+ {
+ this.typeDefGUID = typeDefGUID;
+ }
+
+
+ /**
+ * Return the unique name for the affected TypeDef.
+ *
+ * @return String name
+ */
+ public String getTypeName() {
+ return typeName;
+ }
+
+
+ /**
+ * Set up the unique name for the affected TypeDef.
+ *
+ * @param typeName - String name
+ */
+ public void setTypeName(String typeName) {
+ this.typeName = typeName;
+ }
+
+
+ /**
+ * Return the version number of the TypeDef that this patch applies to.
+ *
+ * @return long version number
+ */
+ public long getApplyToVersion() {
+ return applyToVersion;
+ }
+
+
+ /**
+ * Set up the version number of the TypeDef that this patch applies to.
+ *
+ * @param applyToVersion - long version number
+ */
+ public void setApplyToVersion(long applyToVersion) {
+ this.applyToVersion = applyToVersion;
+ }
+
+
+ /**
+ * Return the new version number of the TypeDef.
+ *
+ * @return long version number
+ */
+ public long getUpdateToVersion() {
+ return updateToVersion;
+ }
+
+
+ /**
+ * Set up the new versionName of the TypeDef.
+ *
+ * @param updateToVersion long version number
+ */
+ public void setUpdateToVersion(long updateToVersion) {
+ this.updateToVersion = updateToVersion;
+ }
+
+
+ /**
+ * Return the new version name ot use once the patch is applied.
+ *
+ * @return String version name
+ */
+ public String getNewVersionName()
+ {
+ return newVersionName;
+ }
+
+
+ /**
+ * Set up the new version name ot use once the patch is applied.
+ *
+ * @param newVersionName - String version name
+ */
+ public void setNewVersionName(String newVersionName)
+ {
+ this.newVersionName = newVersionName;
+ }
+
+
+ /**
+ * Return the new description for the TypeDef.
+ *
+ * @return String description
+ */
+ public String getDescription()
+ {
+ return description;
+ }
+
+
+ /**
+ * Set up the new description for the TypeDef
+ *
+ * @param description - String description
+ */
+ public void setDescription(String description)
+ {
+ this.description = description;
+ }
+
+
+ /**
+ * Return the unique identifier for the new glossary term that describes the TypeDef.
+ *
+ * @return String unique identifier
+ */
+ public String getDescriptionGUID()
+ {
+ return descriptionGUID;
+ }
+
+
+ /**
+ * Set up the unique identifier for the new glossary term that describes the TypeDef.
+ *
+ * @param descriptionGUID - String unique identifier
+ */
+ public void setDescriptionGUID(String descriptionGUID)
+ {
+ this.descriptionGUID = descriptionGUID;
+ }
+
+
+ /**
+ * Return the list of typeDefAttributes that are either new or changing.
+ *
+ * @return list of AttributeDefs
+ */
+ public ArrayList<TypeDefAttribute> getTypeDefAttributes() {
+ return typeDefAttributes;
+ }
+
+
+ /**
+ * Set up the list of typeDefAttributes that are either new or changing.
+ *
+ * @param typeDefAttributes - list of AttributeDefs
+ */
+ public void setTypeDefAttributes(ArrayList<TypeDefAttribute> typeDefAttributes)
+ {
+ this.typeDefAttributes = typeDefAttributes;
+ }
+
+
+ /**
+ * Return the TypeDef options for the patch.
+ *
+ * @return map of TypeDef Options that are new or changing.
+ */
+ public Map<String, String> getTypeDefOptions() {
+ return typeDefOptions;
+ }
+
+
+ /**
+ * Set up the TypeDef options for the patch.
+ *
+ * @param typeDefOptions - map of TypeDef Options that are new or changing.
+ */
+ public void setTypeDefOptions(Map<String, String> typeDefOptions) {
+ this.typeDefOptions = typeDefOptions;
+ }
+
+
+ /**
+ * Return the list of External Standards Mappings that are either new or changing.
+ *
+ * @return list of external standards mappings
+ */
+ public ArrayList<ExternalStandardMapping> getExternalStandardMappings()
+ {
+ return externalStandardMappings;
+ }
+
+
+ /**
+ * Set up the list of External Standards Mappings that are either new or changing.
+ *
+ * @param externalStandardMappings list of external standards mappings
+ */
+ public void setExternalStandardMappings(ArrayList<ExternalStandardMapping> externalStandardMappings)
+ {
+ this.externalStandardMappings = externalStandardMappings;
+ }
+
+
+ /**
+ * Return the list of valid statuses for an instance of this TypeDef.
+ *
+ * @return list of valid statuses
+ */
+ public ArrayList<InstanceStatus> getValidInstanceStatusList()
+ {
+ return validInstanceStatusList;
+ }
+
+
+ /**
+ * Set up the list of valid statuses for an instance of this TypeDef.
+ *
+ * @param validInstanceStatusList - list of valid statuses
+ */
+ public void setValidInstanceStatusList(ArrayList<InstanceStatus> validInstanceStatusList)
+ {
+ this.validInstanceStatusList = validInstanceStatusList;
+ }
+
+
+ /**
+ * Standard toString method.
+ *
+ * @return JSON style description of variables.
+ */
+ @Override
+ public String toString()
+ {
+ return "TypeDefPatch{" +
+ "action=" + action +
+ ", typeDefGUID='" + typeDefGUID + '\'' +
+ ", typeName='" + typeName + '\'' +
+ ", applyToVersion=" + applyToVersion +
+ ", updateToVersion=" + updateToVersion +
+ ", newVersionName='" + newVersionName + '\'' +
+ ", typeDefAttributes=" + typeDefAttributes +
+ ", typeDefOptions=" + typeDefOptions +
+ ", externalStandardMappings=" + externalStandardMappings +
+ ", validInstanceStatusList=" + validInstanceStatusList +
+ '}';
+ }
+
+ /**
+ * Validated that the GUID, name and versionName of a TypeDef are equal.
+ *
+ * @param object to test
+ * @return boolean flag to say object is the same TypeDefPatch
+ */
+ @Override
+ public boolean equals(Object object)
+ {
+ if (this == object)
+ {
+ return true;
+ }
+ if (object == null || getClass() != object.getClass())
+ {
+ return false;
+ }
+
+ TypeDefPatch that = (TypeDefPatch) object;
+
+ if (applyToVersion != that.applyToVersion)
+ {
+ return false;
+ }
+ if (updateToVersion != that.updateToVersion)
+ {
+ return false;
+ }
+ if (action != that.action)
+ {
+ return false;
+ }
+ if (typeDefGUID != null ? !typeDefGUID.equals(that.typeDefGUID) : that.typeDefGUID != null)
+ {
+ return false;
+ }
+ if (typeName != null ? !typeName.equals(that.typeName) : that.typeName != null)
+ {
+ return false;
+ }
+ if (typeDefAttributes != null ? !typeDefAttributes.equals(that.typeDefAttributes) : that.typeDefAttributes != null)
+ {
+ return false;
+ }
+ if (typeDefOptions != null ? !typeDefOptions.equals(that.typeDefOptions) : that.typeDefOptions != null)
+ {
+ return false;
+ }
+ if (externalStandardMappings != null ? !externalStandardMappings.equals(that.externalStandardMappings) : that.externalStandardMappings != null)
+ {
+ return false;
+ }
+ return validInstanceStatusList != null ? validInstanceStatusList.equals(that.validInstanceStatusList) : that.validInstanceStatusList == null;
+ }
+
+ /**
+ * Using the GUID as a hashcode - it should be unique if all connected metadata repositories are behaving properly.
+ *
+ * @return int hash code
+ */
+ @Override
+ public int hashCode()
+ {
+ return typeDefGUID != null ? typeDefGUID.hashCode() : 0;
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/TypeDefPatchAction.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/TypeDefPatchAction.java b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/TypeDefPatchAction.java
new file mode 100644
index 0000000..c89c42a
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/TypeDefPatchAction.java
@@ -0,0 +1,103 @@
+/*
+ * 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.metadatacollection.properties.typedefs;
+
+
+/**
+ * TypeDefPatchAction defines the types of actions that can be taken to update a TypeDef. These changes are safe
+ * to make while there are active instances using them. If more extensive changes need to be made to a TypeDef
+ * then a new TypeDef should be defined.
+ */
+public enum TypeDefPatchAction
+{
+ ADD_ATTRIBUTES (1, "AddAttributes",
+ "Add one or more new attributes to a TypeDef"),
+ ADD_OPTIONS (2, "AddOptions",
+ "Extend the current list of options for a TypeDef. These options are used to " +
+ "help process metadata instances. " +
+ "They may be different in each TypeDef."),
+ UPDATE_OPTIONS (3, "UpdateOptions",
+ "Replace the options from a TypeDef. These options are used to help " +
+ "process metadata instances. " +
+ "They may be different in each TypeDef."),
+ DELETE_OPTIONS (4, "DeleteOptions",
+ "Delete the options from a TypeDef. These options are used to help " +
+ "process metadata instances. " +
+ "They may be different in each TypeDef."),
+ ADD_EXTERNAL_STANDARDS (5, "AddExternalStandardMapping",
+ "Add a mapping to an external standard either for the TypeDef or the supplied attributes."),
+ UPDATE_EXTERNAL_STANDARDS (6, "UpdateExternalStandardMapping",
+ "Update a mapping to an external standard either for the TypeDef or the supplied attributes."),
+ DELETE_EXTERNAL_STANDARDS (7, "DeleteExternalStandardMapping",
+ "Remove a mapping to an external standard either for the TypeDef or the supplied attributes."),
+ UPDATE_DESCRIPTIONS (8, "UpdateDescriptions",
+ "Update the descriptions and descriptionGUIDs of the TypeDef and its attributes.");
+
+
+ private int patchActionCode;
+ private String patchActionName;
+ private String patchActionDescription;
+
+
+ /**
+ * Constructor to set up a single instances of the enum.
+ *
+ * @param patchActionCode - numeric code for the patch action
+ * @param patchActionName - descriptive name for the patch action
+ * @param patchActionDescription - description of the patch action
+ */
+ TypeDefPatchAction(int patchActionCode, String patchActionName, String patchActionDescription)
+ {
+ this.patchActionCode = patchActionCode;
+ this.patchActionName = patchActionName;
+ this.patchActionDescription = patchActionDescription;
+ }
+
+
+ /**
+ * Return the code value for the patch action.
+ *
+ * @return int code
+ */
+ public int getPatchActionCode()
+ {
+ return patchActionCode;
+ }
+
+
+ /**
+ * Return the descriptive name for the patch action.
+ *
+ * @return String name
+ */
+ public String getPatchActionName()
+ {
+ return patchActionName;
+ }
+
+
+ /**
+ * Return the description of the patch action.
+ *
+ * @return String description
+ */
+ public String getPatchActionDescription()
+ {
+ return patchActionDescription;
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/TypeDefProperties.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/TypeDefProperties.java b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/TypeDefProperties.java
new file mode 100644
index 0000000..cfb549e
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/TypeDefProperties.java
@@ -0,0 +1,154 @@
+/*
+ * 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.metadatacollection.properties.typedefs;
+
+import org.apache.atlas.omrs.ffdc.OMRSErrorCode;
+import org.apache.atlas.omrs.ffdc.exception.OMRSRuntimeException;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+
+/**
+ * The TypeDefProperties class provides support for arbitrary properties that belong to a TypeDef object.
+ * It is used for searching the TypeDefs.
+ * It wraps a java.util.Map map object built around HashMap.
+ */
+public class TypeDefProperties extends TypeDefElementHeader
+{
+ private Map<String,Object> typeDefProperties = new HashMap<>();
+
+
+ /**
+ * Typical constructor
+ */
+ public TypeDefProperties()
+ {
+ /*
+ * Nothing to do
+ */
+ }
+
+
+ /**
+ * Copy/clone Constructor.
+ *
+ * @param templateProperties - template object to copy.
+ */
+ public TypeDefProperties(TypeDefProperties templateProperties)
+ {
+ /*
+ * An empty properties object is created in the private variable declaration so nothing to do.
+ */
+ if (templateProperties != null)
+ {
+ /*
+ * Process templateProperties if they are not null
+ */
+ Iterator<String> propertyNames = templateProperties.getPropertyNames();
+
+ if (propertyNames != null)
+ {
+ while (propertyNames.hasNext())
+ {
+ String newPropertyName = propertyNames.next();
+ Object newPropertyValue = templateProperties.getProperty(newPropertyName);
+
+ typeDefProperties.put(newPropertyName, newPropertyValue);
+ }
+ }
+ }
+ }
+
+
+ /**
+ * Returns a list of the instance properties for the element.
+ * If no stored properties are present then null is returned.
+ *
+ * @return list of properties
+ */
+ public Iterator<String> getPropertyNames()
+ {
+ return typeDefProperties.keySet().iterator();
+ }
+
+
+ /**
+ * Returns the requested instance property for the element.
+ * If no stored property with that name is present then null is returned.
+ *
+ * @param name - String name of the property to return.
+ * @return requested property value.
+ */
+ public Object getProperty(String name)
+ {
+ return typeDefProperties.get(name);
+ }
+
+
+ /**
+ * Adds or updates an instance property.
+ * If a null is supplied for the property name, an OMRS runtime exception is thrown.
+ * If a null is supplied for the property value, the property is removed.
+ *
+ * @param newPropertyName - name
+ * @param newPropertyValue - value
+ */
+ public void setProperty(String newPropertyName, Object newPropertyValue)
+ {
+ if (newPropertyName == null)
+ {
+ /*
+ * Build and throw exception.
+ */
+ OMRSErrorCode errorCode = OMRSErrorCode.NULL_PROPERTY_NAME;
+ String errorMessage = errorCode.getErrorMessageId()
+ + errorCode.getFormattedErrorMessage();
+
+ throw new OMRSRuntimeException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ "setProperty",
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+ else if (newPropertyValue == null)
+ {
+ typeDefProperties.remove(newPropertyName);
+ }
+ else
+ {
+ typeDefProperties.put(newPropertyName, newPropertyValue);
+ }
+ }
+
+
+ /**
+ * Standard toString method.
+ *
+ * @return JSON style description of variables.
+ */
+ @Override
+ public String toString()
+ {
+ return "TypeDefProperties{" +
+ "typeDefProperties=" + typeDefProperties +
+ '}';
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/TypeDefSummary.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/TypeDefSummary.java b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/TypeDefSummary.java
new file mode 100644
index 0000000..864c82d
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/TypeDefSummary.java
@@ -0,0 +1,168 @@
+/*
+ * 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.metadatacollection.properties.typedefs;
+
+
+/**
+ * The TypeDefSummary holds basic identifying information for a specific TypeDef. It is used in
+ * the registration process between repositories.
+ */
+public class TypeDefSummary extends TypeDefLink
+{
+ protected long version = 0L;
+ protected String versionName = null;
+ protected TypeDefCategory category = TypeDefCategory.UNKNOWN_DEF;
+
+
+ /**
+ * Default constructor
+ */
+ public TypeDefSummary()
+ {
+ super();
+ }
+
+
+ /**
+ * Typical constructor is passed the properties of the typedef being constructed.
+ *
+ * @param category - category of this TypeDef
+ * @param guid - unique id for the TypeDef
+ * @param name - unique name for the TypeDef
+ * @param version - active version number for the TypeDef
+ * @param versionName - unique name for the TypeDef
+ */
+ public TypeDefSummary(TypeDefCategory category,
+ String guid,
+ String name,
+ long version,
+ String versionName)
+ {
+ super(guid, name);
+
+ this.category = category;
+ this.version = version;
+ this.versionName = versionName;
+ }
+
+
+ /**
+ * Copy/clone constructor copies the values from the supplied template.
+ *
+ * @param template TypeDefSummary
+ */
+ public TypeDefSummary(TypeDefSummary template)
+ {
+ super(template);
+
+ if (template != null)
+ {
+ this.category = template.getCategory();
+ this.guid = template.getGUID();
+ this.versionName = template.getVersionName();
+ this.version = template.getVersion();
+ }
+ }
+
+
+ /**
+ * Return the category of the TypeDef.
+ *
+ * @return TypeDefCategory enum
+ */
+ public TypeDefCategory getCategory()
+ {
+ return category;
+ }
+
+
+ /**
+ * Set up the category of the TypeDef.
+ *
+ * @param category - TypeDefCategory enum
+ */
+ public void setCategory(TypeDefCategory category)
+ {
+ this.category = category;
+ }
+
+ /**
+ * Return the version of the TypeDef. Versions are created when a TypeDef's properties are changed. If
+ * a description is updated, then this does not create a new version.
+ *
+ * @return String version number
+ */
+ public long getVersion()
+ {
+ return version;
+ }
+
+
+ /**
+ * Set up the version of the TypeDef. Versions are created when a TypeDef's properties are changed. If
+ * a description is updated, then this does not create a new version.
+ *
+ * @param version - long version number
+ */
+ public void setVersion(long version)
+ {
+ this.version = version;
+ }
+
+
+ /**
+ * Return the version name is more of a human readable form of the version number. It can be used to show whether the
+ * change is a minor or major update.
+ *
+ * @return String version name
+ */
+ public String getVersionName()
+ {
+ return versionName;
+ }
+
+
+ /**
+ * Set up the version name is more of a human readable form of the version number. It can be used to show whether the
+ * change is a minor or major update.
+ *
+ * @param versionName - String version name
+ */
+ public void setVersionName(String versionName)
+ {
+ this.versionName = versionName;
+ }
+
+
+ /**
+ * Standard toString method.
+ *
+ * @return JSON style description of variables.
+ */
+ @Override
+ public String toString()
+ {
+ return "TypeDefSummary{" +
+ "version=" + version +
+ ", versionName='" + versionName + '\'' +
+ ", category=" + category +
+ ", guid='" + guid + '\'' +
+ ", name='" + name + '\'' +
+ '}';
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/repositoryconnector/OMRSMetadataCollectionManager.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/repositoryconnector/OMRSMetadataCollectionManager.java b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/repositoryconnector/OMRSMetadataCollectionManager.java
new file mode 100644
index 0000000..a001208
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/repositoryconnector/OMRSMetadataCollectionManager.java
@@ -0,0 +1,46 @@
+/*
+ * 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.metadatacollection.repositoryconnector;
+
+import org.apache.atlas.omrs.metadatacollection.OMRSMetadataCollection;
+
+/**
+ * OMRSRepositoryConnectors are used by OMRS to retrieve metadata from metadata repositories. Each implementation
+ * of the OMRSRepositoryConnector is for a different type of repository. This interface defines the extension that
+ * an OMRSRepositoryConnector must implement over the base connector definition. It describes the concept of a
+ * metadata collection. This is a collection of metadata that includes the type definitions (TypeDefs) and
+ * metadata instances (Entities and Relationships) stored in the repository.
+ */
+public interface OMRSMetadataCollectionManager
+{
+ /**
+ * Set up the unique Id for this metadata collection.
+ *
+ * @param metadataCollectionId - String unique Id
+ */
+ void setMetadataCollectionId(String metadataCollectionId);
+
+
+ /**
+ * Returns the metadata collection object that provides an OMRS abstraction of the metadata within
+ * a metadata repository.
+ *
+ * @return OMRSMetadataCollection - metadata TypeDefs and instances retrieved from the metadata repository.
+ */
+ OMRSMetadataCollection getMetadataCollection();
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/repositoryconnector/OMRSRepositoryConnector.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/repositoryconnector/OMRSRepositoryConnector.java b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/repositoryconnector/OMRSRepositoryConnector.java
new file mode 100644
index 0000000..46bd19a
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/repositoryconnector/OMRSRepositoryConnector.java
@@ -0,0 +1,29 @@
+/*
+ * 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.metadatacollection.repositoryconnector;
+
+import org.apache.atlas.ocf.ConnectorBase;
+
+
+/**
+ * The OMRSRepositoryConnector provides access to the secure properties for OMRS Connector implementations.
+ * Subclasses need to implement the OMRSMetadataCollectionManager interface.
+ */
+public abstract class OMRSRepositoryConnector extends ConnectorBase implements OMRSMetadataCollectionManager
+{
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/repositoryconnector/OMRSRepositoryConnectorProviderBase.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/repositoryconnector/OMRSRepositoryConnectorProviderBase.java b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/repositoryconnector/OMRSRepositoryConnectorProviderBase.java
new file mode 100644
index 0000000..c05747c
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/repositoryconnector/OMRSRepositoryConnectorProviderBase.java
@@ -0,0 +1,43 @@
+/*
+ * 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.metadatacollection.repositoryconnector;
+
+import org.apache.atlas.ocf.ConnectorProviderBase;
+
+/**
+ * The OMRSRepositoryConnectorProviderBase provides a base class for the connector provider supporting OMRS Connectors.
+ * It adds no function but provides a placeholder for additional function if needed for the creation of
+ * any OMRS Repository connectors.
+ *
+ * It extends ConnectorProviderBase which does the creation of connector instances. The subclasses of
+ * OMRSRepositoryConnectorProviderBase must initialize ConnectorProviderBase with the Java class
+ * name of the OMRS Connector implementation (by calling super.setConnectorClassName(className)).
+ * Then the connector provider will work.
+ */
+public abstract class OMRSRepositoryConnectorProviderBase extends ConnectorProviderBase
+{
+ /**
+ * Default Constructor
+ */
+ public OMRSRepositoryConnectorProviderBase()
+ {
+ /*
+ * Nothing to do
+ */
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/metadatahighway/CohortConnectionStatus.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/metadatahighway/CohortConnectionStatus.java b/omrs/src/main/java/org/apache/atlas/omrs/metadatahighway/CohortConnectionStatus.java
new file mode 100644
index 0000000..65eb068
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/metadatahighway/CohortConnectionStatus.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.metadatahighway;
+
+
+/**
+ * CohortConnectionStatus defines the status of the local server's connection to the metadata highway for
+ * a specific cohort.
+ * <ul>
+ * <li>
+ * NOT_INITIALIZED - the local components for communicating with other members of the cohort are not initialized.
+ * This should never been seen on the admin console since it is the value for the cohort manager used on the
+ * variable declaration.
+ * </li>
+ * <li>
+ * INITIALIZING - the local components for communicating with the other members of the cohort are initializing.
+ * It the server is working properly this status is only set for a split-second.
+ * If it is seen on the admin console it probably means one of the underlying connectors is hanging during its
+ * initialization.
+ * </li>
+ * <li>
+ * NEW - the local components for the cohort are initialized but they have not yet exchanged messages with the other
+ * members of the cohort. At this point, the local metadata collection id may be changed.
+ * </li>
+ * <li>
+ * CONFIGURATION_ERROR - means there is an error in the configuration and connection is not possible.
+ * The administrator needs to either fix the config or fix the system's infrastructure around the server.
+ * </li>
+ * <li>
+ * CONNECTED - means the server is connected to the metadata highway for this cohort and is exchanging messages.
+ * </li>
+ * <li>
+ * DISCONNECTING - means the server is disconnecting from the metadata highway and is in the process of shutting
+ * down the local components that manage communication with the other members of this cohort.
+ * </li>
+ * <li>
+ * DISCONNECTED - means the server is disconnected from the metadata highway for this cohort. This may be because the
+ * local server is shutting down or the configuration is being adjusted.
+ * </li>
+ * </ul>
+ */
+public enum CohortConnectionStatus
+{
+ NOT_INITIALIZED (0, "NotInitialized", "The local components for communicating with the cohort are not initialized."),
+ INITIALIZING (1, "Initializing", "The local components for communicating with the cohort are initializing."),
+ NEW (2, "New", "The local components for communicating with the cohort are initialized " +
+ "but they have not exchanged messages with the other members of cohort."),
+ CONFIGURATION_ERROR (3, "ConfigurationError", "There is an error in the configuration and connection is not possible."),
+ CONNECTED (4, "Connected", "The server is connected to the metadata highway for this cohort and messages " +
+ "are being exchanged with other members of the cohort."),
+ DISCONNECTING (5, "Initializing", "The local components for communicating with the cohort are disconnecting."),
+ DISCONNECTED (6, "Disconnected", "The server is disconnected from the metadata highway for this cohort. This may be because the " +
+ "local server is shutting down or the configuration is being adjusted.");
+
+
+ private int statusCode;
+ private String statusName;
+ private String statusDescription;
+
+
+ /**
+ * Create an instance of the enum.
+ *
+ * @param statusCode - numeric code
+ * @param statusName - name
+ * @param statusDescription - description
+ */
+ CohortConnectionStatus(int statusCode, String statusName, String statusDescription)
+ {
+ this.statusCode = statusCode;
+ this.statusName = statusName;
+ this.statusDescription = statusDescription;
+ }
+
+
+ /**
+ * Return the numeric code for the enum.
+ *
+ * @return int code
+ */
+ public int getStatusCode()
+ {
+ return statusCode;
+ }
+
+
+ /**
+ * Return the name for the enum.
+ *
+ * @return String name
+ */
+ public String getStatusName()
+ {
+ return statusName;
+ }
+
+
+ /**
+ * Return the description of the enum.
+ *
+ * @return String description
+ */
+ public String getStatusDescription()
+ {
+ return statusDescription;
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/metadatahighway/OMRSCohortManager.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/metadatahighway/OMRSCohortManager.java b/omrs/src/main/java/org/apache/atlas/omrs/metadatahighway/OMRSCohortManager.java
new file mode 100644
index 0000000..755dae8
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/metadatahighway/OMRSCohortManager.java
@@ -0,0 +1,382 @@
+/*
+ * 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.metadatahighway;
+
+import org.apache.atlas.ocf.ffdc.ConnectorCheckedException;
+import org.apache.atlas.omrs.admin.properties.OpenMetadataEventProtocolVersion;
+import org.apache.atlas.omrs.auditlog.OMRSAuditCode;
+import org.apache.atlas.omrs.auditlog.OMRSAuditLog;
+import org.apache.atlas.omrs.auditlog.OMRSAuditingComponent;
+import org.apache.atlas.omrs.ffdc.OMRSErrorCode;
+import org.apache.atlas.omrs.ffdc.exception.OMRSConnectorErrorException;
+import org.apache.atlas.omrs.metadatahighway.cohortregistry.OMRSCohortRegistry;
+import org.apache.atlas.omrs.metadatahighway.cohortregistry.store.OMRSCohortRegistryStore;
+import org.apache.atlas.omrs.eventmanagement.*;
+import org.apache.atlas.omrs.enterprise.connectormanager.OMRSConnectionConsumer;
+import org.apache.atlas.omrs.localrepository.OMRSLocalRepository;
+import org.apache.atlas.omrs.eventmanagement.OMRSRepositoryEventExchangeRule;
+import org.apache.atlas.omrs.topicconnectors.OMRSTopicConnector;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * The OMRSCohortManager manages the components that connect to a single open metadata repository cohort.
+ */
+public class OMRSCohortManager
+{
+ private String cohortName = null;
+ private OMRSTopicConnector cohortTopicConnector = null;
+ private OMRSRepositoryEventManager cohortRepositoryEventManager = null;
+ private OMRSCohortRegistry cohortRegistry = null;
+ private OMRSEventListener cohortEventListener = null;
+ private CohortConnectionStatus cohortConnectionStatus = CohortConnectionStatus.NOT_INITIALIZED;
+
+ private OMRSRepositoryEventManager localRepositoryEventManager = null;
+
+ private static final OMRSAuditLog auditLog = new OMRSAuditLog(OMRSAuditingComponent.COHORT_MANAGER);
+
+ private static final Logger log = LoggerFactory.getLogger(OMRSCohortManager.class);
+
+
+ /**
+ * Default Constructor that relies on the initialization of variables in their declaration.
+ */
+ public OMRSCohortManager()
+ {
+ }
+
+
+ /**
+ * The constructor defines the minimum information necessary to connect to a cohort. If these values
+ * are not correctly configured, the constructor will throw an exception.
+ *
+ * @param cohortName - name of the cohort. This is a local name used for messages.
+ * @param localMetadataCollectionId - configured value for the local metadata collection id
+ * @param localServerName - the name of the local server. It is a descriptive name for informational purposes.
+ * @param localServerType - the type of the local server. It is a descriptive name for informational purposes.
+ * @param localOrganizationName - the name of the organization that owns the local server/repository.
+ * It is a descriptive name for informational purposes.
+ * @param localRepository - link to the local repository - may be null.
+ * @param connectionConsumer - The connection consumer is a component interested in maintaining details of the
+ * connections to each of the members of the open metadata repository cohort. If it is
+ * null, the cohort registry does not publish connections for members of the open
+ * metadata repository cohort.
+ * @param cohortRegistryStore - the cohort registry store where details of members of the cohort are kept
+ * @param cohortTopicConnector - Connector to the cohort's OMRS Topic.
+ * @param enterpriseTopicConnector - Connector to the federated OMRS Topic.
+ * @param eventProtocolVersion - Protocol to use for events to the cohort.
+ * @param inboundEventExchangeRule - rule for processing inbound events.
+ */
+ public void initialize(String cohortName,
+ String localMetadataCollectionId,
+ String localServerName,
+ String localServerType,
+ String localOrganizationName,
+ OMRSLocalRepository localRepository,
+ OMRSConnectionConsumer connectionConsumer,
+ OMRSTopicConnector enterpriseTopicConnector,
+ OMRSCohortRegistryStore cohortRegistryStore,
+ OMRSTopicConnector cohortTopicConnector,
+ OpenMetadataEventProtocolVersion eventProtocolVersion,
+ OMRSRepositoryEventExchangeRule inboundEventExchangeRule)
+ {
+ final String actionDescription = "Initialize Cohort Manager";
+
+ if (log.isDebugEnabled())
+ {
+ log.debug(actionDescription);
+ }
+
+ try
+ {
+ this.cohortName = cohortName;
+
+ OMRSAuditCode auditCode = OMRSAuditCode.COHORT_INITIALIZING;
+ auditLog.logRecord(actionDescription,
+ auditCode.getLogMessageId(),
+ auditCode.getSeverity(),
+ auditCode.getFormattedLogMessage(cohortName),
+ null,
+ auditCode.getSystemAction(),
+ auditCode.getUserAction());
+
+ /*
+ * Set up the config status. It is updated multiple times during this method to help detect whether
+ * underlying component are hanging in their initialization. Most of these intermediary states are
+ * unlikely to be seen.
+ */
+ this.cohortConnectionStatus = CohortConnectionStatus.INITIALIZING;
+
+ /*
+ * Create the event manager for processing incoming events from the cohort's OMRS Topic.
+ */
+ this.cohortRepositoryEventManager = new OMRSRepositoryEventManager(inboundEventExchangeRule);
+
+ /*
+ * Create an event publisher for the cohort registry to use to send registration requests.
+ */
+ OMRSEventPublisher outboundRegistryEventProcessor = new OMRSEventPublisher(cohortName,
+ eventProtocolVersion,
+ cohortTopicConnector);
+
+ /*
+ * The presence/absence of the local repository affects the behaviour of the cohort registry.
+ */
+ if (localRepository != null)
+ {
+ /*
+ * The local repository is present so set up the CohortRegistry to play a full role in the protocol.
+ */
+ this.cohortRegistry.initialize(cohortName,
+ localMetadataCollectionId,
+ localRepository.getLocalRepositoryRemoteConnection(),
+ localServerName,
+ localServerType,
+ localOrganizationName,
+ outboundRegistryEventProcessor,
+ cohortRegistryStore,
+ localRepository.getTypeDefValidator(),
+ connectionConsumer);
+
+ localRepositoryEventManager = localRepository.getOutboundRepositoryEventManager();
+
+ if (localRepositoryEventManager != null)
+ {
+ /*
+ * Register an event publisher with the local repository for this cohort. This will mean
+ * other members of the cohort can receive events from the local server's repository.
+ */
+ OMRSEventPublisher repositoryEventPublisher = new OMRSEventPublisher(cohortName,
+ eventProtocolVersion,
+ cohortTopicConnector);
+
+
+ localRepositoryEventManager.registerTypeDefProcessor(repositoryEventPublisher);
+ localRepositoryEventManager.registerInstanceProcessor(repositoryEventPublisher);
+ }
+
+ /*
+ * Register the local repository's processors with the cohort's event manager. This will
+ * route incoming repository events to the local repository.
+ */
+ if (localRepository.getIncomingTypeDefEventProcessor() != null)
+ {
+ this.cohortRepositoryEventManager.registerTypeDefProcessor(
+ localRepository.getIncomingTypeDefEventProcessor());
+ }
+ if (localRepository.getIncomingInstanceEventProcessor() != null)
+ {
+ this.cohortRepositoryEventManager.registerInstanceProcessor(
+ localRepository.getIncomingInstanceEventProcessor());
+ }
+ }
+ else /* no local repository */
+ {
+ /*
+ * If there is no local repository, then the cohort registry is focusing on managing registrations
+ * from remote members of the cohort to configure the enterprise access capability.
+ */
+ this.cohortRegistry.initialize(cohortName,
+ null,
+ null,
+ localServerName,
+ localServerType,
+ localOrganizationName,
+ outboundRegistryEventProcessor,
+ null,
+ null,
+ connectionConsumer);
+ }
+
+ /*
+ * If the enterprise omrs topic is active, then register an event publisher for it.
+ * This topic is active if the Open Metadata Access Services (OMASs) are active.
+ */
+ if (enterpriseTopicConnector != null)
+ {
+ OMRSEventPublisher enterpriseEventPublisher = new OMRSEventPublisher("OMAS Enterprise Access",
+ eventProtocolVersion,
+ cohortTopicConnector);
+
+ this.cohortRepositoryEventManager.registerInstanceProcessor(enterpriseEventPublisher);
+ }
+
+ this.cohortConnectionStatus = CohortConnectionStatus.NEW;
+
+ /*
+ * The cohort topic connector is used by the local cohort components to communicate with the other
+ * members of the cohort.
+ */
+ if (cohortTopicConnector != null)
+ {
+ /*
+ * Finally create the event listener and register it with the cohort OMRS Topic.
+ */
+ OMRSEventListener cohortEventListener = new OMRSEventListener(cohortName,
+ localMetadataCollectionId,
+ this.cohortRegistry,
+ this.cohortRepositoryEventManager,
+ this.cohortRepositoryEventManager);
+ cohortTopicConnector.registerListener(cohortEventListener);
+ this.cohortTopicConnector = cohortTopicConnector;
+ this.cohortEventListener = cohortEventListener;
+
+ /*
+ * Once the event infrastructure is set up it is ok to send out registration requests to the
+ * rest of the cohort.
+ */
+ this.cohortRegistry.connectToCohort();
+
+ this.cohortConnectionStatus = CohortConnectionStatus.CONNECTED;
+ }
+ }
+ catch (Throwable error)
+ {
+ this.cohortConnectionStatus = CohortConnectionStatus.CONFIGURATION_ERROR;
+ throw error;
+ }
+
+ if (log.isDebugEnabled())
+ {
+ log.debug(actionDescription + " COMPLETE");
+ }
+ }
+
+
+ /**
+ * Return the name of the cohort.
+ *
+ * @return String name
+ */
+ public String getCohortName()
+ {
+ return cohortName;
+ }
+
+
+ /**
+ * Return the status of the connection with the metadata highway.
+ *
+ * @return CohortConnectionStatus
+ */
+ public CohortConnectionStatus getCohortConnectionStatus()
+ {
+ return cohortConnectionStatus;
+ }
+
+
+ /**
+ * Disconnect from the cohort.
+ *
+ * @param permanent - flag indicating if the local repository should unregister from the cohort because it is
+ * not going ot connect again.
+ */
+ public synchronized void disconnect(boolean permanent)
+ {
+ final String actionDescription = "Disconnect Cohort Manager";
+
+ if (log.isDebugEnabled())
+ {
+ log.debug(actionDescription);
+ }
+
+ try
+ {
+ cohortConnectionStatus = CohortConnectionStatus.DISCONNECTING;
+
+ OMRSAuditCode auditCode = OMRSAuditCode.COHORT_DISCONNECTING;
+ auditLog.logRecord(actionDescription,
+ auditCode.getLogMessageId(),
+ auditCode.getSeverity(),
+ auditCode.getFormattedLogMessage(cohortName),
+ null,
+ auditCode.getSystemAction(),
+ auditCode.getUserAction());
+
+ if (cohortRegistry != null)
+ {
+ cohortRegistry.disconnectFromCohort(permanent);
+ }
+
+ if (cohortTopicConnector != null)
+ {
+ cohortTopicConnector.disconnect();
+ }
+
+ cohortConnectionStatus = CohortConnectionStatus.DISCONNECTED;
+ }
+ catch (ConnectorCheckedException error)
+ {
+ if (log.isDebugEnabled())
+ {
+ log.debug(actionDescription + " FAILED with connector checked exception");
+ }
+
+ /*
+ * Throw runtime exception to indicate that the cohort registry is not available.
+ */
+ OMRSErrorCode errorCode = OMRSErrorCode.COHORT_DISCONNECT_FAILED;
+ String errorMessage = errorCode.getErrorMessageId()
+ + errorCode.getFormattedErrorMessage(cohortName);
+
+ throw new OMRSConnectorErrorException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ actionDescription,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction(),
+ error);
+
+ }
+ catch (Throwable error)
+ {
+ if (log.isDebugEnabled())
+ {
+ log.debug(actionDescription + " FAILED with exception");
+ }
+
+ throw error;
+ }
+
+ if (log.isDebugEnabled())
+ {
+ log.debug(actionDescription + " COMPLETE");
+ }
+ }
+
+
+ /**
+ * Standard toString method.
+ *
+ * @return JSON style description of variables.
+ */
+ @Override
+ public String toString()
+ {
+ return "OMRSCohortManager{" +
+ "cohortName='" + cohortName + '\'' +
+ ", cohortTopicConnector=" + cohortTopicConnector +
+ ", cohortRepositoryEventManager=" + cohortRepositoryEventManager +
+ ", cohortRegistry=" + cohortRegistry +
+ ", cohortEventListener=" + cohortEventListener +
+ ", cohortConnectionStatus=" + cohortConnectionStatus +
+ ", localRepositoryEventManager=" + localRepositoryEventManager +
+ '}';
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/metadatahighway/OMRSMetadataHighwayManager.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/metadatahighway/OMRSMetadataHighwayManager.java b/omrs/src/main/java/org/apache/atlas/omrs/metadatahighway/OMRSMetadataHighwayManager.java
new file mode 100644
index 0000000..07ef814
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/metadatahighway/OMRSMetadataHighwayManager.java
@@ -0,0 +1,453 @@
+/*
+ * 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.metadatahighway;
+
+import org.apache.atlas.ocf.Connector;
+import org.apache.atlas.ocf.ConnectorBroker;
+import org.apache.atlas.ocf.properties.Connection;
+import org.apache.atlas.omrs.admin.properties.CohortConfig;
+import org.apache.atlas.omrs.auditlog.OMRSAuditCode;
+import org.apache.atlas.omrs.auditlog.OMRSAuditLog;
+import org.apache.atlas.omrs.auditlog.OMRSAuditingComponent;
+import org.apache.atlas.omrs.ffdc.exception.OMRSLogicErrorException;
+import org.apache.atlas.omrs.metadatahighway.cohortregistry.store.OMRSCohortRegistryStore;
+import org.apache.atlas.omrs.eventmanagement.*;
+import org.apache.atlas.omrs.enterprise.connectormanager.OMRSConnectionConsumer;
+import org.apache.atlas.omrs.ffdc.exception.OMRSConfigErrorException;
+import org.apache.atlas.omrs.ffdc.OMRSErrorCode;
+import org.apache.atlas.omrs.localrepository.OMRSLocalRepository;
+import org.apache.atlas.omrs.localrepository.repositorycontentmanager.OMRSTypeDefValidator;
+import org.apache.atlas.omrs.topicconnectors.OMRSTopicConnector;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+
+/**
+ * OMRSMetadataHighwayManager is responsible for managing the connectivity to to each cohort that the local
+ * server is a member of.
+ */
+public class OMRSMetadataHighwayManager
+{
+ private ArrayList<OMRSCohortManager> cohortManagers = new ArrayList<>();
+
+ private String localServerName = null;
+ private String localServerType = null;
+ private String localOrganizationName = null;
+ private OMRSLocalRepository localRepository = null;
+ private OMRSTypeDefValidator localTypeDefValidator = null;
+ private OMRSConnectionConsumer enterpriseAccessConnectionConsumer = null;
+ private OMRSTopicConnector enterpriseAccessTopicConnector = null;
+
+
+ private static final OMRSAuditLog auditLog = new OMRSAuditLog(OMRSAuditingComponent.METADATA_HIGHWAY_MANAGER);
+
+ private static final Logger log = LoggerFactory.getLogger(OMRSEventPublisher.class);
+
+ /**
+ * Constructor taking the values that are used in every cohort. Any of these values may be null.
+ *
+ * @param localServerName - name of the local server.
+ * @param localServerType - descriptive type of the local server.
+ * @param localOrganizationName - name of the organization that owns the local server.
+ * @param localRepository - link to local repository - may be null.
+ * @param localTypeDefValidator - the TypeDefValidator is ues in evaluating the type definitions (TypeDefs)
+ * passed around the cohort.
+ * @param enterpriseAccessConnectionConsumer - connection consumer for managing the connections of enterprise access.
+ * @param enterpriseAccessTopicConnector - connector for the OMRS Topic for enterprise access.
+ */
+ public OMRSMetadataHighwayManager(String localServerName,
+ String localServerType,
+ String localOrganizationName,
+ OMRSLocalRepository localRepository,
+ OMRSTypeDefValidator localTypeDefValidator,
+ OMRSConnectionConsumer enterpriseAccessConnectionConsumer,
+ OMRSTopicConnector enterpriseAccessTopicConnector)
+ {
+ this.localServerName = localServerName;
+ this.localServerType = localServerType;
+ this.localOrganizationName = localOrganizationName;
+ this.localRepository = localRepository;
+ this.localTypeDefValidator = localTypeDefValidator;
+ this.enterpriseAccessConnectionConsumer = enterpriseAccessConnectionConsumer;
+ this.enterpriseAccessTopicConnector = enterpriseAccessTopicConnector;
+ }
+
+
+ /**
+ * Initialize each cohort manager in turn. Configuration errors will result in an exception and the initialization
+ * process will halt.
+ *
+ * @param cohortConfigList - list of cohorts to initialize
+ */
+ public void initialize(ArrayList<CohortConfig> cohortConfigList)
+ {
+ if (cohortConfigList != null)
+ {
+ /*
+ * Loop through the configured cohorts
+ */
+ for (CohortConfig cohortConfig : cohortConfigList)
+ {
+ this.connectToCohort(cohortConfig);
+ }
+ }
+ }
+
+
+ /**
+ * Initialize the components to connect the local repository to a cohort.
+ *
+ * @param cohortConfig - description of cohort.
+ * @return the status of the cohort
+ */
+ public CohortConnectionStatus connectToCohort(CohortConfig cohortConfig)
+ {
+ OMRSCohortManager cohortManager = new OMRSCohortManager();
+ String localMetadataCollectionId = null;
+ String actionDescription = "Connect to Cohort";
+
+ /*
+ * Validate the cohort name exists
+ */
+ if (cohortConfig.getCohortName() == null)
+ {
+ OMRSErrorCode errorCode = OMRSErrorCode.NULL_COHORT_NAME;
+ String errorMessage = errorCode.getErrorMessageId()
+ + errorCode.getFormattedErrorMessage();
+
+ throw new OMRSLogicErrorException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ actionDescription,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+
+ /*
+ * Loop through the existing cohort managers to make sure the new cohort name is unique
+ */
+ for (OMRSCohortManager existingCohortManager : cohortManagers)
+ {
+ if (existingCohortManager != null)
+ {
+ if (cohortConfig.getCohortName().equals(existingCohortManager.getCohortName()))
+ {
+ OMRSErrorCode errorCode = OMRSErrorCode.DUPLICATE_COHORT_NAME;
+ String errorMessage = errorCode.getErrorMessageId()
+ + errorCode.getFormattedErrorMessage(cohortConfig.getCohortName());
+
+ throw new OMRSLogicErrorException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ actionDescription,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+ }
+ }
+
+ /*
+ * Extract the local metadata collection id if there is a local repository
+ */
+ if (localRepository != null)
+ {
+ localMetadataCollectionId = localRepository.getMetadataCollectionId();
+ }
+
+ /*
+ * Create the resources needed by the cohort and initialize them in a cohort manager.
+ */
+ try
+ {
+ OMRSCohortRegistryStore cohortRegistryStore
+ = getCohortRegistryStore(cohortConfig.getCohortName(),
+ cohortConfig.getCohortRegistryConnection());
+
+ OMRSTopicConnector cohortTopicConnector
+ = getTopicConnector(cohortConfig.getCohortName(),
+ cohortConfig.getCohortOMRSTopicConnection());
+
+ OMRSRepositoryEventExchangeRule inboundEventExchangeRule
+ = new OMRSRepositoryEventExchangeRule(cohortConfig.getCohortName() + " Events To Process",
+ localTypeDefValidator,
+ cohortConfig.getEventsToProcessRule(),
+ cohortConfig.getSelectedTypesToProcess());
+
+ cohortManager.initialize(cohortConfig.getCohortName(),
+ localMetadataCollectionId,
+ localServerName,
+ localServerType,
+ localOrganizationName,
+ localRepository,
+ enterpriseAccessConnectionConsumer,
+ enterpriseAccessTopicConnector,
+ cohortRegistryStore,
+ cohortTopicConnector,
+ cohortConfig.getCohortOMRSTopicProtocolVersion(),
+ inboundEventExchangeRule);
+
+ /*
+ * The cohort manager is only added to the list if it initializes successfully.
+ */
+ cohortManagers.add(cohortManager);
+ }
+ catch (OMRSConfigErrorException error)
+ {
+ OMRSAuditCode auditCode = OMRSAuditCode.COHORT_CONFIG_ERROR;
+ auditLog.logRecord(actionDescription,
+ auditCode.getLogMessageId(),
+ auditCode.getSeverity(),
+ auditCode.getFormattedLogMessage(cohortConfig.getCohortName()),
+ null,
+ auditCode.getSystemAction(),
+ auditCode.getUserAction());
+
+ throw error;
+ }
+ catch (Throwable error)
+ {
+ throw error;
+ }
+
+ return cohortManager.getCohortConnectionStatus();
+ }
+
+
+ /**
+ * Return the status of the named cohort.
+ *
+ * @param cohortName name of cohort
+ * @return connection status - if the cohort manager is not running then "NOT_INITIALIZED" is returned
+ */
+ public CohortConnectionStatus getCohortConnectionStatus(String cohortName)
+ {
+ String actionDescription = "Get cohort status";
+
+ if (cohortName == null)
+ {
+ OMRSErrorCode errorCode = OMRSErrorCode.NULL_COHORT_NAME;
+ String errorMessage = errorCode.getErrorMessageId()
+ + errorCode.getFormattedErrorMessage();
+
+ throw new OMRSLogicErrorException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ actionDescription,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+
+ for (OMRSCohortManager existingCohortManager : cohortManagers)
+ {
+ if (existingCohortManager != null)
+ {
+ if (cohortName.equals(existingCohortManager.getCohortName()))
+ {
+ return existingCohortManager.getCohortConnectionStatus();
+ }
+ }
+ }
+
+ /*
+ * No cohort manager was found so return not initialized.
+ */
+ return CohortConnectionStatus.NOT_INITIALIZED;
+ }
+
+
+ /**
+ * Disconnect communications from a specific cohort.
+ *
+ * @param cohortName - name of cohort
+ * @param permanent - is the local server permanently disconnecting from the cohort - causes an unregistration
+ * event to be sent to the other members.
+ * @return boolean flag to indicate success.
+ */
+ public boolean disconnectFromCohort(String cohortName, boolean permanent)
+ {
+ String actionDescription = "Disconnect cohort";
+
+ if (cohortName == null)
+ {
+ OMRSErrorCode errorCode = OMRSErrorCode.NULL_COHORT_NAME;
+ String errorMessage = errorCode.getErrorMessageId()
+ + errorCode.getFormattedErrorMessage();
+
+ throw new OMRSLogicErrorException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ actionDescription,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+
+ for (OMRSCohortManager existingCohortManager : cohortManagers)
+ {
+ if (existingCohortManager != null)
+ {
+ if (cohortName.equals(existingCohortManager.getCohortName()))
+ {
+ existingCohortManager.disconnect(permanent);
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+
+
+ /**
+ * Disconnect from all cohorts.
+ *
+ * @param permanent - indicates whether the cohort registry should unregister from the cohort
+ * and clear its registry store or just disconnect from the event topic.
+ */
+ public void disconnect(boolean permanent)
+ {
+ final String actionDescription = "Disconnecting from metadata highway";
+
+ if (log.isDebugEnabled())
+ {
+ log.debug(actionDescription);
+ }
+
+ for (OMRSCohortManager cohortManager : cohortManagers)
+ {
+ if (cohortManager != null)
+ {
+ cohortManager.disconnect(permanent);
+ }
+ }
+
+ if (log.isDebugEnabled())
+ {
+ log.debug(actionDescription + " COMPLETE");
+ }
+ }
+
+
+ /**
+ * Create a connector to the cohort registry store. If there is a problem with the connection information
+ * that means a connector can not be created, an exception is thrown.
+ *
+ * @param cohortName - name of the cohort that this registry store is for
+ * @param cohortRegistryConnection - connection to the cluster registry store.
+ * @return OMRSCohortRegistryStore connector
+ */
+ private OMRSCohortRegistryStore getCohortRegistryStore(String cohortName,
+ Connection cohortRegistryConnection)
+ {
+ final String methodName = "getCohortRegistryStore()";
+
+ try
+ {
+ ConnectorBroker connectorBroker = new ConnectorBroker();
+ Connector connector = connectorBroker.getConnector(cohortRegistryConnection);
+
+ return (OMRSCohortRegistryStore)connector;
+ }
+ catch (Throwable error)
+ {
+ if (log.isDebugEnabled())
+ {
+ log.debug("Unable to create cohort registry store connector: " + error.toString());
+ }
+
+ /*
+ * Throw runtime exception to indicate that the cohort registry is not available.
+ */
+ OMRSErrorCode errorCode = OMRSErrorCode.NULL_REGISTRY_STORE;
+ String errorMessage = errorCode.getErrorMessageId()
+ + errorCode.getFormattedErrorMessage(cohortName);
+
+ throw new OMRSConfigErrorException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ methodName,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction(),
+ error);
+ }
+ }
+
+ /**
+ * Creates a topic connector using information from the supplied topic connection. This connector supported
+ * the Open Connector Framework (OCF) so it is possible to configure different connector implementations for
+ * different event/messaging infrastructure. If there is a problem with the connection information
+ * that means a connector can not be created, an exception is thrown.
+ *
+ * @param cohortName - name of the cohort that this registry store is for
+ * @param topicConnection - connection parameters
+ * @return OMRSTopicConnector for managing communications with the event/messaging infrastructure.
+ */
+ private OMRSTopicConnector getTopicConnector(String cohortName,
+ Connection topicConnection)
+ {
+ try
+ {
+ ConnectorBroker connectorBroker = new ConnectorBroker();
+ Connector connector = connectorBroker.getConnector(topicConnection);
+
+ return (OMRSTopicConnector)connector;
+ }
+ catch (Throwable error)
+ {
+ String methodName = "getTopicConnector()";
+
+ if (log.isDebugEnabled())
+ {
+ log.debug("Unable to create topic connector: " + error.toString());
+ }
+
+ OMRSErrorCode errorCode = OMRSErrorCode.NULL_TOPIC_CONNECTOR;
+ String errorMessage = errorCode.getErrorMessageId()
+ + errorCode.getFormattedErrorMessage(cohortName);
+
+ throw new OMRSConfigErrorException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ methodName,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction(),
+ error);
+ }
+ }
+
+
+ /**
+ * Standard toString method.
+ *
+ * @return JSON style description of variables.
+ */
+ @Override
+ public String toString()
+ {
+ return "OMRSMetadataHighwayManager{" +
+ "cohortManagers=" + cohortManagers +
+ ", localServerName='" + localServerName + '\'' +
+ ", localServerType='" + localServerType + '\'' +
+ ", localOrganizationName='" + localOrganizationName + '\'' +
+ ", localRepository=" + localRepository +
+ ", localTypeDefValidator=" + localTypeDefValidator +
+ ", enterpriseAccessConnectionConsumer=" + enterpriseAccessConnectionConsumer +
+ ", enterpriseAccessTopicConnector=" + enterpriseAccessTopicConnector +
+ '}';
+ }
+}
[29/30] atlas git commit: ATLAS-2246: OMRS Connector API plus REST
and IGC Connector skeleton - 15th February 2018
Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/admin/OMRSOperationalServices.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/admin/OMRSOperationalServices.java b/omrs/src/main/java/org/apache/atlas/omrs/admin/OMRSOperationalServices.java
new file mode 100644
index 0000000..8a47945
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/admin/OMRSOperationalServices.java
@@ -0,0 +1,858 @@
+/*
+ * 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.admin;
+
+import org.apache.atlas.ocf.Connector;
+import org.apache.atlas.ocf.ConnectorBroker;
+import org.apache.atlas.ocf.properties.Connection;
+import org.apache.atlas.omrs.admin.properties.CohortConfig;
+import org.apache.atlas.omrs.admin.properties.EnterpriseAccessConfig;
+import org.apache.atlas.omrs.admin.properties.LocalRepositoryConfig;
+import org.apache.atlas.omrs.admin.properties.RepositoryServicesConfig;
+import org.apache.atlas.omrs.archivemanager.OMRSArchiveManager;
+import org.apache.atlas.omrs.archivemanager.store.OpenMetadataArchiveStore;
+import org.apache.atlas.omrs.auditlog.OMRSAuditCode;
+import org.apache.atlas.omrs.auditlog.OMRSAuditLog;
+import org.apache.atlas.omrs.auditlog.OMRSAuditingComponent;
+import org.apache.atlas.omrs.auditlog.store.OMRSAuditLogStore;
+import org.apache.atlas.omrs.enterprise.connectormanager.OMRSConnectionConsumer;
+import org.apache.atlas.omrs.enterprise.connectormanager.OMRSEnterpriseConnectorManager;
+import org.apache.atlas.omrs.eventmanagement.OMRSRepositoryEventExchangeRule;
+import org.apache.atlas.omrs.eventmanagement.OMRSRepositoryEventManager;
+import org.apache.atlas.omrs.eventmanagement.repositoryeventmapper.OMRSRepositoryEventMapper;
+import org.apache.atlas.omrs.ffdc.exception.OMRSConfigErrorException;
+import org.apache.atlas.omrs.ffdc.OMRSErrorCode;
+import org.apache.atlas.omrs.ffdc.exception.OMRSLogicErrorException;
+import org.apache.atlas.omrs.ffdc.exception.OMRSRuntimeException;
+import org.apache.atlas.omrs.enterprise.repositoryconnector.EnterpriseOMRSConnectorProvider;
+import org.apache.atlas.omrs.localrepository.repositoryconnector.LocalOMRSConnectorProvider;
+import org.apache.atlas.omrs.localrepository.repositoryconnector.LocalOMRSRepositoryConnector;
+import org.apache.atlas.omrs.localrepository.repositorycontentmanager.OMRSRepositoryContentManager;
+import org.apache.atlas.omrs.localrepository.repositorycontentmanager.OMRSRepositoryHelper;
+import org.apache.atlas.omrs.localrepository.repositorycontentmanager.OMRSRepositoryValidator;
+import org.apache.atlas.omrs.localrepository.repositorycontentmanager.OMRSTypeDefValidator;
+import org.apache.atlas.omrs.metadatahighway.OMRSMetadataHighwayManager;
+import org.apache.atlas.omrs.rest.server.OMRSRepositoryRESTServices;
+import org.apache.atlas.omrs.topicconnectors.OMRSTopicConnector;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+
+/**
+ * OMRSOperationalServices provides the OMAG Server with access to the OMRS capabilities.
+ * This includes managing the local metadata repository, connecting and disconnecting from the metadata
+ * highway and supporting administrative
+ * actions captured through the OMAG REST interface.
+ *
+ * Examples of the types of capabilities offered by the OMRS Manager include:
+ * <ul>
+ * <li>Initialize and Shutdown the OMRS</li>
+ * <li>See the state of the cluster</li>
+ * <li>see the state of the connectors</li>
+ * <li>View the audit log</li>
+ * <li>Load new connector JARs</li>
+ * <li>Connect/disconnect from the metadata highway</li>
+ * </ul>
+ */
+public class OMRSOperationalServices
+{
+ /*
+ * The audit log provides a verifiable record of the membership of the open metadata repository cohort and the
+ * metadata exchange activity they are involved in. The Logger is for standard debug.
+ */
+ private static final Logger log = LoggerFactory.getLogger(OMRSOperationalServices.class);
+ private static final OMRSAuditLog auditLog = new OMRSAuditLog(OMRSAuditingComponent.OPERATIONAL_SERVICES);
+
+
+ private String localServerName = null;
+ private String localServerType = null;
+ private String localOrganizationName = null;
+ private String localMetadataCollectionId = null;
+
+ private OMRSRepositoryContentManager localRepositoryContentManager = null;
+ private OMRSRepositoryEventManager localRepositoryEventManager = null;
+ private OMRSMetadataHighwayManager metadataHighwayManager = null;
+ private OMRSEnterpriseConnectorManager enterpriseConnectorManager = null;
+ private OMRSTopicConnector enterpriseOMRSTopicConnector = null;
+ private LocalOMRSRepositoryConnector localRepositoryConnector = null;
+ private OMRSArchiveManager archiveManager = null;
+
+
+ /**
+ * Constructor used at server startup.
+ *
+ * @param localServerName - name of the local server
+ * @param localServerType - type of the local server
+ * @param organizationName - name of the organization that owns the local server
+ */
+ public OMRSOperationalServices(String localServerName,
+ String localServerType,
+ String organizationName)
+ {
+ /*
+ * Save details about the local server
+ */
+ this.localServerName = localServerName;
+ this.localServerType = localServerType;
+ this.localOrganizationName = organizationName;
+ }
+
+
+ /**
+ * Initialize the OMRS component for the Open Metadata Repository Services (OMRS). The configuration
+ * is taken as is. Any configuration errors are reported as exceptions.
+ *
+ * @param repositoryServicesConfig - current configuration values
+ */
+ public void initialize(RepositoryServicesConfig repositoryServicesConfig)
+ {
+ final String actionDescription = "Initialize Repository Operational Services";
+ final String methodName = "initialize()";
+ OMRSAuditCode auditCode = null;
+
+
+ if (repositoryServicesConfig == null)
+ {
+ /*
+ * Throw exception as without configuration information the OMRS can not start.
+ */
+ OMRSErrorCode errorCode = OMRSErrorCode.NULL_CONFIG;
+ String errorMessage = errorCode.getErrorMessageId()
+ + errorCode.getFormattedErrorMessage();
+
+ throw new OMRSLogicErrorException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ methodName,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+
+ /*
+ * Initialize the audit log
+ */
+ OMRSAuditLog.initialize(localServerName,
+ localServerType,
+ localOrganizationName,
+ getAuditLogStore(repositoryServicesConfig.getAuditLogConnection()));
+
+ /*
+ * Log that the OMRS is starting. There is another Audit log message logged at the end of this method
+ * to confirm that all of the pieces started successfully.
+ */
+ auditCode = OMRSAuditCode.OMRS_INITIALIZING;
+ auditLog.logRecord(actionDescription,
+ auditCode.getLogMessageId(),
+ auditCode.getSeverity(),
+ auditCode.getFormattedLogMessage(),
+ null,
+ auditCode.getSystemAction(),
+ auditCode.getUserAction());
+ /*
+ * There are 3 major groupings of components, each are optional and have linkages between one another.
+ * These are the enterprise access services, local repository and the metadata highway (cohort services).
+ * Each group as its own config.
+ */
+ EnterpriseAccessConfig enterpriseAccessConfig = repositoryServicesConfig.getEnterpriseAccessConfig();
+ LocalRepositoryConfig localRepositoryConfig = repositoryServicesConfig.getLocalRepositoryConfig();
+ ArrayList<CohortConfig> cohortConfigList = repositoryServicesConfig.getCohortConfigList();
+
+ /*
+ * Begin with the enterprise repository services. They are always needed since the
+ * Open Metadata Access Services (OMAS) is dependent on them. There are 2 modes of operation: local only
+ * and enterprise access. Enterprise access provide an enterprise view of metadata
+ * across all of the open metadata repository cohorts that this server connects to.
+ * If EnterpriseAccessConfig is null, the enterprise repository services run in local only mode.
+ * Otherwise the supplied configuration properties enable it to be configured for enterprise access.
+ *
+ * The connector manager manages the list of connectors to metadata repositories that the enterprise
+ * repository services will use. The OMRS Topic is used to publish events from these repositories to support the
+ * OMASs' event notifications.
+ */
+ enterpriseConnectorManager = initializeEnterpriseConnectorManager(enterpriseAccessConfig);
+ enterpriseOMRSTopicConnector = initializeEnterpriseOMRSTopicConnector(enterpriseAccessConfig);
+
+ /*
+ * The archive manager loads pre-defined types and instances that are stored in open metadata archives.
+ */
+ archiveManager = initializeOpenMetadataArchives(repositoryServicesConfig.getOpenMetadataArchiveConnectionList());
+
+ /*
+ * The local repository is optional. However, the repository content manager is still
+ * used to manage the validation of TypeDefs and the creation of metadata instances.
+ * It is loaded with any TypeDefs from the archives to seed its in-memory TypeDef cache.
+ */
+ localRepositoryContentManager = new OMRSRepositoryContentManager();
+
+ /*
+ * The repository validator and helper are used by repository connectors to verify the types and instances
+ * they receive from external parties and to build new types and instances. Instances of these
+ * classes are created in each of the repository connectors (and possibly the event mappers as well).
+ * They are given a link to the repository content manager since it has the cache of TypeDefs.
+ */
+ OMRSRepositoryValidator.setRepositoryContentManager(localRepositoryContentManager);
+ OMRSRepositoryHelper.setRepositoryContentManager(localRepositoryContentManager);
+
+ /*
+ * Start up the local repository if one is configured.
+ */
+ if (localRepositoryConfig != null)
+ {
+ localMetadataCollectionId = localRepositoryConfig.getMetadataCollectionId();
+
+ auditCode = OMRSAuditCode.LOCAL_REPOSITORY_INITIALIZING;
+ auditLog.logRecord(actionDescription,
+ auditCode.getLogMessageId(),
+ auditCode.getSeverity(),
+ auditCode.getFormattedLogMessage(localMetadataCollectionId),
+ null,
+ auditCode.getSystemAction(),
+ auditCode.getUserAction());
+
+ localRepositoryEventManager =
+ new OMRSRepositoryEventManager(
+ new OMRSRepositoryEventExchangeRule("Local Repository Events to Send",
+ localRepositoryContentManager,
+ localRepositoryConfig.getEventsToSendRule(),
+ localRepositoryConfig.getSelectedTypesToSend()));
+
+ /*
+ * Pass the local metadata collectionId to the AuditLog
+ */
+ OMRSAuditLog.setLocalMetadataCollectionId(localMetadataCollectionId);
+
+ localRepositoryConnector = initializeLocalRepository(localRepositoryConfig);
+
+ /*
+ * Set up the OMRS REST Services with the local repository
+ */
+ OMRSRepositoryRESTServices.setLocalRepository(localRepositoryConnector);
+ }
+
+ /*
+ * This is the point at which the open metadata archives will be processed. The archives are processed
+ * using the same mechanisms as TypeDef/Instance events received from other members of the cohort. This
+ * is because the metadata in the archives is effectively reference metadata that is owned by the archive
+ * and should not be updated in the local repository.
+ *
+ * Note that if the local repository is not configured then only TypeDefs are processed because there
+ * is nowhere to store the instances. The TypeDefs are used for validation of metadata that is passed to
+ * the enterprise repository services.
+ */
+ if (localRepositoryConnector != null)
+ {
+ archiveManager.setLocalRepository(localRepositoryContentManager,
+ localRepositoryConnector.getIncomingInstanceEventProcessor());
+ }
+ else
+ {
+ archiveManager.setLocalRepository(localRepositoryContentManager,
+ null);
+ }
+
+ /*
+ * Connect the local repository connector to the connector manager if they both exist. This means
+ * that enterprise repository requests will include metadata from the local repository.
+ */
+ if ((localRepositoryConnector != null) && (enterpriseConnectorManager != null))
+ {
+ enterpriseConnectorManager.setLocalConnector(localRepositoryConnector.getMetadataCollectionId(),
+ localRepositoryConnector);
+ }
+
+ /*
+ * local operation is ready, now connect to the metadata highway.
+ */
+ if (cohortConfigList != null)
+ {
+ auditCode = OMRSAuditCode.METADATA_HIGHWAY_INITIALIZING;
+ auditLog.logRecord(actionDescription,
+ auditCode.getLogMessageId(),
+ auditCode.getSeverity(),
+ auditCode.getFormattedLogMessage(),
+ null,
+ auditCode.getSystemAction(),
+ auditCode.getUserAction());
+
+ metadataHighwayManager = initializeCohorts(localServerName,
+ localServerType,
+ localOrganizationName,
+ localRepositoryConnector,
+ localRepositoryContentManager,
+ enterpriseConnectorManager,
+ enterpriseOMRSTopicConnector,
+ cohortConfigList);
+ }
+
+ /*
+ * All done and no exceptions :)
+ */
+ auditCode = OMRSAuditCode.OMRS_INITIALIZED;
+ auditLog.logRecord(actionDescription,
+ auditCode.getLogMessageId(),
+ auditCode.getSeverity(),
+ auditCode.getFormattedLogMessage(),
+ null,
+ auditCode.getSystemAction(),
+ auditCode.getUserAction());
+ }
+
+
+ /**
+ * Return the connector to the Enterprise OMRS Topic. If null is returned it means the Enterprise OMRS Topic
+ * is not needed. A configuration error exception is thrown if there is a problem with the connection properties
+ *
+ * @param enterpriseAccessConfig - configuration from the OMAG server
+ * @return connector to the Enterprise OMRS Topic or null
+ */
+ private OMRSTopicConnector initializeEnterpriseOMRSTopicConnector(EnterpriseAccessConfig enterpriseAccessConfig)
+ {
+ OMRSTopicConnector enterpriseOMRSTopicConnector = null;
+
+ if (enterpriseAccessConfig != null)
+ {
+ Connection enterpriseOMRSTopicConnection = enterpriseAccessConfig.getEnterpriseOMRSTopicConnection();
+
+ if (enterpriseOMRSTopicConnection != null)
+ {
+ enterpriseOMRSTopicConnector = getTopicConnector("Enterprise Access",
+ enterpriseOMRSTopicConnection);
+ }
+ }
+
+ return enterpriseOMRSTopicConnector;
+ }
+
+
+ /**
+ * Initialize the OMRSEnterpriseConnectorManager and the EnterpriseOMRSConnector class. If the
+ * enterprise access configuration
+ *
+ * @param enterpriseAccessConfig - enterprise access configuration from the OMAG server
+ * @return initialized OMRSEnterpriseConnectorManager object
+ */
+ private OMRSEnterpriseConnectorManager initializeEnterpriseConnectorManager(EnterpriseAccessConfig enterpriseAccessConfig)
+ {
+ OMRSEnterpriseConnectorManager enterpriseConnectorManager = null;
+
+ if (enterpriseAccessConfig == null)
+ {
+ /*
+ * Federation is not enabled in this server
+ */
+ enterpriseConnectorManager = new OMRSEnterpriseConnectorManager(false);
+
+ /*
+ * Pass the address of the enterprise connector manager to the OMRSEnterpriseConnectorProvider class as
+ * the connector manager is needed by each instance of the EnterpriseOMRSConnector.
+ */
+ EnterpriseOMRSConnectorProvider.initialize(enterpriseConnectorManager,
+ null,
+ null);
+ }
+ else
+ {
+ /*
+ * Enterprise access is enabled in this server
+ */
+ final String actionDescription = "Initialize Repository Operational Services";
+
+ OMRSAuditCode auditCode = OMRSAuditCode.ENTERPRISE_ACCESS_INITIALIZING;
+ auditLog.logRecord(actionDescription,
+ auditCode.getLogMessageId(),
+ auditCode.getSeverity(),
+ auditCode.getFormattedLogMessage(),
+ null,
+ auditCode.getSystemAction(),
+ auditCode.getUserAction());
+
+ enterpriseConnectorManager = new OMRSEnterpriseConnectorManager(true);
+
+ /*
+ * Pass the address of the enterprise connector manager to the OMRSEnterpriseConnectorProvider class as
+ * the connector manager is needed by each instance of the EnterpriseOMRSConnector.
+ */
+ EnterpriseOMRSConnectorProvider.initialize(enterpriseConnectorManager,
+ enterpriseAccessConfig.getEnterpriseMetadataCollectionId(),
+ enterpriseAccessConfig.getEnterpriseMetadataCollectionName());
+ }
+
+ return enterpriseConnectorManager;
+ }
+
+
+ /**
+ * If the local repository is configured then set up the local repository connector. The
+ * information for the local repository's OMRS Repository Connector is configured as a OCF connection in
+ * the local repository config. In fact there are potentially 2 connections configured. There is a connection
+ * for remote access to the local repository and an optional connection for a locally optimized connector to use
+ * within the local server.
+ *
+ * @param localRepositoryConfig - local repository config.
+ * @return wrapped OMRS Repository Connector
+ */
+ private LocalOMRSRepositoryConnector initializeLocalRepository(LocalRepositoryConfig localRepositoryConfig)
+ {
+ LocalOMRSRepositoryConnector localRepositoryConnector = null;
+
+ /*
+ * If the local repository is configured then create the connector to the local repository and
+ * configure it. It is valid to have a server with no local repository.
+ */
+ if (localRepositoryConfig != null)
+ {
+ /*
+ * Create the local repository's Connector Provider. This is a special connector provider that
+ * creates an OMRS Repository Connector that wraps the real OMRS Repository Connector. The
+ * outer OMRS Repository Connector manages events, audit logging and error handling.
+ */
+ LocalOMRSConnectorProvider localConnectorProvider =
+ new LocalOMRSConnectorProvider(localMetadataCollectionId,
+ localRepositoryConfig.getLocalRepositoryRemoteConnection(),
+ localServerName,
+ localServerType,
+ localOrganizationName,
+ getLocalRepositoryEventMapper(localRepositoryConfig.getEventMapperConnection()),
+ localRepositoryEventManager,
+ localRepositoryContentManager,
+ new OMRSRepositoryEventExchangeRule("Local Repository Events To Save",
+ localRepositoryContentManager,
+ localRepositoryConfig.getEventsToSaveRule(),
+ localRepositoryConfig.getSelectedTypesToSave()));
+
+
+ /*
+ * Create the local repository's connector. If there is no locally optimized connection, the
+ * remote connection is used.
+ */
+ Connection localRepositoryConnection = null;
+
+ if (localRepositoryConfig.getLocalRepositoryLocalConnection() != null)
+ {
+ localRepositoryConnection = localRepositoryConfig.getLocalRepositoryLocalConnection();
+ }
+ else
+ {
+ localRepositoryConnection = localRepositoryConfig.getLocalRepositoryRemoteConnection();
+ }
+ localRepositoryConnector = this.getLocalOMRSConnector(localRepositoryConnection,
+ localConnectorProvider);
+ }
+
+ return localRepositoryConnector;
+ }
+
+
+ /**
+ * Return an OMRS archive manager configured with the list of Open Metadata Archive Stores to use.
+ *
+ * @param openMetadataArchiveConnections - connections to the open metadata archive stores
+ * @return OMRS archive manager
+ */
+ private OMRSArchiveManager initializeOpenMetadataArchives(ArrayList<Connection> openMetadataArchiveConnections)
+ {
+ ArrayList<OpenMetadataArchiveStore> openMetadataArchives = null;
+
+ if (openMetadataArchiveConnections != null)
+ {
+ openMetadataArchives = new ArrayList<>();
+
+ for (Connection archiveConnection : openMetadataArchiveConnections)
+ {
+ if (archiveConnection != null)
+ {
+ /*
+ * Any problems creating the connectors will result in an exception.
+ */
+ openMetadataArchives.add(this.getOpenMetadataArchiveStore(archiveConnection));
+ }
+ }
+ }
+
+ return new OMRSArchiveManager(openMetadataArchives);
+ }
+
+
+ /**
+ * A server can optionally connect to one or more open metadata repository cohorts. There is one
+ * CohortConfig for each cohort that the server is to connect to. The communication between
+ * members of a cohort is event-based. The parameters provide supplied to the metadata highway manager
+ * include values need to send compliant OMRS Events.
+ *
+ * @param localServerName - the name of the local server. This value flows in OMRS Events.
+ * @param localServerType - the type of the local server. This value flows in OMRS Events.
+ * @param localOrganizationName - the name of the organization that owns this server.
+ * This value flows in OMRS Events.
+ * @param localRepositoryConnector - the local repository connector is supplied if there is a local repository
+ * for this server.
+ * @param localTypeDefValidator - the TypeDef validator validates the TypeDefs sent by the other members of
+ * the cohort(s). It is looking for conflicting TypeDefs that may cause
+ * metadata integrity issues as the metadata is exchanged between the servers.
+ * @param connectionConsumer - the connection consumer is from the enterprise repository services. It
+ * receives connection information about the other members of the cohort(s)
+ * to enable enterprise access.
+ * @param enterpriseTopicConnector - connector to the enterprise repository services Topic Connector.
+ * The cohorts replicate their events to the enterprise OMRS Topic so
+ * the Open Metadata Access Services (OMASs) can monitor changing metadata.
+ * @param cohortConfigList - list of cohorts to connect to (and the configuration to do it)
+ * @return newly created and initialized metadata highway manager.
+ */
+ private OMRSMetadataHighwayManager initializeCohorts(String localServerName,
+ String localServerType,
+ String localOrganizationName,
+ LocalOMRSRepositoryConnector localRepositoryConnector,
+ OMRSTypeDefValidator localTypeDefValidator,
+ OMRSConnectionConsumer connectionConsumer,
+ OMRSTopicConnector enterpriseTopicConnector,
+ ArrayList<CohortConfig> cohortConfigList)
+ {
+ /*
+ * The metadata highway manager is constructed with the values that are the same for every cohort.
+ */
+ OMRSMetadataHighwayManager metadataHighwayManager = new OMRSMetadataHighwayManager(localServerName,
+ localServerType,
+ localOrganizationName,
+ localRepositoryConnector,
+ localTypeDefValidator,
+ connectionConsumer,
+ enterpriseTopicConnector);
+
+ /*
+ * The metadata highway manager is initialize with the details specific to each cohort.
+ */
+ metadataHighwayManager.initialize(cohortConfigList);
+
+ return metadataHighwayManager;
+ }
+
+
+ /**
+ * Shutdown the Open Metadata Repository Services.
+ *
+ * @param permanent - boolean flag indicating whether this server permanently shutting down or not
+ * @return boolean indicated whether the disconnect was successful.
+ */
+ public boolean disconnect(boolean permanent)
+ {
+ /*
+ * Log that the OMRS is disconnecting. There is another Audit log message logged at the end of this method
+ * to confirm that all of the pieces disconnected successfully.
+ */
+ final String actionDescription = "Disconnect Repository Operational Services";
+ OMRSAuditCode auditCode = OMRSAuditCode.OMRS_DISCONNECTING;
+ auditLog.logRecord(actionDescription,
+ auditCode.getLogMessageId(),
+ auditCode.getSeverity(),
+ auditCode.getFormattedLogMessage(),
+ null,
+ auditCode.getSystemAction(),
+ auditCode.getUserAction());
+
+
+ if (metadataHighwayManager != null)
+ {
+ metadataHighwayManager.disconnect(permanent);
+ }
+
+ if (enterpriseOMRSTopicConnector != null)
+ {
+ try
+ {
+ enterpriseOMRSTopicConnector.disconnect();
+ }
+ catch (Throwable error)
+ {
+ // TODO
+ }
+ }
+
+ if (enterpriseConnectorManager != null)
+ {
+ enterpriseConnectorManager.disconnect();
+ }
+
+ if (localRepositoryConnector != null)
+ {
+ try
+ {
+ localRepositoryConnector.disconnect();
+ }
+ catch (Throwable error)
+ {
+
+ }
+ }
+
+ if (archiveManager != null)
+ {
+ archiveManager.close();
+ }
+
+ auditCode = OMRSAuditCode.OMRS_DISCONNECTED;
+ auditLog.logRecord(actionDescription,
+ auditCode.getLogMessageId(),
+ auditCode.getSeverity(),
+ auditCode.getFormattedLogMessage(),
+ null,
+ auditCode.getSystemAction(),
+ auditCode.getUserAction());
+
+ return true;
+ }
+
+
+ /**
+ * Return the connector to the AuditLog store using the connection information supplied. If there is a
+ * problem with the connection information that means a connector can not be created, an exception is thrown.
+ *
+ * @param auditLogStoreConnection - properties for the audit log
+ * @return audit log store connector
+ */
+ private OMRSAuditLogStore getAuditLogStore(Connection auditLogStoreConnection)
+ {
+ try
+ {
+ ConnectorBroker connectorBroker = new ConnectorBroker();
+ Connector connector = connectorBroker.getConnector(auditLogStoreConnection);
+
+ return (OMRSAuditLogStore)connector;
+ }
+ catch (Throwable error)
+ {
+ String methodName = "getAuditLogStore()";
+
+ if (log.isDebugEnabled())
+ {
+ log.debug("Unable to create audit log store connector: " + error.toString());
+ }
+
+ /*
+ * Throw runtime exception to indicate that the audit log is not available.
+ */
+ OMRSErrorCode errorCode = OMRSErrorCode.NULL_AUDIT_LOG_STORE;
+ String errorMessage = errorCode.getErrorMessageId()
+ + errorCode.getFormattedErrorMessage(localServerName);
+
+ throw new OMRSConfigErrorException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ methodName,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction(),
+ error);
+ }
+ }
+
+
+
+ /**
+ * Creates a topic connector using information from the supplied topic connection. This connector supported
+ * the Open Connector Framework (OCF) so it is possible to configure different connector implementations for
+ * different event/messaging infrastructure. If there is a problem with the connection information
+ * that means a connector can not be created, an exception is thrown.
+ *
+ * @param sourceName - name of the user of this topic
+ * @param topicConnection - connection parameters
+ * @return OMRSTopicConnector for managing communications with the event/messaging infrastructure.
+ */
+ private OMRSTopicConnector getTopicConnector(String sourceName,
+ Connection topicConnection)
+ {
+ try
+ {
+ ConnectorBroker connectorBroker = new ConnectorBroker();
+ Connector connector = connectorBroker.getConnector(topicConnection);
+
+ return (OMRSTopicConnector)connector;
+ }
+ catch (Throwable error)
+ {
+ String methodName = "getTopicConnector()";
+
+ if (log.isDebugEnabled())
+ {
+ log.debug("Unable to create topic connector: " + error.toString());
+ }
+
+ OMRSErrorCode errorCode = OMRSErrorCode.NULL_TOPIC_CONNECTOR;
+ String errorMessage = errorCode.getErrorMessageId()
+ + errorCode.getFormattedErrorMessage(sourceName);
+
+ throw new OMRSConfigErrorException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ methodName,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction(),
+ error);
+
+ }
+ }
+
+
+ /**
+ * Return the connector to an open metadata archive store. Each connector instance can access a single
+ * open metadata archive. If there is a problem with the connection information
+ * that means a connector can not be created, an exception is thrown.
+ *
+ * @param openMetadataArchiveStoreConnection - properties used to create the connection
+ * @return open metadata archive connector
+ */
+ private OpenMetadataArchiveStore getOpenMetadataArchiveStore(Connection openMetadataArchiveStoreConnection)
+ {
+ try
+ {
+ ConnectorBroker connectorBroker = new ConnectorBroker();
+ Connector connector = connectorBroker.getConnector(openMetadataArchiveStoreConnection);
+
+ return (OpenMetadataArchiveStore)connector;
+ }
+ catch (Throwable error)
+ {
+ String methodName = "getOpenMetadataArchiveStore()";
+
+ if (log.isDebugEnabled())
+ {
+ log.debug("Unable to create open metadata archive connector: " + error.toString());
+ }
+
+ /*
+ * Throw runtime exception to indicate that the open metadata archive store is not available.
+ */
+ OMRSErrorCode errorCode = OMRSErrorCode.NULL_ARCHIVE_STORE;
+ String errorMessage = errorCode.getErrorMessageId()
+ + errorCode.getFormattedErrorMessage(localServerName);
+
+ throw new OMRSRuntimeException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ methodName,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction(),
+ error);
+ }
+ }
+
+
+ /**
+ * The local repository may need an event mapper to convert its proprietary events to OMRS Events.
+ * An event mapper is implemented as an OMRSRepositoryEventMapper Connector and it is initialized through the
+ * OCF Connector Broker using an OCF connection.
+ *
+ * @param localRepositoryEventMapperConnection - connection to the local repository's event mapper.
+ * @return local repository's event mapper
+ */
+ private OMRSRepositoryEventMapper getLocalRepositoryEventMapper(Connection localRepositoryEventMapperConnection)
+ {
+ /*
+ * If the event mapper is null it means the local repository does not need an event mapper.
+ * This is not an error.
+ */
+ if (localRepositoryEventMapperConnection == null)
+ {
+ return null;
+ }
+
+ /*
+ * The event mapper is a pluggable component that is implemented as an OCF connector. Its configuration is
+ * passed to it in a Connection object and the ConnectorBroker manages its creation and initialization.
+ */
+ try
+ {
+ ConnectorBroker connectorBroker = new ConnectorBroker();
+ Connector connector = connectorBroker.getConnector(localRepositoryEventMapperConnection);
+
+ return (OMRSRepositoryEventMapper)connector;
+ }
+ catch (Throwable error)
+ {
+ String methodName = "getLocalRepositoryEventMapper()";
+
+ if (log.isDebugEnabled())
+ {
+ log.debug("Unable to create local repository event mapper connector: " + error.toString());
+ }
+
+ /*
+ * Throw runtime exception to indicate that the local repository's event mapper is not available.
+ */
+ OMRSErrorCode errorCode = OMRSErrorCode.NULL_EVENT_MAPPER;
+ String errorMessage = errorCode.getErrorMessageId()
+ + errorCode.getFormattedErrorMessage(localServerName);
+
+ throw new OMRSConfigErrorException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ methodName,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction(),
+ error);
+ }
+ }
+
+
+
+ /**
+ * Private method to convert a Connection into a LocalOMRSRepositoryConnector using the LocalOMRSConnectorProvider.
+ * The supplied connection is for the real local connector. LocalOMRSRepositoryConnector will create the
+ * real local connector and ensure all requests it receives are passed to it.
+ *
+ * @param connection - Connection properties for the real local connection
+ * @param connectorProvider - connector provider to create the repository connector
+ * @return LocalOMRSRepositoryConnector wrapping the real local connector
+ */
+ private LocalOMRSRepositoryConnector getLocalOMRSConnector(Connection connection,
+ LocalOMRSConnectorProvider connectorProvider)
+ {
+ String methodName = "getLocalOMRSConnector()";
+
+ /*
+ * Although the localOMRSConnector is an OMRSRepositoryConnector, its initialization is
+ * managed directly with its connector provider (rather than using the connector broker) because it
+ * needs access to a variety of OMRS components in order for it to support access to the local
+ * repository by other OMRS components. As such it needs more variables at initialization.
+ */
+ try
+ {
+ return (LocalOMRSRepositoryConnector)connectorProvider.getConnector(connection);
+ }
+ catch (Throwable error)
+ {
+ /*
+ * If there is a problem initializing the connector then the ConnectorBroker will have created a
+ * detailed exception already. The only error case that this method has introduced is the cast
+ * of the Connector to OMRSRepositoryConnector. This could occur if the connector configured is a valid
+ * OCF Connector but not an OMRSRepositoryConnector.
+ */
+ String connectionName = connection.getConnectionName();
+
+ OMRSErrorCode errorCode = OMRSErrorCode.INVALID_OMRS_CONNECTION;
+ String errorMessage = errorCode.getErrorMessageId()
+ + errorCode.getFormattedErrorMessage(connectionName);
+
+ throw new OMRSRuntimeException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ methodName,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction(),
+ error);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/admin/properties/CohortConfig.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/admin/properties/CohortConfig.java b/omrs/src/main/java/org/apache/atlas/omrs/admin/properties/CohortConfig.java
new file mode 100644
index 0000000..5fc5983
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/admin/properties/CohortConfig.java
@@ -0,0 +1,233 @@
+/*
+ * 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.admin.properties;
+
+
+import org.apache.atlas.ocf.properties.Connection;
+import org.apache.atlas.omrs.metadatacollection.properties.typedefs.TypeDefSummary;
+
+import java.util.ArrayList;
+
+/**
+ * CohortConfig provides the configuration properties used to connect to an open metadata repository cohort.
+ * <ul>
+ * <li>
+ * cohortName is a descriptive name for the cohort that is used primarily for messages and diagnostics.
+ * It is also used to create a default name for the cohort's OMRS Topic and the cohortRegistry's store
+ * if these names are not explicitly defined.
+ * </li>
+ * <li>
+ * cohortRegistryConnection is the connection properties necessary to create the connector to the
+ * cohort registry store. This is the store where the cohort registry keeps information about its
+ * local metadata collection Id and details of other repositories in the cohort.
+ *
+ * The default value is to use a local file called "cohort.registry" that is stored in the server's
+ * home directory.
+ * </li>
+ * <li>
+ * cohortOMRSTopicConnection is the connection properties necessary to create the connector to the OMRS Topic.
+ * This is used to send/receive events between members of the open metadata repository cohort.
+ * </li>
+ * <li>
+ * cohortOMRSTopicProtocolVersion defines the versionName of the event payload to use when communicating with other
+ * members of the cohort through the OMRS Topic.
+ * </li>
+ * <li>
+ * eventsToProcessRule defines how incoming events on the OMRS Topic should be processed.
+ * </li>
+ * <li>
+ * selectedTypesToProcess - list of TypeDefs used if the eventsToProcess rule (above) says
+ * "SELECTED_TYPES" - otherwise it is set to null.
+ * </li>
+ * </ul>
+ */
+public class CohortConfig
+{
+ private String cohortName = null;
+ private Connection cohortRegistryConnection = null;
+ private Connection cohortOMRSTopicConnection = null;
+ private OpenMetadataEventProtocolVersion cohortOMRSTopicProtocolVersion = null;
+ private OpenMetadataExchangeRule eventsToProcessRule = null;
+ private ArrayList<TypeDefSummary> selectedTypesToProcess = null;
+
+
+
+ /**
+ * Default constructor does nothing.
+ */
+ public CohortConfig()
+ {
+ }
+
+
+ /**
+ * Constructor to populate all config values.
+ *
+ * @param cohortName - name of the cohort
+ * @param cohortRegistryConnection - connection to the cohort registry store
+ * @param cohortOMRSTopicConnection - connection to the OMRS Topic
+ * @param eventsToProcessRule - rule indicating whether metadata events should be sent to the federated OMRS Topic.
+ * @param selectedTypesToProcess - if the rule says "SELECTED_TYPES" then this is the list of types - otherwise
+ * it is set to null.
+ */
+ public CohortConfig(String cohortName,
+ Connection cohortRegistryConnection,
+ Connection cohortOMRSTopicConnection,
+ OpenMetadataExchangeRule eventsToProcessRule,
+ ArrayList<TypeDefSummary> selectedTypesToProcess)
+ {
+ this.cohortName = cohortName;
+ this.cohortRegistryConnection = cohortRegistryConnection;
+ this.cohortOMRSTopicConnection = cohortOMRSTopicConnection;
+ this.eventsToProcessRule = eventsToProcessRule;
+ this.selectedTypesToProcess = selectedTypesToProcess;
+ }
+
+
+ /**
+ * Return the name of the cohort.
+ *
+ * @return String name
+ */
+ public String getCohortName()
+ {
+ return cohortName;
+ }
+
+
+ /**
+ * Set up the name of the cohort.
+ *
+ * @param cohortName String
+ */
+ public void setCohortName(String cohortName)
+ {
+ this.cohortName = cohortName;
+ }
+
+
+ /**
+ * Set up the connection to the cohort registry store.
+ *
+ * @return Connection object
+ */
+ public Connection getCohortRegistryConnection()
+ {
+ return cohortRegistryConnection;
+ }
+
+
+ /**
+ * Set up the connection for the cohort registry store.
+ *
+ * @param cohortRegistryConnection - Connection object
+ */
+ public void setCohortRegistryConnection(Connection cohortRegistryConnection)
+ {
+ this.cohortRegistryConnection = cohortRegistryConnection;
+ }
+
+
+ /**
+ * Return the connection to the cohort's OMRS Topic.
+ *
+ * @return Connection object
+ */
+ public Connection getCohortOMRSTopicConnection()
+ {
+ return cohortOMRSTopicConnection;
+ }
+
+ /**
+ * Set up the connection to the cohort's OMRS Topic.
+ *
+ * @param cohortOMRSTopicConnection - Connection object
+ */
+ public void setCohortOMRSTopicConnection(Connection cohortOMRSTopicConnection)
+ {
+ this.cohortOMRSTopicConnection = cohortOMRSTopicConnection;
+ }
+
+
+ /**
+ * Return the protocol versionName to use when exchanging events amongst the cohort members.
+ *
+ * @return protocol versionName enum
+ */
+ public OpenMetadataEventProtocolVersion getCohortOMRSTopicProtocolVersion()
+ {
+ return cohortOMRSTopicProtocolVersion;
+ }
+
+
+ /**
+ * Set up the protocol versionName to use when exchanging events amongst the cohort members.
+ *
+ * @param cohortOMRSTopicProtocolVersion - protocol versionName enum
+ */
+ public void setCohortOMRSTopicProtocolVersion(OpenMetadataEventProtocolVersion cohortOMRSTopicProtocolVersion)
+ {
+ this.cohortOMRSTopicProtocolVersion = cohortOMRSTopicProtocolVersion;
+ }
+
+
+ /**
+ * Return the rule indicating whether incoming metadata events from a cohort should be processed.
+ *
+ * @return OpenMetadataExchangeRule - NONE, JUST_TYPEDEFS, SELECTED_TYPES and ALL.
+ */
+ public OpenMetadataExchangeRule getEventsToProcessRule()
+ {
+ return eventsToProcessRule;
+ }
+
+
+ /**
+ * Set up the rule indicating whether incoming metadata events from a cohort should be processed.
+ *
+ * @param eventsToProcessRule - OpenMetadataExchangeRule - NONE, JUST_TYPEDEFS, SELECTED_TYPES and ALL.
+ */
+ public void setEventsToProcessRule(OpenMetadataExchangeRule eventsToProcessRule)
+ {
+ this.eventsToProcessRule = eventsToProcessRule;
+ }
+
+
+ /**
+ * Return the list of TypeDefs used if the eventsToProcess rule (above) says "SELECTED_TYPES" - otherwise
+ * it is set to null.
+ *
+ * @return list of TypeDefs that determine which metadata instances to process
+ */
+ public ArrayList<TypeDefSummary> getSelectedTypesToProcess()
+ {
+ return selectedTypesToProcess;
+ }
+
+
+ /**
+ * Set up the list of TypeDefs used if the EventsToProcess rule (above) says "SELECTED_TYPES" - otherwise
+ * it is set to null.
+ *
+ * @param selectedTypesToProcess - list of TypeDefs that determine which metadata instances to process
+ */
+ public void setSelectedTypesToProcess(ArrayList<TypeDefSummary> selectedTypesToProcess)
+ {
+ this.selectedTypesToProcess = selectedTypesToProcess;
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/admin/properties/EnterpriseAccessConfig.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/admin/properties/EnterpriseAccessConfig.java b/omrs/src/main/java/org/apache/atlas/omrs/admin/properties/EnterpriseAccessConfig.java
new file mode 100644
index 0000000..72e84af
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/admin/properties/EnterpriseAccessConfig.java
@@ -0,0 +1,167 @@
+/*
+ * 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.admin.properties;
+
+import org.apache.atlas.ocf.properties.Connection;
+
+/**
+ * EnterpriseAccessConfig describes the properties that control the enterprise access services that the
+ * OMRS provides to the Open Metadata Access Services (OMASs).
+ * <ul>
+ * <li>
+ * enterpriseMetadataCollectionName - name of the combined metadata collection covered by the connected open
+ * metadata repositories. Used for messages.
+ * </li>
+ * <li>
+ * enterpriseMetadataCollectionId - unique identifier for the combined metadata collection covered by the
+ * connected open metadata repositories.
+ * </li>
+ * <li>
+ * enterpriseOMRSTopicConnection - connection for the enterprise OMRS Topic connector.
+ * </li>
+ * </ul>
+ */
+public class EnterpriseAccessConfig
+{
+ private String enterpriseMetadataCollectionName = null;
+ private String enterpriseMetadataCollectionId = null;
+ private Connection enterpriseOMRSTopicConnection = null;
+ private OpenMetadataEventProtocolVersion enterpriseOMRSTopicProtocolVersion = null;
+
+
+ /**
+ * Default Constructor does nothing.
+ */
+ public EnterpriseAccessConfig()
+ {
+ }
+
+
+ /**
+ * Constructor to set up all configuration values.
+ *
+ * @param enterpriseMetadataCollectionName - name of the combined metadata collection covered by the connected open
+ * metadata repositories. Used for messages.
+ * @param enterpriseMetadataCollectionId - unique identifier for the combined metadata collection covered by the
+ * connected open metadata repositories.
+ * @param enterpriseOMRSTopicConnection - connection for the OMRS Topic connector.
+ * @param enterpriseOMRSTopicProtocolVersion - protocol versionName enum
+ */
+ public EnterpriseAccessConfig(String enterpriseMetadataCollectionName,
+ String enterpriseMetadataCollectionId,
+ Connection enterpriseOMRSTopicConnection,
+ OpenMetadataEventProtocolVersion enterpriseOMRSTopicProtocolVersion)
+ {
+ this.enterpriseMetadataCollectionName = enterpriseMetadataCollectionName;
+ this.enterpriseMetadataCollectionId = enterpriseMetadataCollectionId;
+ this.enterpriseOMRSTopicConnection = enterpriseOMRSTopicConnection;
+ this.enterpriseOMRSTopicProtocolVersion = enterpriseOMRSTopicProtocolVersion;
+ }
+
+
+ /**
+ * Return the name of the combined metadata collection covered by the connected open
+ * metadata repositories. Used for messages.
+ *
+ * @return String name
+ */
+ public String getEnterpriseMetadataCollectionName()
+ {
+ return enterpriseMetadataCollectionName;
+ }
+
+
+ /**
+ * Set up the name of the combined metadata collection covered by the connected open
+ * metadata repositories. Used for messages.
+ *
+ * @param enterpriseMetadataCollectionName - String name
+ */
+ public void setEnterpriseMetadataCollectionName(String enterpriseMetadataCollectionName)
+ {
+ this.enterpriseMetadataCollectionName = enterpriseMetadataCollectionName;
+ }
+
+
+ /**
+ * Return the unique identifier for the combined metadata collection covered by the
+ * connected open metadata repositories.
+ *
+ * @return Unique identifier (guid)
+ */
+ public String getEnterpriseMetadataCollectionId()
+ {
+ return enterpriseMetadataCollectionId;
+ }
+
+
+ /**
+ * Set up the unique identifier for the combined metadata collection covered by the
+ * connected open metadata repositories.
+ *
+ * @param enterpriseMetadataCollectionId - Unique identifier (guid)
+ */
+ public void setEnterpriseMetadataCollectionId(String enterpriseMetadataCollectionId)
+ {
+ this.enterpriseMetadataCollectionId = enterpriseMetadataCollectionId;
+ }
+
+
+ /**
+ * Return the connection for the Enterprise OMRS Topic connector.
+ *
+ * @return Connection object
+ */
+ public Connection getEnterpriseOMRSTopicConnection()
+ {
+ return enterpriseOMRSTopicConnection;
+ }
+
+
+ /**
+ * Set up the connection for the Enterprise OMRS Topic connector.
+ *
+ * @param enterpriseOMRSTopicConnection - Connection object
+ */
+ public void setEnterpriseOMRSTopicConnection(Connection enterpriseOMRSTopicConnection)
+ {
+ this.enterpriseOMRSTopicConnection = enterpriseOMRSTopicConnection;
+ }
+
+
+ /**
+ * Return the protocol versionName to use on the EnterpriseOMRSTopicConnector.
+ *
+ * @return protocol versionName enum
+ */
+ public OpenMetadataEventProtocolVersion getEnterpriseOMRSTopicProtocolVersion()
+ {
+ return enterpriseOMRSTopicProtocolVersion;
+ }
+
+
+ /**
+ * Set up the protocol versionName to use on the EnterpriseOMRSTopicConnector.
+ *
+ * @param enterpriseOMRSTopicProtocolVersion - protocol versionName enum
+ */
+ public void setEnterpriseOMRSTopicProtocolVersion(OpenMetadataEventProtocolVersion enterpriseOMRSTopicProtocolVersion)
+ {
+ this.enterpriseOMRSTopicProtocolVersion = enterpriseOMRSTopicProtocolVersion;
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/admin/properties/LocalRepositoryConfig.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/admin/properties/LocalRepositoryConfig.java b/omrs/src/main/java/org/apache/atlas/omrs/admin/properties/LocalRepositoryConfig.java
new file mode 100644
index 0000000..d35b788
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/admin/properties/LocalRepositoryConfig.java
@@ -0,0 +1,310 @@
+/*
+ * 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.admin.properties;
+
+import org.apache.atlas.ocf.properties.Connection;
+import org.apache.atlas.omrs.metadatacollection.properties.typedefs.TypeDefSummary;
+
+import java.util.ArrayList;
+
+
+/**
+ * LocalRepositoryConfig provides the properties to control the behavior of the metadata repository associated with
+ * this server.
+ * <ul>
+ * <li>
+ * metadataCollectionId - unique id of local repository's metadata collection. If this value is set to
+ * null, the server will generate a unique Id.
+ * </li>
+ * <li>
+ * localRepositoryLocalConnection - the connection properties used to create a locally optimized connector
+ * to the local repository for use by this local server's components. If this value is null then the
+ * localRepositoryRemoteConnection is used.
+ * </li>
+ * <li>
+ * localRepositoryRemoteConnection - the connection properties used to create a connector
+ * to the local repository for use by remote servers.
+ * </li>
+ * <li>
+ * eventsToSaveRule - enumeration describing which open metadata repository events should be saved to
+ * the local repository.
+ * </li>
+ * <li>
+ * selectedTypesToSave - list of TypeDefs in supported of the eventsToSave.SELECTED_TYPES option.
+ * </li>
+ * <li>
+ * eventsToSendRule - enumeration describing which open metadata repository events should be sent from
+ * the local repository.
+ * </li>
+ * <li>
+ * selectedTypesToSend - list of TypeDefs in supported of the eventsToSend.SELECTED_TYPES option.
+ * </li>
+ * <li>
+ * eventMapperConnection - the connection properties for the event mapper for the local repository.
+ * The event mapper is an optional component used when the local repository has proprietary external
+ * APIs that can change metadata in the repository without going through the OMRS interfaces.
+ * It maps the proprietary events from the local repository to the OMRS Events.
+ * </li>
+ * </ul>
+ */
+public class LocalRepositoryConfig
+{
+ private String metadataCollectionId = null;
+ private Connection localRepositoryLocalConnection = null;
+ private Connection localRepositoryRemoteConnection = null;
+ private OpenMetadataExchangeRule eventsToSaveRule = null;
+ private ArrayList<TypeDefSummary> selectedTypesToSave = null;
+ private OpenMetadataExchangeRule eventsToSendRule = null;
+ private ArrayList<TypeDefSummary> selectedTypesToSend = null;
+ private Connection eventMapperConnection = null;
+
+
+ /**
+ * Constructor
+ *
+ * @param metadataCollectionId - unique id of local repository's metadata collection
+ * @param localRepositoryLocalConnection - the connection properties used to create a locally optimized connector
+ * to the local repository for use by this local server's components.
+ * @param localRepositoryRemoteConnection - the connection properties used to create a connector
+ * to the local repository for use by remote servers.
+ * @param eventsToSaveRule - enumeration describing which open metadata repository events should be saved to
+ * the local repository.
+ * @param selectedTypesToSave - list of TypeDefs in supported of the eventsToSave.SELECTED_TYPES option.
+ * @param eventsToSendRule - enumeration describing which open metadata repository events should be sent from
+ * the local repository.
+ * @param selectedTypesToSend - list of TypeDefs in supported of the eventsToSend.SELECTED_TYPES option.
+ * @param eventMapperConnection - Connection for the local repository's event mapper. This is optional.
+ */
+ public LocalRepositoryConfig(String metadataCollectionId,
+ Connection localRepositoryLocalConnection,
+ Connection localRepositoryRemoteConnection,
+ OpenMetadataExchangeRule eventsToSaveRule,
+ ArrayList<TypeDefSummary> selectedTypesToSave,
+ OpenMetadataExchangeRule eventsToSendRule,
+ ArrayList<TypeDefSummary> selectedTypesToSend,
+ Connection eventMapperConnection)
+ {
+ this.metadataCollectionId = metadataCollectionId;
+ this.localRepositoryLocalConnection = localRepositoryLocalConnection;
+ this.localRepositoryRemoteConnection = localRepositoryRemoteConnection;
+ this.eventsToSaveRule = eventsToSaveRule;
+ this.selectedTypesToSave = selectedTypesToSave;
+ this.eventsToSendRule = eventsToSendRule;
+ this.selectedTypesToSend = selectedTypesToSend;
+ this.eventMapperConnection = eventMapperConnection;
+ }
+
+
+ /**
+ * Default constructor used for JSON to Java processes - does not do anything useful because all
+ * local variables are initialized to null in their declaration.
+ */
+ public LocalRepositoryConfig()
+ {
+ }
+
+
+ /**
+ * Return the unique id of local repository's metadata collection. If this value is set to
+ * null, the server will generate a unique Id.
+ *
+ * @return String unique Id
+ */
+ public String getMetadataCollectionId()
+ {
+ return metadataCollectionId;
+ }
+
+
+ /**
+ * Set up the unique id of local repository's metadata collection. If this value is set to
+ * null, the server will generate a unique Id.
+ *
+ * @param metadataCollectionId - String unique Id
+ */
+ public void setMetadataCollectionId(String metadataCollectionId)
+ {
+ this.metadataCollectionId = metadataCollectionId;
+ }
+
+
+ /**
+ * Return the connection properties used to create a locally optimized connector to the local repository for
+ * use by this local server's components. If this value is null then the localRepositoryRemoteConnection is used.
+ *
+ * @return Connection properties object
+ */
+ public Connection getLocalRepositoryLocalConnection()
+ {
+ return localRepositoryLocalConnection;
+ }
+
+
+ /**
+ * Set up the connection properties used to create a locally optimized connector to the local repository for
+ * use by this local server's components. If this value is null then the localRepositoryRemoteConnection is used.
+ *
+ * @param localRepositoryLocalConnection - Connection properties object
+ */
+ public void setLocalRepositoryLocalConnection(Connection localRepositoryLocalConnection)
+ {
+ this.localRepositoryLocalConnection = localRepositoryLocalConnection;
+ }
+
+
+ /**
+ * Return the connection properties used to create a connector to the local repository for use by remote servers.
+ *
+ * @return Connection properties object
+ */
+ public Connection getLocalRepositoryRemoteConnection()
+ {
+ return localRepositoryRemoteConnection;
+ }
+
+
+ /**
+ * Set up the connection properties used to create a connector to the local repository for use by remote servers.
+ *
+ * @param localRepositoryRemoteConnection - Connection properties object
+ */
+ public void setLocalRepositoryRemoteConnection(Connection localRepositoryRemoteConnection)
+ {
+ this.localRepositoryRemoteConnection = localRepositoryRemoteConnection;
+ }
+
+
+ /**
+ * Return the enumeration describing which open metadata repository events should be saved to
+ * the local repository.
+ *
+ * @return OpenMetadataExchangeRule enum
+ */
+ public OpenMetadataExchangeRule getEventsToSaveRule()
+ {
+ return eventsToSaveRule;
+ }
+
+
+ /**
+ * Set up the enumeration describing which open metadata repository events should be saved to
+ * the local repository.
+ *
+ * @param eventsToSaveRule - OpenMetadataExchangeRule enum
+ */
+ public void setEventsToSaveRule(OpenMetadataExchangeRule eventsToSaveRule)
+ {
+ this.eventsToSaveRule = eventsToSaveRule;
+ }
+
+
+ /**
+ * Return the list of TypeDefs in supported of the eventsToSave.SELECTED_TYPES option.
+ *
+ * @return list of types
+ */
+ public ArrayList<TypeDefSummary> getSelectedTypesToSave()
+ {
+ return selectedTypesToSave;
+ }
+
+
+ /**
+ * Set up the list of TypeDefs in supported of the eventsToSave.SELECTED_TYPES option.
+ *
+ * @param selectedTypesToSave - list of types
+ */
+ public void setSelectedTypesToSave(ArrayList<TypeDefSummary> selectedTypesToSave)
+ {
+ this.selectedTypesToSave = selectedTypesToSave;
+ }
+
+
+ /**
+ * Return the enumeration describing which open metadata repository events should be sent from
+ * the local repository.
+ *
+ * @return OpenMetadataExchangeRule enum
+ */
+ public OpenMetadataExchangeRule getEventsToSendRule()
+ {
+ return eventsToSendRule;
+ }
+
+
+ /**
+ * Set up the enumeration describing which open metadata repository events should be sent from
+ * the local repository.
+ *
+ * @param eventsToSendRule - OpenMetadataExchangeRule enum
+ */
+ public void setEventsToSendRule(OpenMetadataExchangeRule eventsToSendRule)
+ {
+ this.eventsToSendRule = eventsToSendRule;
+ }
+
+
+ /**
+ * Return the list of TypeDefs in supported of the eventsToSend.SELECTED_TYPES option.
+ *
+ * @return list of types
+ */
+ public ArrayList<TypeDefSummary> getSelectedTypesToSend()
+ {
+ return selectedTypesToSend;
+ }
+
+
+ /**
+ * Set up the list of TypeDefs in supported of the eventsToSend.SELECTED_TYPES option.
+ *
+ * @param selectedTypesToSend - list of types
+ */
+ public void setSelectedTypesToSend(ArrayList<TypeDefSummary> selectedTypesToSend)
+ {
+ this.selectedTypesToSend = selectedTypesToSend;
+ }
+
+
+ /**
+ * Return the connection properties for the event mapper for the local repository. The event mapper is an
+ * optional component used when the local repository has proprietary external APIs that can change metadata
+ * in the repository without going through the OMRS interfaces. It maps the proprietary events from
+ * the local repository to the OMRS Events.
+ *
+ * @return Connection properties object
+ */
+ public Connection getEventMapperConnection()
+ {
+ return eventMapperConnection;
+ }
+
+
+ /**
+ * Set up the connection properties for the event mapper for the local repository. The event mapper is an
+ * optional component used when the local repository has proprietary external APIs that can change metadata
+ * in the repository without going through the OMRS interfaces. It maps the proprietary events from
+ * the local repository to the OMRS Events.
+ *
+ * @param eventMapperConnection - Connection properties object
+ */
+ public void setEventMapperConnection(Connection eventMapperConnection)
+ {
+ this.eventMapperConnection = eventMapperConnection;
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/admin/properties/OpenMetadataEventProtocolVersion.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/admin/properties/OpenMetadataEventProtocolVersion.java b/omrs/src/main/java/org/apache/atlas/omrs/admin/properties/OpenMetadataEventProtocolVersion.java
new file mode 100644
index 0000000..301a589
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/admin/properties/OpenMetadataEventProtocolVersion.java
@@ -0,0 +1,28 @@
+/*
+ * 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.admin.properties;
+
+
+/**
+ * OpenMetadataEventProtocolVersion provides the identifier for the version number of the event payload. There is
+ * only one version at the moment which is why it looks a little sad.
+ */
+public enum OpenMetadataEventProtocolVersion
+{
+ V1
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/admin/properties/OpenMetadataExchangeRule.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/admin/properties/OpenMetadataExchangeRule.java b/omrs/src/main/java/org/apache/atlas/omrs/admin/properties/OpenMetadataExchangeRule.java
new file mode 100644
index 0000000..2bcc087
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/admin/properties/OpenMetadataExchangeRule.java
@@ -0,0 +1,106 @@
+/*
+ * 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.admin.properties;
+
+
+/**
+ * OpenMetadataExchangeRule controls the sending/receiving of metadata instances on the metadata highway.
+ * <ul>
+ * <li>
+ * REGISTRATION_ONLY means do not send/receive reference metadata - just perform the minimal registration
+ * exchanges.
+ * </li>
+ * <li>
+ * JUST_TYPEDEFS - means only send/receive/validate type definitions (TypeDefs).
+ * </li>
+ * <li>
+ * SELECTED_TYPES means that in addition to TypeDefs events, only metadata instances of the types
+ * supplied in the related list of TypeDefs (see typesToSend, typesToSave and typesToFederate) should be processed.
+ * </li>
+ * <li>
+ * LEARNED_TYPES means that the local repository requests reference copies of metadata based on the requests of
+ * the local user community.
+ * </li>
+ * <li>
+ * ALL means send/receive all types of metadata that are supported by the local repository.
+ * </li>
+ * </ul>
+ */
+public enum OpenMetadataExchangeRule
+{
+ REGISTRATION_ONLY (0, "Registration Only", "Only registration exchange; no TypeDefs or metadata instances."),
+ JUST_TYPEDEFS (1, "Just TypeDefs", "Only registration and type definitions (TypeDefs) exchange."),
+ SELECTED_TYPES (2, "Selected Types", "Registration plus all type definitions (TypeDefs) and metadata " +
+ "instances (Entities and Relationships) of selected types."),
+ LEARNED_TYPES (3, "Learned Types", "Registration plus all type definitions (TypeDefs) and metadata " +
+ "instances (Entities and Relationships) of types " +
+ "requested by local users to this server."),
+ ALL (99, "All", "Registration plus all type definitions (TypeDefs) and metadata " +
+ "instances (Entities and Relationships).");
+
+ private int replicationRuleCode;
+ private String replicationRuleName;
+ private String replicationRuleDescription;
+
+ /**
+ * Constructor for the metadata instance replication rule.
+ *
+ * @param replicationRuleCode - the code number of this metadata instance replication rule.
+ * @param replicationRuleName - the name of this metadata instance replication rule.
+ * @param replicationRuleDescription - the description of this metadata instance replication rule.
+ */
+ OpenMetadataExchangeRule(int replicationRuleCode, String replicationRuleName, String replicationRuleDescription)
+ {
+ this.replicationRuleCode = replicationRuleCode;
+ this.replicationRuleName = replicationRuleName;
+ this.replicationRuleDescription = replicationRuleDescription;
+ }
+
+
+ /**
+ * Return the code number of this metadata instance replication rule.
+ *
+ * @return int replication rule code number
+ */
+ public int getReplicationRuleCode()
+ {
+ return replicationRuleCode;
+ }
+
+
+ /**
+ * Return the name of this metadata instance replication rule.
+ *
+ * @return String replication rule name
+ */
+ public String getReplicationRuleName()
+ {
+ return replicationRuleName;
+ }
+
+
+ /**
+ * Return the description of this metadata instance replication rule.
+ *
+ * @return String replication rule description
+ */
+ public String getReplicationRuleDescription()
+ {
+ return replicationRuleDescription;
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/admin/properties/RepositoryServicesConfig.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/admin/properties/RepositoryServicesConfig.java b/omrs/src/main/java/org/apache/atlas/omrs/admin/properties/RepositoryServicesConfig.java
new file mode 100644
index 0000000..f7e303c
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/admin/properties/RepositoryServicesConfig.java
@@ -0,0 +1,207 @@
+/*
+ * 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.admin.properties;
+
+import org.apache.atlas.ocf.properties.Connection;
+
+import java.util.ArrayList;
+
+/**
+ * RepositoryServicesConfig provides the configuration properties that are needed by the OMRS components
+ * to manage access to the metadata repositories that are members of the open metadata repository clusters that
+ * this server connects to.
+ * <ul>
+ * <li>
+ * auditLogConnection is a connection describing the connector to the AuditLog that the OMRS
+ * component should use.
+ * </li>
+ * <li>
+ * openMetadataArchiveConnectionList is a list of Open Metadata Archive Connections.
+ * An open metadata archive connection provides properties needed to create a connector to manage
+ * an open metadata archive. This contains pre-built TypeDefs and metadata instance.
+ * The archives are managed by the OMRSArchiveManager.
+ * </li>
+ * <li>
+ * localRepositoryConfig describes the properties used to manage the local metadata repository for this server.
+ * </li>
+ * <li>
+ * enterpriseAccessConfig describes the properties that control the cluster federation services that the
+ * OMRS provides to the Open Metadata AccessServices (OMASs).
+ * </li>
+ * <li>
+ * cohortConfigList provides details of each open metadata repository cluster that the local server is
+ * connected to.
+ * </li>
+ * </ul>
+ */
+public class RepositoryServicesConfig
+{
+ private Connection auditLogConnection = null;
+ private ArrayList<Connection> openMetadataArchiveConnectionList = new ArrayList<>();
+ private LocalRepositoryConfig localRepositoryConfig = null;
+ private EnterpriseAccessConfig enterpriseAccessConfig = null;
+ private ArrayList<CohortConfig> cohortConfigList = new ArrayList<>();
+
+
+ /**
+ * Default constructor does nothing
+ */
+ public RepositoryServicesConfig()
+ {
+ }
+
+
+ /**
+ * Constructor to set all properties.
+ *
+ * @param auditLogConnection - connection to the audit log.
+ * @param openMetadataArchiveConnectionList - list of open metadata archive files to load.
+ * @param localRepositoryConfig - properties to configure the behavior of the local repository.
+ * @param enterpriseAccessConfig - properties to configure the behavior of the federation services provided
+ * to the Open Metadata Access Services (OMASs).
+ * @param cohortConfigList - properties about the open metadata repository clusters that this server connects to.
+ */
+ public RepositoryServicesConfig(Connection auditLogConnection,
+ ArrayList<Connection> openMetadataArchiveConnectionList,
+ LocalRepositoryConfig localRepositoryConfig,
+ EnterpriseAccessConfig enterpriseAccessConfig,
+ ArrayList<CohortConfig> cohortConfigList)
+ {
+ this.auditLogConnection = auditLogConnection;
+ this.openMetadataArchiveConnectionList = openMetadataArchiveConnectionList;
+ this.localRepositoryConfig = localRepositoryConfig;
+ this.enterpriseAccessConfig = enterpriseAccessConfig;
+ this.cohortConfigList = cohortConfigList;
+ }
+
+
+ /**
+ * Return the Connection properties used to create an OCF Connector to the AuditLog.
+ *
+ * @return Connection object
+ */
+ public Connection getAuditLogConnection()
+ {
+ return auditLogConnection;
+ }
+
+
+ /**
+ * Set up the Connection properties used to create an OCF Connector to the AuditLog.
+ *
+ * @param auditLogConnection - Connection object
+ */
+ public void setAuditLogConnection(Connection auditLogConnection)
+ {
+ this.auditLogConnection = auditLogConnection;
+ }
+
+
+ /**
+ * Return the list of Connection object, each of which is used to create the Connector to an Open Metadata
+ * Archive. Open Metadata Archive contains pre-built metadata types and instances.
+ *
+ * @return list of Connection objects
+ */
+ public ArrayList<Connection> getOpenMetadataArchiveConnectionList()
+ {
+ return openMetadataArchiveConnectionList;
+ }
+
+
+ /**
+ * Set up the list of Connection object, each of which is used to create the Connector to an Open Metadata
+ * Archive. Open Metadata Archive contains pre-built metadata types and instances.
+ *
+ * @param openMetadataArchiveConnectionList - list of Connection objects
+ */
+ public void setOpenMetadataArchiveConnectionList(ArrayList<Connection> openMetadataArchiveConnectionList)
+ {
+ this.openMetadataArchiveConnectionList = openMetadataArchiveConnectionList;
+ }
+
+
+ /**
+ * Return the configuration properties for the local repository.
+ *
+ * @return configuration properties
+ */
+ public LocalRepositoryConfig getLocalRepositoryConfig()
+ {
+ return localRepositoryConfig;
+ }
+
+
+ /**
+ * Set up the configuration properties for the local repository.
+ *
+ * @param localRepositoryConfig - configuration properties
+ */
+ public void setLocalRepositoryConfig(LocalRepositoryConfig localRepositoryConfig)
+ {
+ this.localRepositoryConfig = localRepositoryConfig;
+ }
+
+
+ /**
+ * Return the configuration for the federation services provided by OMRS to the Open Metadata Access
+ * Services (OMASs).
+ *
+ * @return configuration properties
+ */
+ public EnterpriseAccessConfig getEnterpriseAccessConfig()
+ {
+ return enterpriseAccessConfig;
+ }
+
+
+ /**
+ * Set up the configuration for the federation services provided by OMRS to the Open Metadata Access
+ * Services (OMASs).
+ *
+ * @param enterpriseAccessConfig configuration properties
+ */
+ public void setEnterpriseAccessConfig(EnterpriseAccessConfig enterpriseAccessConfig)
+ {
+ this.enterpriseAccessConfig = enterpriseAccessConfig;
+ }
+
+
+ /**
+ * Return the configuration properties for each open metadata repository cluster that this local server
+ * connects to.
+ *
+ * @return list of cluster configuration properties
+ */
+ public ArrayList<CohortConfig> getCohortConfigList()
+ {
+ return cohortConfigList;
+ }
+
+
+ /**
+ * Set up the configuration properties for each open metadata repository cluster that this local server
+ * connects to.
+ *
+ * @param cohortConfigList - list of cluster configuration properties
+ */
+ public void setCohortConfigList(ArrayList<CohortConfig> cohortConfigList)
+ {
+ this.cohortConfigList = cohortConfigList;
+ }
+}
[11/30] atlas git commit: ATLAS-2246: OMRS Connector API plus REST
and IGC Connector skeleton - 15th February 2018
Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositoryconnector/LocalOMRSRepositoryConnector.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositoryconnector/LocalOMRSRepositoryConnector.java b/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositoryconnector/LocalOMRSRepositoryConnector.java
new file mode 100644
index 0000000..752a090
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositoryconnector/LocalOMRSRepositoryConnector.java
@@ -0,0 +1,259 @@
+/*
+ * 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.localrepository.repositoryconnector;
+
+import org.apache.atlas.ocf.ffdc.ConnectorCheckedException;
+import org.apache.atlas.ocf.properties.Connection;
+import org.apache.atlas.omrs.eventmanagement.*;
+import org.apache.atlas.omrs.eventmanagement.events.OMRSInstanceEventProcessor;
+import org.apache.atlas.omrs.eventmanagement.events.OMRSTypeDefEventProcessor;
+import org.apache.atlas.omrs.eventmanagement.repositoryeventmapper.OMRSRepositoryEventMapper;
+import org.apache.atlas.omrs.localrepository.OMRSLocalRepository;
+import org.apache.atlas.omrs.localrepository.repositorycontentmanager.OMRSRepositoryContentManager;
+import org.apache.atlas.omrs.localrepository.repositorycontentmanager.OMRSTypeDefValidator;
+import org.apache.atlas.omrs.metadatacollection.OMRSMetadataCollection;
+import org.apache.atlas.omrs.metadatacollection.repositoryconnector.OMRSRepositoryConnector;
+
+
+/**
+ * LocalOMRSRepositoryConnector provides access the local metadata repository plus manages outbound
+ * repository events.
+ *
+ * It passes each request to both the real OMRS connector for the local metadata repository and an
+ * OMRSEventPublisher. The OMRSEventPublisher will use its configuration to decide if it needs to
+ * pass on the request to the rest of the metadata repository cohort.
+ */
+public class LocalOMRSRepositoryConnector extends OMRSRepositoryConnector implements OMRSLocalRepository
+{
+ private String localServerName = null;
+ private String localServerType = null;
+ private String localOrganizationName = null;
+ private OMRSRepositoryEventMapper repositoryEventMapper = null;
+ private OMRSRepositoryContentManager localTypeDefManager = null;
+ private OMRSInstanceEventProcessor incomingInstanceEventProcessor = null;
+ private OMRSRepositoryEventManager outboundRepositoryEventManager = null;
+ private OMRSRepositoryEventProcessor outboundRepositoryEventProcessor = null;
+
+ private String localMetadataCollectionId = null;
+ private LocalOMRSMetadataCollection metadataCollection = null;
+
+ private OMRSRepositoryConnector realLocalConnector = null;
+ private OMRSMetadataCollection realMetadataCollection = null;
+
+ /**
+ * Constructor used by the LocalOMRSConnectorProvider. It provides the information necessary to run the
+ * local repository.
+ *
+ * @param localServerName - name of the local server
+ * @param localServerType - type of the local server
+ * @param localOrganizationName - name of organization that owns the server
+ * @param realLocalConnector - connector to the local repository
+ * @param repositoryEventMapper - optional event mapper for local repository
+ * @param outboundRepositoryEventManager - event manager to call for outbound events.
+ * @param localTypeDefManager - localTypeDefManager for supporting OMRS in managing TypeDefs.
+ * @param saveExchangeRule - rule to determine what events to save to the local repository.
+ */
+ protected LocalOMRSRepositoryConnector(String localServerName,
+ String localServerType,
+ String localOrganizationName,
+ OMRSRepositoryConnector realLocalConnector,
+ OMRSRepositoryEventMapper repositoryEventMapper,
+ OMRSRepositoryEventManager outboundRepositoryEventManager,
+ OMRSRepositoryContentManager localTypeDefManager,
+ OMRSRepositoryEventExchangeRule saveExchangeRule)
+ {
+ this.localServerName = localServerName;
+ this.localServerType = localServerType;
+ this.localOrganizationName = localOrganizationName;
+
+ this.realLocalConnector = realLocalConnector;
+ this.realMetadataCollection = realLocalConnector.getMetadataCollection();
+ this.repositoryEventMapper = repositoryEventMapper;
+ this.outboundRepositoryEventManager = outboundRepositoryEventManager;
+
+ /*
+ * Incoming events are processed directly with real local connector to avoid the outbound event
+ * propagation managed by LocalOMRSMetadataCollection.
+ */
+ this.localTypeDefManager = localTypeDefManager;
+ if (localTypeDefManager != null)
+ {
+ localTypeDefManager.setupEventProcessor(this,
+ realLocalConnector,
+ saveExchangeRule,
+ outboundRepositoryEventManager);
+
+ }
+
+ this.incomingInstanceEventProcessor = new LocalOMRSInstanceEventProcessor(localMetadataCollectionId,
+ realLocalConnector,
+ localTypeDefManager,
+ saveExchangeRule);
+
+ /*
+ * The repositoryEventMapper is a plug-in component that handles repository events for
+ * repository that have additional APIs for managing metadata and need their own mechanism for
+ * sending OMRS Repository Events. If there is no repositoryEventMapper then the localOMRSMetadataCollection
+ * will send the outbound repository events.
+ */
+ if (repositoryEventMapper != null)
+ {
+ repositoryEventMapper.setRepositoryEventProcessor(outboundRepositoryEventManager);
+ }
+ else
+ {
+ /*
+ * When outboundRepositoryEventProcessor is not null then the local metadata collection creates events.
+ * Otherwise it assumes the event mapper will produce events.
+ */
+ this.outboundRepositoryEventProcessor = outboundRepositoryEventManager;
+ }
+ }
+
+
+ /**
+ * Free up any resources held since the connector is no longer needed.
+ *
+ * @throws ConnectorCheckedException - there is a problem disconnecting the connector.
+ */
+ public void disconnect() throws ConnectorCheckedException
+ {
+ if (realLocalConnector != null)
+ {
+ realLocalConnector.disconnect();
+ }
+ }
+
+
+ /*
+ * ==============================
+ * OMRSMetadataCollectionManager
+ */
+
+ /**
+ * Set up the unique Id for this metadata collection.
+ *
+ * @param metadataCollectionId - String unique Id
+ */
+ public void setMetadataCollectionId(String metadataCollectionId)
+ {
+ this.localMetadataCollectionId = metadataCollectionId;
+
+ /*
+ * Initialize the metadata collection only once the connector is properly set up.
+ */
+ metadataCollection = new LocalOMRSMetadataCollection(localMetadataCollectionId,
+ localServerName,
+ localServerType,
+ localOrganizationName,
+ realMetadataCollection,
+ outboundRepositoryEventProcessor,
+ localTypeDefManager);
+
+ }
+
+ /**
+ * Returns the metadata collection object that provides an OMRS abstraction of the metadata within
+ * a metadata repository.
+ *
+ * @return OMRSMetadataCollection - metadata information retrieved from the metadata repository.
+ */
+ public OMRSMetadataCollection getMetadataCollection()
+ {
+ if (metadataCollection == null)
+ {
+ // TODO Throw Error
+ }
+
+ return metadataCollection;
+ }
+
+ /*
+ * ====================================
+ * OMRSLocalRepository
+ */
+
+ /**
+ * Returns the unique identifier (guid) of the local repository's metadata collection.
+ *
+ * @return String guid
+ */
+ public String getMetadataCollectionId()
+ {
+ return localMetadataCollectionId;
+ }
+
+
+ /**
+ * Returns the Connection to the local repository that can be used by remote servers to create
+ * an OMRS repository connector to call this server in order to access the local repository.
+ *
+ * @return Connection object
+ */
+ public Connection getLocalRepositoryRemoteConnection()
+ {
+ return super.connection;
+ }
+
+
+ /**
+ * Return the TypeDefValidator. This is used to validate that a list of type definitions (TypeDefs) are
+ * compatible with the local repository.
+ *
+ * @return OMRSTypeDefValidator object for the local repository.
+ */
+ public OMRSTypeDefValidator getTypeDefValidator()
+ {
+ return localTypeDefManager;
+ }
+
+
+ /**
+ * Return the event manager that the local repository uses to distribute events from the local repository.
+ *
+ * @return outbound repository event manager
+ */
+ public OMRSRepositoryEventManager getOutboundRepositoryEventManager()
+ {
+ return outboundRepositoryEventManager;
+ }
+
+
+ /**
+ * Return the TypeDef event processor that should be passed all incoming TypeDef events received
+ * from the cohorts that this server is a member of.
+ *
+ * @return OMRSTypeDefEventProcessor for the local repository.
+ */
+ public OMRSTypeDefEventProcessor getIncomingTypeDefEventProcessor()
+ {
+ return localTypeDefManager;
+ }
+
+
+ /**
+ * Return the instance event processor that should be passed all incoming instance events received
+ * from the cohorts that this server is a member of.
+ *
+ * @return OMRSInstanceEventProcessor for the local repository.
+ */
+ public OMRSInstanceEventProcessor getIncomingInstanceEventProcessor()
+ {
+ return incomingInstanceEventProcessor;
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositoryconnector/OMRSInstanceRetrievalEventProcessor.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositoryconnector/OMRSInstanceRetrievalEventProcessor.java b/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositoryconnector/OMRSInstanceRetrievalEventProcessor.java
new file mode 100644
index 0000000..2518397
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositoryconnector/OMRSInstanceRetrievalEventProcessor.java
@@ -0,0 +1,78 @@
+/*
+ * 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.localrepository.repositoryconnector;
+
+import org.apache.atlas.omrs.metadatacollection.properties.instances.EntityDetail;
+import org.apache.atlas.omrs.metadatacollection.properties.instances.Relationship;
+
+import java.util.ArrayList;
+
+
+/**
+ * OMRSInstanceRetrievalEventProcessor defines the interface used by the Enterprise OMRS Repository Connector
+ * to pass instance metadata retrieved from remote open metadata repository connectors.
+ */
+public interface OMRSInstanceRetrievalEventProcessor
+{
+ /**
+ * Pass an entity that has been retrieved from a remote open metadata repository so it can be validated and
+ * (if the rules permit) cached in the local repository.
+ *
+ * @param metadataCollectionId - unique identifier for the metadata from the remote repository
+ * @param entity - the retrieved entity.
+ * @return Validated and processed entity.
+ */
+ EntityDetail processRetrievedEntity(String metadataCollectionId,
+ EntityDetail entity);
+
+
+ /**
+ * Pass a list of entities that have been retrieved from a remote open metadata repository so they can be
+ * validated and (if the rules permit) cached in the local repository.
+ *
+ * @param metadataCollectionId - unique identifier for the metadata from the remote repository
+ * @param entities - the retrieved relationships
+ * @return the validated and processed relationships
+ */
+ ArrayList<EntityDetail> processRetrievedEntities(String metadataCollectionId,
+ ArrayList<EntityDetail> entities);
+
+
+ /**
+ * Pass a relationship that has been retrieved from a remote open metadata repository so it can be validated and
+ * (if the rules permit) cached in the local repository.
+ *
+ * @param metadataCollectionId - unique identifier for the metadata from the remote repository
+ * @param relationship - the retrieved relationship
+ * @return the validated and processed relationship
+ */
+ Relationship processRetrievedRelationship(String metadataCollectionId,
+ Relationship relationship);
+
+
+ /**
+ * Pass a list of relationships that have been retrieved from a remote open metadata repository so they can be
+ * validated and (if the rules permit) cached in the local repository.
+ *
+ * @param metadataCollectionId - unique identifier for the metadata from the remote repository
+ * @param relationships - the list of retrieved relationships
+ * @return the validated and processed relationships
+ */
+ ArrayList<Relationship> processRetrievedRelationships(String metadataCollectionId,
+ ArrayList<Relationship> relationships);
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositorycontentmanager/OMRSInstanceHelper.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositorycontentmanager/OMRSInstanceHelper.java b/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositorycontentmanager/OMRSInstanceHelper.java
new file mode 100644
index 0000000..5478249
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositorycontentmanager/OMRSInstanceHelper.java
@@ -0,0 +1,149 @@
+/*
+ * 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.localrepository.repositorycontentmanager;
+
+
+import org.apache.atlas.omrs.ffdc.exception.TypeErrorException;
+import org.apache.atlas.omrs.metadatacollection.properties.instances.*;
+
+import java.util.ArrayList;
+
+
+/**
+ * OMRSInstanceHelper provides methods to help OMRS connectors and adapters ensure the content of
+ * entities and relationships match the type definitions recorded in the TypeDefs.
+ */
+public interface OMRSInstanceHelper
+{
+ /**
+ * Return an entity with the header and type information filled out. The caller only needs to add properties
+ * and classifications to complete the set up of the entity.
+ *
+ * @param sourceName - source of the request (used for logging)
+ * @param metadataCollectionId - unique identifier for the home metadata collection
+ * @param provenanceType - origin of the entity
+ * @param userName - name of the creator
+ * @param typeName - name of the type
+ * @return partially filled out entity - needs classifications and properties
+ * @throws TypeErrorException - the type name is not recognized.
+ */
+ EntityDetail getSkeletonEntity(String sourceName,
+ String metadataCollectionId,
+ InstanceProvenanceType provenanceType,
+ String userName,
+ String typeName) throws TypeErrorException;
+
+
+ /**
+ * Return a classification with the header and type information filled out. The caller only needs to add properties
+ * and possibility origin information if it is propagated to complete the set up of the classification.
+ *
+ * @param sourceName - source of the request (used for logging)
+ * @param userName - name of the creator
+ * @param classificationTypeName - name of the classification type
+ * @param entityTypeName - name of the type for the entity that this classification is to be attached to.
+ * @return partially filled out classification - needs properties and possibly origin information
+ * @throws TypeErrorException - the type name is not recognized as a classification type.
+ */
+ Classification getSkeletonClassification(String sourceName,
+ String userName,
+ String classificationTypeName,
+ String entityTypeName) throws TypeErrorException;
+
+
+ /**
+ * Return a relationship with the header and type information filled out. The caller only needs to add properties
+ * to complete the set up of the relationship.
+ *
+ * @param sourceName - source of the request (used for logging)
+ * @param metadataCollectionId - unique identifier for the home metadata collection
+ * @param provenanceType - origin type of the relationship
+ * @param userName - name of the creator
+ * @param typeName - name of the relationship's type
+ * @return partially filled out relationship - needs properties
+ * @throws TypeErrorException - the type name is not recognized as a relationship type.
+ */
+ Relationship getSkeletonRelationship(String sourceName,
+ String metadataCollectionId,
+ InstanceProvenanceType provenanceType,
+ String userName,
+ String typeName) throws TypeErrorException;
+
+
+ /**
+ * Return a filled out entity. It just needs to add the classifications.
+ *
+ * @param sourceName - source of the request (used for logging)
+ * @param metadataCollectionId - unique identifier for the home metadata collection
+ * @param provenanceType - origin of the entity
+ * @param userName - name of the creator
+ * @param typeName - name of the type
+ * @param properties - properties for the entity
+ * @param classifications - list of classifications for the entity
+ * @return an entity that is filled out
+ * @throws TypeErrorException - the type name is not recognized as an entity type
+ */
+ EntityDetail getNewEntity(String sourceName,
+ String metadataCollectionId,
+ InstanceProvenanceType provenanceType,
+ String userName,
+ String typeName,
+ InstanceProperties properties,
+ ArrayList<Classification> classifications) throws TypeErrorException;
+
+
+ /**
+ * Return a filled out relationship.
+ *
+ * @param sourceName - source of the request (used for logging)
+ * @param metadataCollectionId - unique identifier for the home metadata collection
+ * @param provenanceType - origin of the relationship
+ * @param userName - name of the creator
+ * @param typeName - name of the type
+ * @param properties - properties for the relationship
+ * @return a relationship that is filled out
+ * @throws TypeErrorException - the type name is not recognized as a relationship type
+ */
+ Relationship getNewRelationship(String sourceName,
+ String metadataCollectionId,
+ InstanceProvenanceType provenanceType,
+ String userName,
+ String typeName,
+ InstanceProperties properties) throws TypeErrorException;
+
+
+ /**
+ * Return a classification with the header and type information filled out. The caller only needs to add properties
+ * to complete the set up of the classification.
+ *
+ * @param sourceName - source of the request (used for logging)
+ * @param userName - name of the creator
+ * @param typeName - name of the type
+ * @param entityTypeName - name of the type for the entity that this classification is to be attached to.
+ * @param properties - properties for the classification
+ * @return partially filled out classification - needs properties and possibly origin information
+ * @throws TypeErrorException - the type name is not recognized as a classification type.
+ */
+ Classification getNewClassification(String sourceName,
+ String userName,
+ String typeName,
+ String entityTypeName,
+ ClassificationOrigin classificationOrigin,
+ String classificationOriginGUID,
+ InstanceProperties properties) throws TypeErrorException;
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositorycontentmanager/OMRSInstanceValidator.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositorycontentmanager/OMRSInstanceValidator.java b/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositorycontentmanager/OMRSInstanceValidator.java
new file mode 100644
index 0000000..02561ab
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositorycontentmanager/OMRSInstanceValidator.java
@@ -0,0 +1,69 @@
+/*
+ * 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.localrepository.repositorycontentmanager;
+
+import org.apache.atlas.omrs.metadatacollection.properties.instances.EntityDetail;
+import org.apache.atlas.omrs.metadatacollection.properties.instances.InstanceType;
+import org.apache.atlas.omrs.metadatacollection.properties.instances.Relationship;
+import org.apache.atlas.omrs.metadatacollection.properties.typedefs.TypeDef;
+import org.apache.atlas.omrs.metadatacollection.properties.typedefs.TypeDefCategory;
+
+
+/**
+ * OMRSInstanceValidator provides method to validate entities and relationships match their type definition
+ * (TypeDef).
+ */
+public interface OMRSInstanceValidator
+{
+ /**
+ * Test that the supplied entity is valid.
+ *
+ * @param sourceName - source of the entity (used for logging)
+ * @param entity - entity to test
+ * @return boolean result
+ */
+ boolean validEntity(String sourceName,
+ EntityDetail entity);
+
+
+ /**
+ * Test that the supplied relationship is valid.
+ *
+ * @param sourceName - source of the relationship (used for logging)
+ * @param relationship - relationship to test
+ * @return boolean result
+ */
+ boolean validRelationship(String sourceName,
+ Relationship relationship);
+
+ /**
+ * Verify that the identifiers for an instance are correct.
+ *
+ * @param sourceName - source of the instance (used for logging)
+ * @param typeDefGUID - unique identifier for the type.
+ * @param typeDefName - unique name for the type.
+ * @param category - expected category of the instance.
+ * @param instanceGUID - unique identifier for the instance.
+ * @return boolean indicating whether the identifiers are ok.
+ */
+ boolean validInstanceId(String sourceName,
+ String typeDefGUID,
+ String typeDefName,
+ TypeDefCategory category,
+ String instanceGUID);
+}
[12/30] atlas git commit: ATLAS-2246: OMRS Connector API plus REST
and IGC Connector skeleton - 15th February 2018
Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositoryconnector/LocalOMRSMetadataCollection.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositoryconnector/LocalOMRSMetadataCollection.java b/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositoryconnector/LocalOMRSMetadataCollection.java
new file mode 100644
index 0000000..a46c28e
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositoryconnector/LocalOMRSMetadataCollection.java
@@ -0,0 +1,3157 @@
+/*
+ * 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.localrepository.repositoryconnector;
+
+import org.apache.atlas.omrs.eventmanagement.OMRSRepositoryEventProcessor;
+import org.apache.atlas.omrs.ffdc.*;
+import org.apache.atlas.omrs.ffdc.exception.*;
+import org.apache.atlas.omrs.localrepository.repositorycontentmanager.OMRSRepositoryContentManager;
+import org.apache.atlas.omrs.metadatacollection.OMRSMetadataCollection;
+import org.apache.atlas.omrs.metadatacollection.properties.MatchCriteria;
+import org.apache.atlas.omrs.metadatacollection.properties.SequencingOrder;
+import org.apache.atlas.omrs.metadatacollection.properties.instances.*;
+import org.apache.atlas.omrs.metadatacollection.properties.typedefs.*;
+
+import java.util.ArrayList;
+import java.util.Date;
+
+/**
+ * LocalOMRSMetadataCollection provides a wrapper around the metadata collection for the real local repository.
+ * Its role is to manage outbound repository events and audit logging/debug for the real local repository.
+ */
+public class LocalOMRSMetadataCollection extends OMRSMetadataCollection
+{
+ private static final String sourceName = "Local Repository";
+
+ private OMRSMetadataCollection realMetadataCollection = null;
+ private String localServerName = null;
+ private String localServerType = null;
+ private String localOrganizationName = null;
+ private OMRSRepositoryEventProcessor outboundRepositoryEventProcessor = null;
+ private OMRSRepositoryContentManager localRepositoryContentManager = null;
+
+
+ /**
+ * Constructor used by LocalOMRSRepositoryConnector
+ *
+ * @param localMetadataConnectionId - unique identifier for the local metadata collection.
+ * @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 realMetadataCollection - metadata collection of the rela local connector.
+ * @param outboundRepositoryEventProcessor - outbound event processor
+ * (may be null if a repository event mapper is deployed).
+ * @param repositoryContentManager - manager of in-memory cache of type definitions (TypeDefs).
+ */
+ LocalOMRSMetadataCollection(String localMetadataConnectionId,
+ String localServerName,
+ String localServerType,
+ String localOrganizationName,
+ OMRSMetadataCollection realMetadataCollection,
+ OMRSRepositoryEventProcessor outboundRepositoryEventProcessor,
+ OMRSRepositoryContentManager repositoryContentManager)
+ {
+ /*
+ * The super class manages the local metadata collection id. This is a locally managed value.
+ */
+ super(localMetadataConnectionId);
+
+ /*
+ * Save the metadata collection object for the real repository. This is the metadata that does all of the
+ * work. LocalOMRSMetadataCollection is just a wrapper for managing repository events and debug and
+ * audit logging.
+ */
+ if (realMetadataCollection == null)
+ {
+ String actionDescription = "Local OMRS Metadata Collection Constructor";
+
+ OMRSErrorCode errorCode = OMRSErrorCode.NULL_LOCAL_METADATA_COLLECTION;
+ String errorMessage = errorCode.getErrorMessageId()
+ + errorCode.getFormattedErrorMessage();
+
+ throw new OMRSLogicErrorException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ actionDescription,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+ this.realMetadataCollection = realMetadataCollection;
+
+ /*
+ * Save the information needed to send repository events.
+ */
+ this.localServerName = localServerName;
+ this.localServerType = localServerType;
+ this.localOrganizationName = localOrganizationName;
+ this.outboundRepositoryEventProcessor = outboundRepositoryEventProcessor;
+ this.localRepositoryContentManager = repositoryContentManager;
+ }
+
+
+ /* ==============================
+ * Group 2: Working with typedefs
+ */
+
+
+ /**
+ * Returns the list of different types of metadata organized into two groups. The first are the
+ * attribute type definitions (AttributeTypeDefs). These provide types for properties in full
+ * type definitions. Full type definitions (TypeDefs) describe types for entities, relationships
+ * and classifications.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @return TypeDefs - Lists of different categories of TypeDefs.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public TypeDefGallery getAllTypes(String userId) throws RepositoryErrorException,
+ UserNotAuthorizedException
+ {
+ return realMetadataCollection.getAllTypes(userId);
+ }
+
+
+ /**
+ * Returns a list of TypeDefs that have the specified name. TypeDef names should be unique. This
+ * method allows wildcard character to be included in the name. These are * (asterisk) for an arbitrary string of
+ * characters and ampersand for an arbitrary character.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param name - name of the TypeDefs to return (including wildcard characters).
+ * @return TypeDefs list.
+ * @throws InvalidParameterException - the name of the TypeDef is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public TypeDefGallery findTypesByName(String userId,
+ String name) throws InvalidParameterException,
+ RepositoryErrorException,
+ UserNotAuthorizedException
+ {
+ return realMetadataCollection.findTypesByName(userId, name);
+ }
+
+
+ /**
+ * Returns all of the TypeDefs for a specific category.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param category - enum value for the category of TypeDef to return.
+ * @return TypeDefs list.
+ * @throws InvalidParameterException - the TypeDefCategory is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public ArrayList<TypeDef> findTypeDefsByCategory(String userId,
+ TypeDefCategory category) throws InvalidParameterException,
+ RepositoryErrorException,
+ UserNotAuthorizedException
+ {
+ return realMetadataCollection.findTypeDefsByCategory(userId, category);
+ }
+
+
+ /**
+ * Returns all of the AttributeTypeDefs for a specific category.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param category - enum value for the category of an AttributeTypeDef to return.
+ * @return TypeDefs list.
+ * @throws InvalidParameterException - the TypeDefCategory is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public ArrayList<AttributeTypeDef> findAttributeTypeDefsByCategory(String userId,
+ AttributeTypeDefCategory category) throws InvalidParameterException,
+ RepositoryErrorException,
+ UserNotAuthorizedException
+ {
+ return realMetadataCollection.findAttributeTypeDefsByCategory(userId, category);
+ }
+
+
+
+ /**
+ * Return the TypeDefs that have the properties matching the supplied match criteria.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param matchCriteria - TypeDefProperties - a list of property names and values.
+ * @return TypeDefs list.
+ * @throws InvalidParameterException - the matchCriteria is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public ArrayList<TypeDef> findTypeDefsByProperty(String userId,
+ TypeDefProperties matchCriteria) throws InvalidParameterException,
+ RepositoryErrorException,
+ UserNotAuthorizedException
+ {
+ return realMetadataCollection.findTypeDefsByProperty(userId, matchCriteria);
+ }
+
+
+ /**
+ * Return the types that are linked to the elements from the specified standard.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param standard - name of the standard - null means any.
+ * @param organization - name of the organization - null means any.
+ * @param identifier - identifier of the element in the standard - null means any.
+ * @return TypeDefs list - each entry in the list contains a typedef. This is is a structure
+ * describing the TypeDef's category and properties.
+ * @throws InvalidParameterException - all attributes of the external id are null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public TypeDefGallery findTypesByExternalID(String userId,
+ String standard,
+ String organization,
+ String identifier) throws InvalidParameterException,
+ RepositoryErrorException,
+ UserNotAuthorizedException
+ {
+ return realMetadataCollection.findTypesByExternalID(userId, standard, organization, identifier);
+ }
+
+ /**
+ * Return the TypeDefs that match the search criteria.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param searchCriteria - String - search criteria.
+ * @return TypeDefs list - each entry in the list contains a typedef. This is is a structure
+ * describing the TypeDef's category and properties.
+ * @throws InvalidParameterException - the searchCriteria is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public ArrayList<TypeDef> searchForTypeDefs(String userId,
+ String searchCriteria) throws InvalidParameterException,
+ RepositoryErrorException,
+ UserNotAuthorizedException
+ {
+ return realMetadataCollection.searchForTypeDefs(userId, searchCriteria);
+ }
+
+
+ /**
+ * Return the TypeDef identified by the GUID.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param guid - String unique id of the TypeDef
+ * @return TypeDef structure describing its category and properties.
+ * @throws InvalidParameterException - the guid is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws TypeDefNotKnownException - The requested TypeDef is not known in the metadata collection.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public TypeDef getTypeDefByGUID(String userId,
+ String guid) throws InvalidParameterException,
+ RepositoryErrorException,
+ TypeDefNotKnownException,
+ UserNotAuthorizedException
+ {
+ return realMetadataCollection.getTypeDefByGUID(userId, guid);
+ }
+
+
+ /**
+ * Return the AttributeTypeDef identified by the GUID.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param guid - String unique id of the TypeDef
+ * @return TypeDef structure describing its category and properties.
+ * @throws InvalidParameterException - the guid is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws TypeDefNotKnownException - The requested TypeDef is not known in the metadata collection.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public AttributeTypeDef getAttributeTypeDefByGUID(String userId,
+ String guid) throws InvalidParameterException,
+ RepositoryErrorException,
+ TypeDefNotKnownException,
+ UserNotAuthorizedException
+ {
+ return realMetadataCollection.getAttributeTypeDefByGUID(userId, guid);
+ }
+
+
+ /**
+ * Return the TypeDef identified by the unique name.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param name - String name of the TypeDef.
+ * @return TypeDef structure describing its category and properties.
+ * @throws InvalidParameterException - the name is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws TypeDefNotKnownException - the requested TypeDef is not found in the metadata collection.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public TypeDef getTypeDefByName(String userId,
+ String name) throws InvalidParameterException,
+ RepositoryErrorException,
+ TypeDefNotKnownException,
+ UserNotAuthorizedException
+ {
+ return realMetadataCollection.getTypeDefByName(userId, name);
+ }
+
+
+ /**
+ * Return the AttributeTypeDef identified by the unique name.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param name - String name of the TypeDef.
+ * @return TypeDef structure describing its category and properties.
+ * @throws InvalidParameterException - the name is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws TypeDefNotKnownException - the requested TypeDef is not found in the metadata collection.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public AttributeTypeDef getAttributeTypeDefByName(String userId,
+ String name) throws InvalidParameterException,
+ RepositoryErrorException,
+ TypeDefNotKnownException,
+ UserNotAuthorizedException
+ {
+ return realMetadataCollection.getAttributeTypeDefByName(userId, name);
+ }
+
+
+ /**
+ * Create a collection of related types.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param newTypes - TypeDefGallery structure describing the new AttributeTypeDefs and TypeDefs.
+ * @throws InvalidParameterException - the new TypeDef is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws TypeDefNotSupportedException - the repository is not able to support this TypeDef.
+ * @throws TypeDefKnownException - the TypeDef is already stored in the repository.
+ * @throws TypeDefConflictException - the new TypeDef conflicts with an existing TypeDef.
+ * @throws InvalidTypeDefException - the new TypeDef has invalid contents.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public void addTypeDefGallery(String userId,
+ TypeDefGallery newTypes) throws InvalidParameterException,
+ RepositoryErrorException,
+ TypeDefNotSupportedException,
+ TypeDefKnownException,
+ TypeDefConflictException,
+ InvalidTypeDefException,
+ UserNotAuthorizedException
+ {
+
+ }
+
+
+ /**
+ * Create a definition of a new TypeDef.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param newTypeDef - TypeDef structure describing the new TypeDef.
+ * @throws InvalidParameterException - the new TypeDef is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws TypeDefNotSupportedException - the repository is not able to support this TypeDef.
+ * @throws TypeDefKnownException - the TypeDef is already stored in the repository.
+ * @throws TypeDefConflictException - the new TypeDef conflicts with an existing TypeDef.
+ * @throws InvalidTypeDefException - the new TypeDef has invalid contents.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public void addTypeDef(String userId,
+ TypeDef newTypeDef) throws InvalidParameterException,
+ RepositoryErrorException,
+ TypeDefNotSupportedException,
+ TypeDefKnownException,
+ TypeDefConflictException,
+ InvalidTypeDefException,
+ UserNotAuthorizedException
+ {
+ realMetadataCollection.addTypeDef(userId, newTypeDef);
+
+ if (localRepositoryContentManager != null)
+ {
+ localRepositoryContentManager.addTypeDef(sourceName, newTypeDef);
+ }
+
+ if (outboundRepositoryEventProcessor != null)
+ {
+ outboundRepositoryEventProcessor.processNewTypeDefEvent(sourceName,
+ metadataCollectionId,
+ localServerName,
+ localServerType,
+ localOrganizationName,
+ newTypeDef);
+ }
+ }
+
+ /**
+ * Create a definition of a new AttributeTypeDef.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param newAttributeTypeDef - TypeDef structure describing the new TypeDef.
+ * @throws InvalidParameterException - the new TypeDef is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws TypeDefNotSupportedException - the repository is not able to support this TypeDef.
+ * @throws TypeDefKnownException - the TypeDef is already stored in the repository.
+ * @throws TypeDefConflictException - the new TypeDef conflicts with an existing TypeDef.
+ * @throws InvalidTypeDefException - the new TypeDef has invalid contents.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public void addAttributeTypeDef(String userId,
+ AttributeTypeDef newAttributeTypeDef) throws InvalidParameterException,
+ RepositoryErrorException,
+ TypeDefNotSupportedException,
+ TypeDefKnownException,
+ TypeDefConflictException,
+ InvalidTypeDefException,
+ UserNotAuthorizedException
+ {
+ realMetadataCollection.addAttributeTypeDef(userId, newAttributeTypeDef);
+
+ if (localRepositoryContentManager != null)
+ {
+ localRepositoryContentManager.addAttributeTypeDef(sourceName, newAttributeTypeDef);
+ }
+
+ if (outboundRepositoryEventProcessor != null)
+ {
+ outboundRepositoryEventProcessor.processNewAttributeTypeDefEvent(sourceName,
+ metadataCollectionId,
+ localServerName,
+ localServerType,
+ localOrganizationName,
+ newAttributeTypeDef);
+ }
+ }
+
+
+ /**
+ * Verify that a definition of a TypeDef is either new - or matches the definition already stored.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param typeDef - TypeDef structure describing the TypeDef to test.
+ * @return boolean - true means the TypeDef matches the local definition - false means the TypeDef is not known.
+ * @throws InvalidParameterException - the TypeDef is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws TypeDefNotSupportedException - the repository is not able to support this TypeDef.
+ * @throws TypeDefConflictException - the new TypeDef conflicts with an existing TypeDef.
+ * @throws InvalidTypeDefException - the new TypeDef has invalid contents.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public boolean verifyTypeDef(String userId,
+ TypeDef typeDef) throws InvalidParameterException,
+ RepositoryErrorException,
+ TypeDefNotSupportedException,
+ TypeDefConflictException,
+ InvalidTypeDefException,
+ UserNotAuthorizedException
+ {
+ return realMetadataCollection.verifyTypeDef(userId, typeDef);
+ }
+
+
+ /**
+ * Verify that a definition of an AttributeTypeDef is either new - or matches the definition already stored.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param attributeTypeDef - TypeDef structure describing the TypeDef to test.
+ * @return boolean - true means the TypeDef matches the local definition - false means the TypeDef is not known.
+ * @throws InvalidParameterException - the TypeDef is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws TypeDefNotSupportedException - the repository is not able to support this TypeDef.
+ * @throws TypeDefConflictException - the new TypeDef conflicts with an existing TypeDef.
+ * @throws InvalidTypeDefException - the new TypeDef has invalid contents.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public boolean verifyAttributeTypeDef(String userId,
+ AttributeTypeDef attributeTypeDef) throws InvalidParameterException,
+ RepositoryErrorException,
+ TypeDefNotSupportedException,
+ TypeDefConflictException,
+ InvalidTypeDefException,
+ UserNotAuthorizedException
+ {
+ return realMetadataCollection.verifyAttributeTypeDef(userId, attributeTypeDef);
+ }
+
+
+ /**
+ * Update one or more properties of the TypeDef. The TypeDefPatch controls what types of updates
+ * are safe to make to the TypeDef.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param typeDefPatch - TypeDef patch describing change to TypeDef.
+ * @return updated TypeDef
+ * @throws InvalidParameterException - the TypeDefPatch is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws TypeDefNotKnownException - the requested TypeDef is not found in the metadata collection.
+ * @throws PatchErrorException - the TypeDef can not be updated because the supplied patch is incompatible
+ * with the stored TypeDef.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public TypeDef updateTypeDef(String userId,
+ TypeDefPatch typeDefPatch) throws InvalidParameterException,
+ RepositoryErrorException,
+ TypeDefNotKnownException,
+ PatchErrorException,
+ UserNotAuthorizedException
+ {
+ TypeDef updatedTypeDef = realMetadataCollection.updateTypeDef(userId, typeDefPatch);
+
+ if (localRepositoryContentManager != null)
+ {
+ localRepositoryContentManager.updateTypeDef(sourceName, updatedTypeDef);
+ }
+
+ if (outboundRepositoryEventProcessor != null)
+ {
+ outboundRepositoryEventProcessor.processUpdatedTypeDefEvent(sourceName,
+ metadataCollectionId,
+ localServerName,
+ localServerType,
+ localOrganizationName,
+ typeDefPatch);
+ }
+
+ return updatedTypeDef;
+ }
+
+
+ /**
+ * Delete the TypeDef. This is only possible if the TypeDef has never been used to create instances or any
+ * instances of this TypeDef have been purged from the metadata collection.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param obsoleteTypeDefGUID - String unique identifier for the TypeDef.
+ * @param obsoleteTypeDefName - String unique name for the TypeDef.
+ * @throws InvalidParameterException - the one of TypeDef identifiers is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws TypeDefNotKnownException - the requested TypeDef is not found in the metadata collection.
+ * @throws TypeDefInUseException - the TypeDef can not be deleted because there are instances of this type in the
+ * the metadata collection. These instances need to be purged before the
+ * TypeDef can be deleted.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public void deleteTypeDef(String userId,
+ String obsoleteTypeDefGUID,
+ String obsoleteTypeDefName) throws InvalidParameterException,
+ RepositoryErrorException,
+ TypeDefNotKnownException,
+ TypeDefInUseException,
+ UserNotAuthorizedException
+ {
+ if ((obsoleteTypeDefGUID == null) || (obsoleteTypeDefName == null))
+ {
+ // TODO Throw InvalidParameterException
+ }
+
+ realMetadataCollection.deleteTypeDef(userId,
+ obsoleteTypeDefGUID,
+ obsoleteTypeDefName);
+
+ if (localRepositoryContentManager != null)
+ {
+ localRepositoryContentManager.deleteTypeDef(sourceName,
+ obsoleteTypeDefGUID,
+ obsoleteTypeDefName);
+ }
+
+ if (outboundRepositoryEventProcessor != null)
+ {
+ outboundRepositoryEventProcessor.processDeletedTypeDefEvent(sourceName,
+ metadataCollectionId,
+ localServerName,
+ localServerType,
+ localOrganizationName,
+ obsoleteTypeDefGUID,
+ obsoleteTypeDefName);
+ }
+ }
+
+
+ /**
+ * Delete an AttributeTypeDef. This is only possible if the AttributeTypeDef has never been used to create
+ * instances or any instances of this AttributeTypeDef have been purged from the metadata collection.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param obsoleteTypeDefGUID - String unique identifier for the AttributeTypeDef.
+ * @param obsoleteTypeDefName - String unique name for the AttributeTypeDef.
+ * @throws InvalidParameterException - the one of AttributeTypeDef identifiers is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws TypeDefNotKnownException - the requested AttributeTypeDef is not found in the metadata collection.
+ * @throws TypeDefInUseException - the AttributeTypeDef can not be deleted because there are instances of this type in the
+ * the metadata collection. These instances need to be purged before the
+ * AttributeTypeDef can be deleted.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public void deleteAttributeTypeDef(String userId,
+ String obsoleteTypeDefGUID,
+ String obsoleteTypeDefName) throws InvalidParameterException,
+ RepositoryErrorException,
+ TypeDefNotKnownException,
+ TypeDefInUseException,
+ UserNotAuthorizedException
+ {
+ if ((obsoleteTypeDefGUID == null) || (obsoleteTypeDefName == null))
+ {
+ // TODO Throw InvalidParameterException
+ }
+
+ realMetadataCollection.deleteAttributeTypeDef(userId,
+ obsoleteTypeDefGUID,
+ obsoleteTypeDefName);
+
+ if (localRepositoryContentManager != null)
+ {
+ localRepositoryContentManager.deleteAttributeTypeDef(sourceName,
+ obsoleteTypeDefGUID,
+ obsoleteTypeDefName);
+ }
+
+ if (outboundRepositoryEventProcessor != null)
+ {
+ outboundRepositoryEventProcessor.processDeletedAttributeTypeDefEvent(sourceName,
+ metadataCollectionId,
+ localServerName,
+ localServerType,
+ localOrganizationName,
+ obsoleteTypeDefGUID,
+ obsoleteTypeDefName);
+ }
+ }
+
+
+ /**
+ * Change the guid or name of an existing TypeDef to a new value. This is used if two different
+ * TypeDefs are discovered to have the same guid. This is extremely unlikely but not impossible so
+ * the open metadata protocol has provision for this.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param originalTypeDefGUID - the original guid of the TypeDef.
+ * @param originalTypeDefName - the original name of the TypeDef.
+ * @param newTypeDefGUID - the new identifier for the TypeDef.
+ * @param newTypeDefName - new name for this TypeDef.
+ * @return typeDef - new values for this TypeDef, including the new guid/name.
+ * @throws InvalidParameterException - one of the parameters is invalid or null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws TypeDefNotKnownException - the TypeDef identified by the original guid/name is not found
+ * in the metadata collection.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public TypeDef reIdentifyTypeDef(String userId,
+ String originalTypeDefGUID,
+ String originalTypeDefName,
+ String newTypeDefGUID,
+ String newTypeDefName) throws InvalidParameterException,
+ RepositoryErrorException,
+ TypeDefNotKnownException,
+ UserNotAuthorizedException
+ {
+ if ((originalTypeDefGUID == null) || (originalTypeDefName == null) ||
+ (newTypeDefGUID == null) || (newTypeDefName == null))
+ {
+ // TODO Throw InvalidParameterException
+ }
+
+ TypeDef originalTypeDef = realMetadataCollection.getTypeDefByGUID(userId, originalTypeDefGUID);
+
+ TypeDef newTypeDef = realMetadataCollection.reIdentifyTypeDef(userId,
+ originalTypeDefGUID,
+ originalTypeDefName,
+ newTypeDefGUID,
+ newTypeDefName);
+
+ if (localRepositoryContentManager != null)
+ {
+ localRepositoryContentManager.reIdentifyTypeDef(sourceName,
+ originalTypeDefGUID,
+ originalTypeDefName,
+ newTypeDef);
+ }
+
+ if (outboundRepositoryEventProcessor != null)
+ {
+ outboundRepositoryEventProcessor.processReIdentifiedTypeDefEvent(sourceName,
+ metadataCollectionId,
+ localServerName,
+ localServerType,
+ localOrganizationName,
+ originalTypeDef,
+ newTypeDef);
+ }
+
+ return newTypeDef;
+ }
+
+
+ /**
+ * Change the guid or name of an existing TypeDef to a new value. This is used if two different
+ * TypeDefs are discovered to have the same guid. This is extremely unlikely but not impossible so
+ * the open metadata protocol has provision for this.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param originalAttributeTypeDefGUID - the original guid of the AttributeTypeDef.
+ * @param originalAttributeTypeDefName - the original name of the AttributeTypeDef.
+ * @param newAttributeTypeDefGUID - the new identifier for the AttributeTypeDef.
+ * @param newAttributeTypeDefName - new name for this AttributeTypeDef.
+ * @return attributeTypeDef - new values for this AttributeTypeDef, including the new guid/name.
+ * @throws InvalidParameterException - one of the parameters is invalid or null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws TypeDefNotKnownException - the AttributeTypeDef identified by the original guid/name is not
+ * found in the metadata collection.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public AttributeTypeDef reIdentifyAttributeTypeDef(String userId,
+ String originalAttributeTypeDefGUID,
+ String originalAttributeTypeDefName,
+ String newAttributeTypeDefGUID,
+ String newAttributeTypeDefName) throws InvalidParameterException,
+ RepositoryErrorException,
+ TypeDefNotKnownException,
+ UserNotAuthorizedException
+ {
+ if ((originalAttributeTypeDefGUID == null) || (originalAttributeTypeDefName == null) ||
+ (newAttributeTypeDefGUID == null) || (newAttributeTypeDefName == null))
+ {
+ // TODO Throw InvalidParameterException
+ }
+
+ AttributeTypeDef originalAttributeTypeDef = realMetadataCollection.getAttributeTypeDefByGUID(userId, originalAttributeTypeDefGUID);
+
+ AttributeTypeDef newAttributeTypeDef = realMetadataCollection.reIdentifyAttributeTypeDef(userId,
+ originalAttributeTypeDefGUID,
+ originalAttributeTypeDefName,
+ newAttributeTypeDefGUID,
+ newAttributeTypeDefName);
+
+ if (localRepositoryContentManager != null)
+ {
+ localRepositoryContentManager.reIdentifyAttributeTypeDef(sourceName,
+ originalAttributeTypeDefGUID,
+ originalAttributeTypeDefName,
+ newAttributeTypeDef);
+ }
+
+ if (outboundRepositoryEventProcessor != null)
+ {
+ outboundRepositoryEventProcessor.processReIdentifiedAttributeTypeDefEvent(sourceName,
+ metadataCollectionId,
+ localServerName,
+ localServerType,
+ localOrganizationName,
+ originalAttributeTypeDef,
+ newAttributeTypeDef);
+ }
+
+ return newAttributeTypeDef;
+ }
+
+
+
+ /* ===================================================
+ * Group 3: Locating entity and relationship instances
+ */
+
+
+ /**
+ * Returns a boolean indicating if the entity is stored in the metadata collection.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param guid - String unique identifier for the entity
+ * @return entity details if the entity is found in the metadata collection; otherwise return null
+ * @throws InvalidParameterException - the guid is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public EntityDetail isEntityKnown(String userId,
+ String guid) throws InvalidParameterException,
+ RepositoryErrorException,
+ UserNotAuthorizedException
+ {
+ EntityDetail entity = realMetadataCollection.isEntityKnown(userId, guid);
+
+ if (entity != null)
+ {
+ /*
+ * Ensure the provenance of the entity is correctly set. A repository may not support the storing of
+ * the metadata collection id in the repository (or uses null to mean "local"). When the entity
+ * detail is sent out, it must have its home metadata collection id set up. So LocalOMRSMetadataCollection
+ * fixes up the provenance.
+ */
+ if (entity.getMetadataCollectionId() == null)
+ {
+ entity.setMetadataCollectionId(metadataCollectionId);
+ entity.setInstanceProvenanceType(InstanceProvenanceType.LOCAL_COHORT);
+ }
+ }
+
+ return entity;
+ }
+
+
+ /**
+ * Return the header and classifications for a specific entity.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param guid - String unique identifier for the entity
+ * @return EntitySummary structure
+ * @throws InvalidParameterException - the guid is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws EntityNotKnownException - the requested entity instance is not known in the metadata collection.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public EntitySummary getEntitySummary(String userId,
+ String guid) throws InvalidParameterException,
+ RepositoryErrorException,
+ EntityNotKnownException,
+ UserNotAuthorizedException
+ {
+ EntitySummary entity = realMetadataCollection.getEntitySummary(userId, guid);
+
+ if (entity != null)
+ {
+ /*
+ * Ensure the provenance of the entity is correctly set. A repository may not support the storing of
+ * the metadata collection id in the repository (or uses null to mean "local"). When the entity
+ * detail is sent out, it must have its home metadata collection id set up. So LocalOMRSMetadataCollection
+ * fixes up the provenance.
+ */
+ if (entity.getMetadataCollectionId() == null)
+ {
+ entity.setMetadataCollectionId(metadataCollectionId);
+ entity.setInstanceProvenanceType(InstanceProvenanceType.LOCAL_COHORT);
+ }
+ }
+
+ return entity;
+ }
+
+
+ /**
+ * Return the header, classifications and properties of a specific entity.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param guid - String unique identifier for the entity.
+ * @return EntityDetail structure.
+ * @throws InvalidParameterException - the guid is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws EntityNotKnownException - the requested entity instance is not known in the metadata collection.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public EntityDetail getEntityDetail(String userId,
+ String guid) throws InvalidParameterException,
+ RepositoryErrorException,
+ EntityNotKnownException,
+ UserNotAuthorizedException
+ {
+ EntityDetail entity = realMetadataCollection.getEntityDetail(userId, guid);
+
+ if (entity != null)
+ {
+ /*
+ * Ensure the provenance of the entity is correctly set. A repository may not support the storing of
+ * the metadata collection id in the repository (or uses null to mean "local"). When the entity
+ * detail is sent out, it must have its home metadata collection id set up. So LocalOMRSMetadataCollection
+ * fixes up the provenance.
+ */
+ if (entity.getMetadataCollectionId() == null)
+ {
+ entity.setMetadataCollectionId(metadataCollectionId);
+ entity.setInstanceProvenanceType(InstanceProvenanceType.LOCAL_COHORT);
+ }
+ }
+
+ return entity;
+ }
+
+
+ /**
+ * Return a historical version of an entity - includes the header, classifications and properties of the entity.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param guid - String unique identifier for the entity.
+ * @param asOfTime - the time used to determine which version of the entity that is desired.
+ * @return EntityDetail structure.
+ * @throws InvalidParameterException - the guid or date is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws EntityNotKnownException - the requested entity instance is not known in the metadata collection
+ * at the time requested.
+ * @throws PropertyErrorException - the asOfTime property is for a future time
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public EntityDetail getEntityDetail(String userId,
+ String guid,
+ Date asOfTime) throws InvalidParameterException,
+ RepositoryErrorException,
+ EntityNotKnownException,
+ PropertyErrorException,
+ UserNotAuthorizedException
+ {
+ EntityDetail entity = realMetadataCollection.getEntityDetail(userId, guid, asOfTime);
+
+ if (entity != null)
+ {
+ /*
+ * Ensure the provenance of the entity is correctly set. A repository may not support the storing of
+ * the metadata collection id in the repository (or uses null to mean "local"). When the entity
+ * detail is sent out, it must have its home metadata collection id set up. So LocalOMRSMetadataCollection
+ * fixes up the provenance.
+ */
+ if (entity.getMetadataCollectionId() == null)
+ {
+ entity.setMetadataCollectionId(metadataCollectionId);
+ entity.setInstanceProvenanceType(InstanceProvenanceType.LOCAL_COHORT);
+ }
+ }
+
+ return entity;
+ }
+
+
+ /**
+ * Return the header, classifications, properties and relationships for a specific entity.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param guid - String unique identifier for the entity.
+ * @return EntityUniverse structure.
+ * @throws InvalidParameterException - the guid is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws EntityNotKnownException - the requested entity instance is not known in the metadata collection.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public EntityUniverse getEntityUniverse(String userId,
+ String guid) throws InvalidParameterException,
+ RepositoryErrorException,
+ EntityNotKnownException,
+ UserNotAuthorizedException
+ {
+ EntityUniverse entity = realMetadataCollection.getEntityUniverse(userId, guid);
+
+ if (entity != null)
+ {
+ /*
+ * Ensure the provenance of the entity is correctly set. A repository may not support the storing of
+ * the metadata collection id in the repository (or uses null to mean "local"). When the entity
+ * detail is sent out, it must have its home metadata collection id set up. So LocalOMRSMetadataCollection
+ * fixes up the provenance.
+ */
+ if (entity.getMetadataCollectionId() == null)
+ {
+ entity.setMetadataCollectionId(metadataCollectionId);
+ entity.setInstanceProvenanceType(InstanceProvenanceType.LOCAL_COHORT);
+ }
+ }
+
+ return entity;
+ }
+
+
+ /**
+ * Return the relationships for a specific entity.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param entityGUID - String unique identifier for the entity.
+ * @param fromRelationshipElement - the starting element number of the relationships to return.
+ * This is used when retrieving elements
+ * beyond the first page of results. Zero means start from the first element.
+ * @param limitResultsByStatus - By default, relationships in all statuses are returned. However, it is possible
+ * to specify a list of statuses (eg ACTIVE) to restrict the results to. Null means all
+ * status values.
+ * @param asOfTime - Requests a historical query of the relationships for the entity. Null means return the
+ * present values.
+ * @param sequencingProperty - String name of the property that is to be used to sequence the results.
+ * Null means do not sequence on a property name (see SequencingOrder).
+ * @param sequencingOrder - Enum defining how the results should be ordered.
+ * @param pageSize -- the maximum number of result classifications that can be returned on this request. Zero means
+ * unrestricted return results size.
+ * @return Relationships list. Null means no relationships associated with the entity.
+ * @throws InvalidParameterException - a parameter is invalid or null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws EntityNotKnownException - the requested entity instance is not known in the metadata collection.
+ * @throws PropertyErrorException - the sequencing property is not valid for the attached classifications.
+ * @throws PagingErrorException - the paging/sequencing parameters are set up incorrectly.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public ArrayList<Relationship> getRelationshipsForEntity(String userId,
+ String entityGUID,
+ int fromRelationshipElement,
+ ArrayList<InstanceStatus> limitResultsByStatus,
+ Date asOfTime,
+ String sequencingProperty,
+ SequencingOrder sequencingOrder,
+ int pageSize) throws InvalidParameterException,
+ RepositoryErrorException,
+ EntityNotKnownException,
+ PropertyErrorException,
+ PagingErrorException,
+ UserNotAuthorizedException
+ {
+ return realMetadataCollection.getRelationshipsForEntity(userId,
+ entityGUID,
+ fromRelationshipElement,
+ limitResultsByStatus,
+ asOfTime,
+ sequencingProperty,
+ sequencingOrder,
+ pageSize);
+ }
+
+
+ /**
+ * Return a list of entities that match the supplied properties according to the match criteria. The results
+ * can be returned over many pages.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param entityTypeGUID - String unique identifier for the entity type of interest (null means any entity type).
+ * @param matchProperties - List of entity properties to match to (null means match on entityTypeGUID only).
+ * @param matchCriteria - Enum defining how the properties should be matched to the entities in the repository.
+ * @param fromEntityDetailElement - the starting element number of the entities to return.
+ * This is used when retrieving elements
+ * beyond the first page of results. Zero means start from the first element.
+ * @param limitResultsByStatus - By default, entities in all statuses are returned. However, it is possible
+ * to specify a list of statuses (eg ACTIVE) to restrict the results to. Null means all
+ * status values.
+ * @param limitResultsByClassification - List of classifications that must be present on all returned entities.
+ * @param asOfTime - Requests a historical query of the entity. Null means return the present values.
+ * @param sequencingProperty - String name of the entity property that is to be used to sequence the results.
+ * Null means do not sequence on a property name (see SequencingOrder).
+ * @param sequencingOrder - Enum defining how the results should be ordered.
+ * @param pageSize - the maximum number of result entities that can be returned on this request. Zero means
+ * unrestricted return results size.
+ * @return a list of entities matching the supplied criteria - null means no matching entities in the metadata
+ * collection.
+ * @throws InvalidParameterException - a parameter is invalid or null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws TypeErrorException - the type guid passed on the request is not known by the
+ * metadata collection.
+ * @throws PropertyErrorException - the properties specified are not valid for any of the requested types of
+ * entity.
+ * @throws PagingErrorException - the paging/sequencing parameters are set up incorrectly.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public ArrayList<EntityDetail> findEntitiesByProperty(String userId,
+ String entityTypeGUID,
+ InstanceProperties matchProperties,
+ MatchCriteria matchCriteria,
+ int fromEntityDetailElement,
+ ArrayList<InstanceStatus> limitResultsByStatus,
+ ArrayList<String> limitResultsByClassification,
+ Date asOfTime,
+ String sequencingProperty,
+ SequencingOrder sequencingOrder,
+ int pageSize) throws InvalidParameterException,
+ RepositoryErrorException,
+ TypeErrorException,
+ PropertyErrorException,
+ PagingErrorException,
+ UserNotAuthorizedException
+ {
+ return realMetadataCollection.findEntitiesByProperty(userId,
+ entityTypeGUID,
+ matchProperties,
+ matchCriteria,
+ fromEntityDetailElement,
+ limitResultsByStatus,
+ limitResultsByClassification,
+ asOfTime,
+ sequencingProperty,
+ sequencingOrder,
+ pageSize);
+ }
+
+
+ /**
+ * Return a list of entities that have the requested type of classification attached.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param entityTypeGUID - unique identifier for the type of entity requested. Null mans any type of entity.
+ * @param classificationName - name of the classification - a null is not valid.
+ * @param matchClassificationProperties - list of classification properties used to narrow the search.
+ * @param matchCriteria - Enum defining how the properties should be matched to the classifications in the repository.
+ * @param fromEntityDetailElement - the starting element number of the entities to return.
+ * This is used when retrieving elements
+ * beyond the first page of results. Zero means start from the first element.
+ * @param limitResultsByStatus - By default, entities in all statuses are returned. However, it is possible
+ * to specify a list of statuses (eg ACTIVE) to restrict the results to. Null means all
+ * status values.
+ * @param asOfTime - Requests a historical query of the entity. Null means return the present values.
+ * @param sequencingProperty - String name of the entity property that is to be used to sequence the results.
+ * Null means do not sequence on a property name (see SequencingOrder).
+ * @param sequencingOrder - Enum defining how the results should be ordered.
+ * @param pageSize - the maximum number of result entities that can be returned on this request. Zero means
+ * unrestricted return results size.
+ * @return a list of entities matching the supplied criteria - null means no matching entities in the metadata
+ * collection.
+ * @throws InvalidParameterException - a parameter is invalid or null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws TypeErrorException - the type guid passed on the request is not known by the
+ * metadata collection.
+ * @throws ClassificationErrorException - the classification request is not known to the metadata collection.
+ * @throws PropertyErrorException - the properties specified are not valid for the requested type of
+ * classification.
+ * @throws PagingErrorException - the paging/sequencing parameters are set up incorrectly.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public ArrayList<EntityDetail> findEntitiesByClassification(String userId,
+ String entityTypeGUID,
+ String classificationName,
+ InstanceProperties matchClassificationProperties,
+ MatchCriteria matchCriteria,
+ ArrayList<InstanceStatus> limitResultsByStatus,
+ Date asOfTime,
+ String sequencingProperty,
+ SequencingOrder sequencingOrder,
+ int fromEntityDetailElement,
+ int pageSize) throws InvalidParameterException,
+ RepositoryErrorException,
+ TypeErrorException,
+ ClassificationErrorException,
+ PropertyErrorException,
+ PagingErrorException,
+ UserNotAuthorizedException
+ {
+ return realMetadataCollection.findEntitiesByClassification(userId,
+ entityTypeGUID,
+ classificationName,
+ matchClassificationProperties,
+ matchCriteria,
+ limitResultsByStatus,
+ asOfTime,
+ sequencingProperty,
+ sequencingOrder,
+ fromEntityDetailElement,
+ pageSize);
+ }
+
+
+ /**
+ * Return a list of entities matching the search criteria.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param searchCriteria - String expression of the characteristics of the required relationships.
+ * @param fromEntityDetailElement - the starting element number of the entities to return.
+ * This is used when retrieving elements
+ * beyond the first page of results. Zero means start from the first element.
+ * @param limitResultsByStatus - By default, entities in all statuses are returned. However, it is possible
+ * to specify a list of statuses (eg ACTIVE) to restrict the results to. Null means all
+ * status values.
+ * @param limitResultsByClassification - List of classifications that must be present on all returned entities.
+ * @param asOfTime - Requests a historical query of the entity. Null means return the present values.
+ * @param sequencingProperty - String name of the property that is to be used to sequence the results.
+ * Null means do not sequence on a property name (see SequencingOrder).
+ * @param sequencingOrder - Enum defining how the results should be ordered.
+ * @param pageSize - the maximum number of result entities that can be returned on this request. Zero means
+ * unrestricted return results size.
+ * @return a list of entities matching the supplied criteria - null means no matching entities in the metadata
+ * collection.
+ * @throws InvalidParameterException - a parameter is invalid or null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws PropertyErrorException - the sequencing property specified is not valid for any of the requested types of
+ * entity.
+ * @throws PagingErrorException - the paging/sequencing parameters are set up incorrectly.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public ArrayList<EntityDetail> searchForEntities(String userId,
+ String searchCriteria,
+ int fromEntityDetailElement,
+ ArrayList<InstanceStatus> limitResultsByStatus,
+ ArrayList<String> limitResultsByClassification,
+ Date asOfTime,
+ String sequencingProperty,
+ SequencingOrder sequencingOrder,
+ int pageSize) throws InvalidParameterException,
+ RepositoryErrorException,
+ PropertyErrorException,
+ PagingErrorException,
+ UserNotAuthorizedException
+ {
+ return realMetadataCollection.searchForEntities(userId,
+ searchCriteria,
+ fromEntityDetailElement,
+ limitResultsByStatus,
+ limitResultsByClassification,
+ asOfTime,
+ sequencingProperty,
+ sequencingOrder,
+ pageSize);
+ }
+
+
+ /**
+ * Returns a boolean indicating if the relationship is stored in the metadata collection.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param guid - String unique identifier for the relationship.
+ * @return relationship details if the relationship is found in the metadata collection; otherwise return null.
+ * @throws InvalidParameterException - the guid is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public Relationship isRelationshipKnown(String userId,
+ String guid) throws InvalidParameterException,
+ RepositoryErrorException,
+ UserNotAuthorizedException
+ {
+ return realMetadataCollection.isRelationshipKnown(userId, guid);
+ }
+
+
+ /**
+ * Return a requested relationship.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param guid - String unique identifier for the relationship.
+ * @return a relationship structure.
+ * @throws InvalidParameterException - the guid is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws RelationshipNotKnownException - the metadata collection does not have a relationship with
+ * the requested GUID stored.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public Relationship getRelationship(String userId,
+ String guid) throws InvalidParameterException,
+ RepositoryErrorException,
+ RelationshipNotKnownException,
+ UserNotAuthorizedException
+ {
+ return realMetadataCollection.getRelationship(userId, guid);
+ }
+
+
+ /**
+ * Return a historical version of a relationship.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param guid - String unique identifier for the relationship.
+ * @param asOfTime - the time used to determine which version of the entity that is desired.
+ * @return EntityDetail structure.
+ * @throws InvalidParameterException - the guid or date is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws RelationshipNotKnownException - the requested entity instance is not known in the metadata collection
+ * at the time requested.
+ * @throws PropertyErrorException - the asOfTime property is for a future time.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public Relationship getRelationship(String userId,
+ String guid,
+ Date asOfTime) throws InvalidParameterException,
+ RepositoryErrorException,
+ RelationshipNotKnownException,
+ PropertyErrorException,
+ UserNotAuthorizedException
+ {
+ return realMetadataCollection.getRelationship(userId, guid, asOfTime);
+ }
+
+
+ /**
+ * Return a list of relationships that match the requested properties by hte matching criteria. The results
+ * can be broken into pages.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param relationshipTypeGUID - unique identifier (guid) for the new relationship's type.
+ * @param matchProperties - list of properties used to narrow the search.
+ * @param matchCriteria - Enum defining how the properties should be matched to the relationships in the repository.
+ * @param fromEntityDetailElement - the starting element number of the entities to return.
+ * This is used when retrieving elements
+ * beyond the first page of results. Zero means start from the first element.
+ * @param limitResultsByStatus - By default, relationships in all statuses are returned. However, it is possible
+ * to specify a list of statuses (eg ACTIVE) to restrict the results to. Null means all
+ * status values.
+ * @param asOfTime - Requests a historical query of the relationships for the entity. Null means return the
+ * present values.
+ * @param sequencingProperty - String name of the property that is to be used to sequence the results.
+ * Null means do not sequence on a property name (see SequencingOrder).
+ * @param sequencingOrder - Enum defining how the results should be ordered.
+ * @param pageSize - the maximum number of result relationships that can be returned on this request. Zero means
+ * unrestricted return results size.
+ * @return a list of relationships. Null means no matching relationships.
+ * @throws InvalidParameterException - one of the parameters is invalid or null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws TypeErrorException - the type guid passed on the request is not known by the
+ * metadata collection.
+ * @throws PropertyErrorException - the properties specified are not valid for any of the requested types of
+ * relationships.
+ * @throws PagingErrorException - the paging/sequencing parameters are set up incorrectly.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public ArrayList<Relationship> findRelationshipsByProperty(String userId,
+ String relationshipTypeGUID,
+ InstanceProperties matchProperties,
+ MatchCriteria matchCriteria,
+ int fromEntityDetailElement,
+ ArrayList<InstanceStatus> limitResultsByStatus,
+ Date asOfTime,
+ String sequencingProperty,
+ SequencingOrder sequencingOrder,
+ int pageSize) throws InvalidParameterException,
+ RepositoryErrorException,
+ TypeErrorException,
+ PropertyErrorException,
+ PagingErrorException,
+ UserNotAuthorizedException
+ {
+ return realMetadataCollection.findRelationshipsByProperty(userId,
+ relationshipTypeGUID,
+ matchProperties,
+ matchCriteria,
+ fromEntityDetailElement,
+ limitResultsByStatus,
+ asOfTime,
+ sequencingProperty,
+ sequencingOrder,
+ pageSize);
+ }
+
+
+ /**
+ * Return a list of relationships that match the search criteria. The results can be paged.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param searchCriteria - String expression of the characteristics of the required relationships.
+ * @param fromRelationshipElement - Element number of the results to skip to when building the results list
+ * to return. Zero means begin at the start of the results. This is used
+ * to retrieve the results over a number of pages.
+ * @param limitResultsByStatus - By default, relationships in all statuses are returned. However, it is possible
+ * to specify a list of statuses (eg ACTIVE) to restrict the results to. Null means all
+ * status values.
+ * @param asOfTime - Requests a historical query of the relationships for the entity. Null means return the
+ * present values.
+ * @param sequencingProperty - String name of the property that is to be used to sequence the results.
+ * Null means do not sequence on a property name (see SequencingOrder).
+ * @param sequencingOrder - Enum defining how the results should be ordered.
+ * @param pageSize - the maximum number of result relationships that can be returned on this request. Zero means
+ * unrestricted return results size.
+ * @return a list of relationships. Null means no matching relationships.
+ * @throws InvalidParameterException - one of the parameters is invalid or null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws PropertyErrorException - there is a problem with one
<TRUNCATED>
[02/30] atlas git commit: ATLAS-2246: OMRS Connector API plus REST
and IGC Connector skeleton - 15th February 2018
Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/metadatahighway/cohortregistry/OMRSCohortRegistry.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/metadatahighway/cohortregistry/OMRSCohortRegistry.java b/omrs/src/main/java/org/apache/atlas/omrs/metadatahighway/cohortregistry/OMRSCohortRegistry.java
new file mode 100644
index 0000000..278ad10
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/metadatahighway/cohortregistry/OMRSCohortRegistry.java
@@ -0,0 +1,1097 @@
+/*
+ * 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.metadatahighway.cohortregistry;
+
+import org.apache.atlas.ocf.ffdc.OCFCheckedExceptionBase;
+import org.apache.atlas.ocf.properties.Connection;
+import org.apache.atlas.omrs.auditlog.OMRSAuditCode;
+import org.apache.atlas.omrs.auditlog.OMRSAuditLog;
+import org.apache.atlas.omrs.auditlog.OMRSAuditingComponent;
+import org.apache.atlas.omrs.eventmanagement.events.OMRSRegistryEventProcessor;
+import org.apache.atlas.omrs.metadatahighway.cohortregistry.store.OMRSCohortRegistryStore;
+import org.apache.atlas.omrs.metadatahighway.cohortregistry.store.properties.MemberRegistration;
+import org.apache.atlas.omrs.ffdc.exception.OMRSConfigErrorException;
+import org.apache.atlas.omrs.ffdc.exception.OMRSLogicErrorException;
+import org.apache.atlas.omrs.localrepository.repositorycontentmanager.OMRSTypeDefValidator;
+import org.apache.atlas.omrs.enterprise.connectormanager.OMRSConnectionConsumer;
+import org.apache.atlas.omrs.ffdc.OMRSErrorCode;
+import org.apache.atlas.omrs.ffdc.exception.OMRSRuntimeException;
+import org.apache.atlas.omrs.metadatacollection.properties.typedefs.TypeDefSummary;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.Date;
+
+
+/**
+ * OMRSCohortRegistry manages the local server's registration into a cohort and receives registration
+ * requests from other servers in the cohort. This management involves:
+ * <ul>
+ * <li>
+ * Sending and receiving registry events that contain registration information about the members
+ * of the cohort.
+ * </li>
+ * <li>
+ * Maintaining details of the local server's and other remote server's registration information
+ * in the cohort registry store to use for server restart.
+ * </li>
+ * <li>
+ * Interacting with the Local OMRS Connector and repository to verify that the type definitions
+ * (TypeDefs) used by other servers in the cohort are compatible with the local TypeDefs.
+ * </li>
+ * <li>
+ * Configuring the federation services (OMRS Federation Manager and Enterprise OMRS Connector) with
+ * information about the other servers in the cohort as they register and unregister from the
+ * cohort.
+ * </li>
+ * </ul>
+ * Within a server, there is a single instance of the cohort registry for each cohort that the server joins.
+ */
+public class OMRSCohortRegistry implements OMRSRegistryEventProcessor
+{
+ /*
+ * Local name of the cohort - used for messages rather than being part of the protocol.
+ */
+ private String cohortName = null;
+
+ /*
+ * These variables describe the local server's properties.
+ */
+ private String localMetadataCollectionId = null;
+ private Connection localRepositoryRemoteConnection = null;
+ private String localServerName = null;
+ private String localServerType = null;
+ private String localOrganizationName = null;
+
+ /*
+ * The registry store is used to save information about the members of the open metadata repository cohort.
+ */
+ private OMRSCohortRegistryStore registryStore = null;
+
+ /*
+ * The event publisher is used to send events to the rest of the open metadata repository cohort.
+ */
+ private OMRSRegistryEventProcessor outboundRegistryEventProcessor = null;
+
+ /*
+ * The connection consumer supports components such as the EnterpriseOMRSRepositoryConnector that need to maintain a
+ * list of remote partners that are part of the open metadata repository cohort.
+ */
+ private OMRSConnectionConsumer connectionConsumer = null;
+
+ /*
+ * The typeDef manager provides the cohort registry with details of the TypeDefs supported by the local
+ * and also validates the compatibility of TypeDefs from other members of the open metadata repository cohort.
+ */
+ private OMRSTypeDefValidator typeDefValidator = null;
+
+ /*
+ * The audit log provides a verifiable record of the membership of the open metadata repository cohort and the
+ * metadata exchange activity they are involved in. The Logger is for standard debug.
+ */
+ private static final OMRSAuditLog auditLog = new OMRSAuditLog(OMRSAuditingComponent.COHORT_REGISTRY);
+ private static final Logger log = LoggerFactory.getLogger(OMRSCohortRegistry.class);
+
+
+ /**
+ * Default constructor that relies on the initialization of variables in the declaration.
+ */
+ public OMRSCohortRegistry()
+ {
+ }
+
+
+ /**
+ * Validate that any metadata collection id previously used by the local server to register with the
+ * open metadata repository cohort matches the local metadata collection id passed in the configuration
+ * properties.
+ *
+ * @param configuredLocalMetadataCollectionId - configured value for the local metadata collection id - may be null
+ * if no local repository.
+ */
+ private void validateLocalMetadataCollectionId(String configuredLocalMetadataCollectionId)
+ {
+ String methodName = "validateLocalMetadataCollectionId()";
+
+ if (this.registryStore == null)
+ {
+ /*
+ * Throw exception as the cohort registry store is not available.
+ */
+ OMRSErrorCode errorCode = OMRSErrorCode.NULL_REGISTRY_STORE;
+ String errorMessage = errorCode.getErrorMessageId()
+ + errorCode.getFormattedErrorMessage(cohortName);
+
+ throw new OMRSLogicErrorException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ methodName,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+
+ MemberRegistration localRegistration = registryStore.retrieveLocalRegistration();
+
+ if (localRegistration != null)
+ {
+ String storedLocalMetadataCollectionId = localRegistration.getMetadataCollectionId();
+
+ if (storedLocalMetadataCollectionId != null)
+ {
+ /*
+ * There is a stored local metadata collection id which is going to be used. There is a consistency check
+ * to ensure this stored local Id is the same as the configured local metadata collection id.
+ *
+ * If it is not the same, the administrator has changed the configured value after the server
+ * registered with the cohort. The message on the audit log explains that the new value will be
+ * ignored until the local repository is un-registered with the old metadata collection id and then it
+ * can be registered with the new metadata collection Id.
+ */
+
+ if (!storedLocalMetadataCollectionId.equals(configuredLocalMetadataCollectionId))
+ {
+ if (configuredLocalMetadataCollectionId == null)
+ {
+ /*
+ * The change in the configuration is to remove the local repository. This means
+ * the local server should simply unregister from the cohort.
+ */
+ this.unRegisterLocalRepositoryWithCohort(localRegistration);
+ registryStore.removeLocalRegistration();
+
+ }
+ else
+ {
+ /*
+ * The configured value is different from the value used to register with this cohort.
+ * This is a situation that could potentially damage the metadata integrity across the cohort.
+ * Hence the exception.
+ */
+ OMRSErrorCode errorCode = OMRSErrorCode.INVALID_LOCAL_METADATA_COLLECTION_ID;
+ String errorMessage = errorCode.getErrorMessageId()
+ + errorCode.getFormattedErrorMessage(cohortName,
+ localServerName,
+ storedLocalMetadataCollectionId,
+ configuredLocalMetadataCollectionId);
+
+ throw new OMRSConfigErrorException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ methodName,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Initialize the cohort registry object. The parameters passed control its behavior.
+ *
+ * @param cohortName - the name of the cohort that this cohort registry is communicating with.
+ * @param localMetadataCollectionId - configured value for the local metadata collection id - may be null
+ * if no local repository.
+ * @param localRepositoryRemoteConnection - the connection properties for a connector that can call this
+ * server from a remote server.
+ * @param localServerName - the name of the local server. It is a descriptive name for informational purposes.
+ * @param localServerType - the type of the local server. It is a descriptive name for informational purposes.
+ * @param localOrganizationName - the name of the organization that owns the local server/repository.
+ * It is a descriptive name for informational purposes.
+ * @param registryEventProcessor - used to send outbound registry events to the cohort.
+ * @param cohortRegistryStore - the cohort registry store where details of members of the cohort are kept.
+ * @param typeDefValidator - TypeDef validator is used to validate typedefs across membership of the open
+ * metadata repository cohort. If it is null then no TypeDef validation occurs.
+ * @param connectionConsumer - The connection consumer is a component interested in maintaining details of the
+ * connections to each of the members of the open metadata repository cohort. If it is
+ * null, the cohort registry does not publish connections for members of the open
+ * metadata repository cohort.
+ */
+ public void initialize(String cohortName,
+ String localMetadataCollectionId,
+ Connection localRepositoryRemoteConnection,
+ String localServerName,
+ String localServerType,
+ String localOrganizationName,
+ OMRSRegistryEventProcessor registryEventProcessor,
+ OMRSCohortRegistryStore cohortRegistryStore,
+ OMRSTypeDefValidator typeDefValidator,
+ OMRSConnectionConsumer connectionConsumer)
+ {
+ String actionDescription = "Initialize cohort registry";
+
+ if (cohortRegistryStore == null)
+ {
+ OMRSErrorCode errorCode = OMRSErrorCode.NULL_REGISTRY_STORE;
+ String errorMessage = errorCode.getErrorMessageId()
+ + errorCode.getFormattedErrorMessage(cohortName);
+
+ throw new OMRSLogicErrorException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ actionDescription,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+ this.registryStore = cohortRegistryStore;
+
+ /*
+ * Save the cohort name for messages and the registry event processor for sending outbound events.
+ */
+ this.cohortName = cohortName;
+ this.outboundRegistryEventProcessor = registryEventProcessor;
+
+ /*
+ * Verify that the configured local metadata collection Id matches the one stored in the registry store.
+ * This will throw an exception if there are unresolvable differences.
+ */
+ this.validateLocalMetadataCollectionId(localMetadataCollectionId);
+
+ /*
+ * Save the TypeDef validator. This object is able to generate the list of TypeDef
+ * summaries supported by this repository and validate the TypeDef summaries received
+ * from the remote members of the open metadata repository cluster.
+ */
+ this.typeDefValidator = typeDefValidator;
+
+ /*
+ * Save the connection consumer. This component needs details of the current connections it should use
+ * to contact various members of the cluster (including the local server). It needs an initial
+ * upload of the members's connections and then ongoing notifications for any changes in the membership.
+ */
+ this.connectionConsumer = connectionConsumer;
+
+ /*
+ * Save the connections to the local repository. The localRepositoryRemoteConnection is used
+ * in the registration request that this repository sends out.
+ */
+ this.localRepositoryRemoteConnection = localRepositoryRemoteConnection;
+
+ /*
+ * Save information about the local server
+ */
+ this.localServerName = localServerName;
+ this.localServerType = localServerType;
+ this.localOrganizationName = localOrganizationName;
+ }
+
+
+ /**
+ * A new server needs to register the metadataCollectionId for its metadata repository with the other servers in the
+ * open metadata repository. It only needs to do this once and uses a timestamp to record that the registration
+ * event has been sent.
+ *
+ * If the server has already registered in the past, it does not need to take any action.
+ */
+ public void connectToCohort()
+ {
+ if (registryStore == null)
+ {
+ /*
+ * Throw exception as the cohort registry store is not available.
+ */
+ String methodName = "connectToCohort()";
+
+ OMRSErrorCode errorCode = OMRSErrorCode.NULL_REGISTRY_STORE;
+ String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage();
+
+ throw new OMRSRuntimeException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ methodName,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+
+
+ /*
+ * Extract member registration information from the cohort registry store. If there is
+ * no local registration, it means the local repository is not currently registered with the metadata
+ * repository cohort.
+ */
+ MemberRegistration localRegistration = registryStore.retrieveLocalRegistration();
+
+ if (localRegistration == null)
+ {
+ localRegistration = new MemberRegistration();
+ }
+
+
+ /*
+ * Fill in the local registration with details from the caller. Any value from the local repository
+ * can change except the localMetadataCollectionId and this value has already been validated.
+ */
+ localRegistration.setMetadataCollectionId(localMetadataCollectionId);
+ localRegistration.setServerName(localServerName);
+ localRegistration.setServerType(localServerType);
+ localRegistration.setOrganizationName(localOrganizationName);
+ localRegistration.setRepositoryConnection(localRepositoryRemoteConnection);
+
+ if (localMetadataCollectionId == null)
+ {
+ /*
+ * If the local metadata collection Id is null it means there is no local repository. No registration
+ * is required but the cohort registry sends a registration refresh request to ensure it has a complete
+ * list of the remote members for the connection consumer. The connection consumer will be null
+ * if enterprise access is disabled.
+ */
+ if (connectionConsumer != null)
+ {
+ this.requestReRegistrationFromCohort(localRegistration);
+ }
+ }
+ else if (localRegistration.getRegistrationTime() == null)
+ {
+ /*
+ * This repository has never registered with the open metadata repository cohort, so send registration
+ * request.
+ */
+ localRegistration.setRegistrationTime(new Date());
+
+ if (this.registerLocalRepositoryWithCohort(localRegistration))
+ {
+ /*
+ * Successfully registered so save the local registration to the registry store.
+ */
+ registryStore.saveLocalRegistration(localRegistration);
+ }
+ }
+ else
+ {
+ /*
+ * Successfully registered already - save the local registration to the registry store.
+ * in case some of the server details (name, type, organization name) have changed.
+ */
+ registryStore.saveLocalRegistration(localRegistration);
+
+ /*
+ * No registration is required but the cohort registry sends a registration refresh request to
+ * ensure it has a complete list of the remote members for the connection consumer.
+ * The connection consumer will be null if enterprise access is disabled.
+ */
+ if (connectionConsumer != null)
+ {
+ this.requestReRegistrationFromCohort(localRegistration);
+ }
+ }
+
+ /*
+ * Now read the remote registrations from the registry store and publish them to the connection consumer.
+ * The connection consumer will be null if enterprise access is disabled.
+ */
+ if (connectionConsumer != null)
+ {
+ /*
+ * Extract remote member registrations from the cohort registry store and register each one with the
+ * connection consumer.
+ */
+ ArrayList<MemberRegistration> remoteRegistrations = registryStore.retrieveRemoteRegistrations();
+
+ if (remoteRegistrations != null)
+ {
+ for (MemberRegistration remoteMember : remoteRegistrations)
+ {
+ if (remoteMember != null)
+ {
+ this.registerRemoteConnectionWithConsumer(remoteMember.getMetadataCollectionId(),
+ remoteMember.getServerName(),
+ remoteMember.getRepositoryConnection());
+ }
+ }
+ }
+ }
+ }
+
+
+ /**
+ * Close the connection to the registry store.
+ *
+ * @param permanent boolean flag indicating whether the disconnection is permanent or not. If it is set
+ * to true, the OMRS Cohort will remove all information about the cohort from the
+ * cohort registry store.
+ */
+ public void disconnectFromCohort(boolean permanent)
+ {
+ final String actionDescription = "Disconnect from Cohort";
+
+ if (registryStore != null)
+ {
+ if (permanent)
+ {
+ MemberRegistration localRegistration = registryStore.retrieveLocalRegistration();
+
+ OMRSAuditCode auditCode = OMRSAuditCode.COHORT_PERMANENTLY_DISCONNECTING;
+ auditLog.logRecord(actionDescription,
+ auditCode.getLogMessageId(),
+ auditCode.getSeverity(),
+ auditCode.getFormattedLogMessage(cohortName),
+ null,
+ auditCode.getSystemAction(),
+ auditCode.getUserAction());
+
+ if (localRegistration != null)
+ {
+ this.unRegisterLocalRepositoryWithCohort(localRegistration);
+ }
+
+ registryStore.clearAllRegistrations();
+
+ if (connectionConsumer != null)
+ {
+ connectionConsumer.removeCohort(cohortName);
+ }
+ }
+ else
+ {
+ OMRSAuditCode auditCode = OMRSAuditCode.COHORT_DISCONNECTING;
+ auditLog.logRecord(actionDescription,
+ auditCode.getLogMessageId(),
+ auditCode.getSeverity(),
+ auditCode.getFormattedLogMessage(cohortName),
+ null,
+ auditCode.getSystemAction(),
+ auditCode.getUserAction());
+ }
+
+ registryStore.close();
+ }
+ }
+
+
+ /**
+ * Send a registration event to the open metadata repository cohort. This means the
+ * server has never registered with the cohort before.
+ *
+ * @param localRegistration - details of the local server that are needed to build the event
+ * @return boolean indicating whether the repository registered successfully or not.
+ */
+ private boolean registerLocalRepositoryWithCohort(MemberRegistration localRegistration)
+ {
+ final String actionDescription = "Registering with cohort";
+
+ OMRSAuditCode auditCode = OMRSAuditCode.REGISTERED_WITH_COHORT;
+ auditLog.logRecord(actionDescription,
+ auditCode.getLogMessageId(),
+ auditCode.getSeverity(),
+ auditCode.getFormattedLogMessage(cohortName, localMetadataCollectionId),
+ null,
+ auditCode.getSystemAction(),
+ auditCode.getUserAction());
+
+ ArrayList<TypeDefSummary> typeDefSummaries = null;
+
+ if (typeDefValidator != null)
+ {
+ typeDefSummaries = typeDefValidator.getLocalTypeDefs();
+ }
+
+ return outboundRegistryEventProcessor.processRegistrationEvent(cohortName,
+ localRegistration.getMetadataCollectionId(),
+ localRegistration.getServerName(),
+ localRegistration.getServerType(),
+ localRegistration.getOrganizationName(),
+ localRegistration.getRegistrationTime(),
+ localRegistration.getRepositoryConnection(),
+ typeDefSummaries);
+ }
+
+
+ /**
+ * Request that the remote members of the cohort send details of their registration to enable the local
+ * server to ensure it has details of every member. There are two use cases. It may have missed a
+ * registration event from a remote member because it was not online for some time.
+ * Alternatively, it may not have a local repository and so can not trigger the reRegistration events
+ * with its own registration events.
+ *
+ * @param localRegistration - information needed to sent the refresh request
+ * @return boolean flag indicating whether it worked or not.
+ */
+ private boolean requestReRegistrationFromCohort(MemberRegistration localRegistration)
+ {
+ final String actionDescription = "Re-registering with cohort";
+
+ OMRSAuditCode auditCode = OMRSAuditCode.RE_REGISTERED_WITH_COHORT;
+ auditLog.logRecord(actionDescription,
+ auditCode.getLogMessageId(),
+ auditCode.getSeverity(),
+ auditCode.getFormattedLogMessage(cohortName),
+ null,
+ auditCode.getSystemAction(),
+ auditCode.getUserAction());
+
+ return outboundRegistryEventProcessor.processRegistrationRefreshRequest(cohortName,
+ localRegistration.getServerName(),
+ localRegistration.getServerType(),
+ localRegistration.getOrganizationName());
+ }
+
+
+ /**
+ * Unregister from the Cohort.
+ *
+ * @param localRegistration - details of the local registration
+ * @return boolean indicating whether the request was successful of not.
+ */
+ private boolean unRegisterLocalRepositoryWithCohort(MemberRegistration localRegistration)
+ {
+ final String actionDescription = "Unregistering from cohort";
+
+ OMRSAuditCode auditCode = OMRSAuditCode.UNREGISTERING_FROM_COHORT;
+ auditLog.logRecord(actionDescription,
+ auditCode.getLogMessageId(),
+ auditCode.getSeverity(),
+ auditCode.getFormattedLogMessage(cohortName, localMetadataCollectionId),
+ null,
+ auditCode.getSystemAction(),
+ auditCode.getUserAction());
+
+ return outboundRegistryEventProcessor.processUnRegistrationEvent(cohortName,
+ localRegistration.getMetadataCollectionId(),
+ localRegistration.getServerName(),
+ localRegistration.getServerType(),
+ localRegistration.getOrganizationName());
+ }
+
+
+ /**
+ * Register a new remote connection with the OMRSConnectionConsumer. If there is a problem with the
+ * remote connection, a bad connection registry event is sent to the remote repository.
+ *
+ * @param remoteMetadataCollectionId - id of the remote repository
+ * @param remoteServerName - name of the remote server.
+ * @param remoteRepositoryConnection - connection used to create a connector to call the remote repository.
+ */
+ private void registerRemoteConnectionWithConsumer(String remoteMetadataCollectionId,
+ String remoteServerName,
+ Connection remoteRepositoryConnection)
+ {
+ final String actionDescription = "Receiving registration request";
+ OMRSAuditCode auditCode = OMRSAuditCode.OUTGOING_BAD_CONNECTION;
+
+ if (connectionConsumer != null)
+ {
+ /*
+ * An exception is thrown if the remote connection is bad.
+ */
+ try
+ {
+ connectionConsumer.addRemoteConnection(cohortName,
+ remoteMetadataCollectionId,
+ remoteRepositoryConnection);
+ }
+ catch (OCFCheckedExceptionBase error)
+ {
+ auditLog.logRecord(actionDescription,
+ auditCode.getLogMessageId(),
+ auditCode.getSeverity(),
+ auditCode.getFormattedLogMessage(cohortName,
+ remoteRepositoryConnection.getConnectionName(),
+ remoteServerName,
+ remoteMetadataCollectionId),
+ error.getErrorMessage(),
+ auditCode.getSystemAction(),
+ auditCode.getUserAction());
+
+ if (outboundRegistryEventProcessor != null)
+ {
+ outboundRegistryEventProcessor.processBadConnectionEvent(cohortName,
+ localMetadataCollectionId,
+ localServerName,
+ localServerType,
+ localOrganizationName,
+ remoteMetadataCollectionId,
+ remoteRepositoryConnection,
+ error.getErrorMessage());
+ }
+ }
+ catch (Throwable error)
+ {
+ String formattedLogMessage = auditCode.getFormattedLogMessage(cohortName,
+ remoteRepositoryConnection.getConnectionName(),
+ remoteServerName,
+ remoteMetadataCollectionId);
+ auditLog.logRecord(actionDescription,
+ auditCode.getLogMessageId(),
+ auditCode.getSeverity(),
+ formattedLogMessage,
+ error.toString(),
+ auditCode.getSystemAction(),
+ auditCode.getUserAction());
+
+ if (outboundRegistryEventProcessor != null)
+ {
+ outboundRegistryEventProcessor.processBadConnectionEvent(cohortName,
+ localMetadataCollectionId,
+ localServerName,
+ localServerType,
+ localOrganizationName,
+ remoteMetadataCollectionId,
+ remoteRepositoryConnection,
+ auditCode.getLogMessageId() + formattedLogMessage);
+ }
+ }
+ }
+ }
+
+ /**
+ * Unregister a remote connection from the OMRSConnectionConsumer.
+ *
+ * @param remoteMetadataCollectionId - id of the remote repository
+ */
+ private void unRegisterRemoteConnectionWithConsumer(String remoteMetadataCollectionId)
+ {
+ if (connectionConsumer != null)
+ {
+ connectionConsumer.removeRemoteConnection(cohortName,
+ remoteMetadataCollectionId);
+ }
+ }
+
+
+ /*
+ * =============================
+ * OMRSRegistryEventProcessor
+ */
+
+ /**
+ * Introduces a new server/repository to the metadata repository cohort.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection that is registering with the cohort.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param registrationTimestamp - the time that the server/repository issued the registration request.
+ * @param remoteConnection - the Connection properties for the connector used to call the registering server.
+ * @param typeDefList - the list of TypeDefs supported by the registering server/repository.
+ */
+ public boolean processRegistrationEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ Date registrationTimestamp,
+ Connection remoteConnection,
+ ArrayList<TypeDefSummary> typeDefList)
+ {
+ final String actionDescription = "Receiving Registration event";
+
+ if (registryStore != null)
+ {
+ /*
+ * Store information about the remote repository in the cohort registry store.
+ */
+ MemberRegistration remoteRegistration = new MemberRegistration();
+
+ remoteRegistration.setMetadataCollectionId(originatorMetadataCollectionId);
+ remoteRegistration.setServerName(originatorServerName);
+ remoteRegistration.setServerType(originatorServerType);
+ remoteRegistration.setOrganizationName(originatorOrganizationName);
+ remoteRegistration.setRegistrationTime(registrationTimestamp);
+ remoteRegistration.setRepositoryConnection(remoteConnection);
+
+ registryStore.saveRemoteRegistration(remoteRegistration);
+
+ if (remoteConnection != null)
+ {
+ /*
+ * Pass the new remote connection to the connection consumer.
+ */
+ this.registerRemoteConnectionWithConsumer(originatorMetadataCollectionId,
+ originatorServerName,
+ remoteConnection);
+ }
+
+ OMRSAuditCode auditCode = OMRSAuditCode.NEW_MEMBER_IN_COHORT;
+ auditLog.logRecord(actionDescription,
+ auditCode.getLogMessageId(),
+ auditCode.getSeverity(),
+ auditCode.getFormattedLogMessage(cohortName,
+ originatorServerName,
+ originatorMetadataCollectionId),
+ null,
+ auditCode.getSystemAction(),
+ auditCode.getUserAction());
+
+ /*
+ * Check for incompatible TypeDefs occurring between this local repository and the new member.
+ * Incompatible TypeDefs are logged and managed by the typeDefValidator.
+ */
+ if ((typeDefValidator != null) && (typeDefList != null))
+ {
+ typeDefValidator.validateAgainstLocalTypeDefs(sourceName, typeDefList);
+ }
+
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+
+ /**
+ * Requests that the other servers in the cohort send re-registration events.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ */
+ public boolean processRegistrationRefreshRequest(String sourceName,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName)
+ {
+ final String actionDescription = "Receiving Registration Refresh event";
+
+ if (registryStore != null)
+ {
+ MemberRegistration localRegistration = registryStore.retrieveLocalRegistration();
+
+ if (localRegistration != null)
+ {
+ ArrayList<TypeDefSummary> typeDefSummaries = null;
+
+ if (typeDefValidator != null)
+ {
+ typeDefSummaries = typeDefValidator.getLocalTypeDefs();
+ }
+
+ OMRSAuditCode auditCode = OMRSAuditCode.REFRESHING_REGISTRATION_WITH_COHORT;
+ auditLog.logRecord(actionDescription,
+ auditCode.getLogMessageId(),
+ auditCode.getSeverity(),
+ auditCode.getFormattedLogMessage(cohortName,
+ localMetadataCollectionId,
+ originatorServerName),
+ null,
+ auditCode.getSystemAction(),
+ auditCode.getUserAction());
+
+ return outboundRegistryEventProcessor.processReRegistrationEvent(cohortName,
+ localRegistration.getMetadataCollectionId(),
+ localRegistration.getServerName(),
+ localRegistration.getServerType(),
+ localRegistration.getOrganizationName(),
+ localRegistration.getRegistrationTime(),
+ localRegistration.getRepositoryConnection(),
+ typeDefSummaries);
+ }
+ else
+ {
+ return true;
+ }
+ }
+ else
+ {
+ OMRSAuditCode auditCode = OMRSAuditCode.MISSING_MEMBER_REGISTRATION;
+ auditLog.logRecord(actionDescription,
+ auditCode.getLogMessageId(),
+ auditCode.getSeverity(),
+ auditCode.getFormattedLogMessage(originatorServerName,
+ cohortName),
+ null,
+ auditCode.getSystemAction(),
+ auditCode.getUserAction());
+
+ return false;
+ }
+ }
+
+
+ /**
+ * Refreshes the other servers in the cohort with the originator server's registration.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection that is registering with the cohort.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param registrationTimestamp - the time that the server/repository first registered with the cohort.
+ * @param remoteConnection - the Connection properties for the connector used to call the registering server.
+ * @param typeDefList - the list of TypeDefs supported by the registering server/repository.
+ */
+ public boolean processReRegistrationEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ Date registrationTimestamp,
+ Connection remoteConnection,
+ ArrayList<TypeDefSummary> typeDefList)
+ {
+ final String actionDescription = "Receiving ReRegistration event";
+
+ if (registryStore != null)
+ {
+ /*
+ * Store information about the remote repository in the cohort registry store. If the
+ * repository is already stored in the registry store, its entry is refreshed.
+ */
+ MemberRegistration remoteRegistration = new MemberRegistration();
+
+ remoteRegistration.setMetadataCollectionId(originatorMetadataCollectionId);
+ remoteRegistration.setServerName(originatorServerName);
+ remoteRegistration.setServerType(originatorServerType);
+ remoteRegistration.setOrganizationName(originatorOrganizationName);
+ remoteRegistration.setRegistrationTime(registrationTimestamp);
+ remoteRegistration.setRepositoryConnection(remoteConnection);
+
+ registryStore.saveRemoteRegistration(remoteRegistration);
+
+ if (remoteConnection != null)
+ {
+ /*
+ * Pass the new remote connection to the connection consumer. It may have been updated since
+ * the last registration request was received.
+ */
+ this.registerRemoteConnectionWithConsumer(originatorMetadataCollectionId,
+ originatorServerName,
+ remoteConnection);
+ }
+
+ OMRSAuditCode auditCode = OMRSAuditCode.REFRESHED_MEMBER_IN_COHORT;
+ auditLog.logRecord(actionDescription,
+ auditCode.getLogMessageId(),
+ auditCode.getSeverity(),
+ auditCode.getFormattedLogMessage(cohortName,
+ originatorServerName,
+ originatorMetadataCollectionId),
+ null,
+ auditCode.getSystemAction(),
+ auditCode.getUserAction());
+
+ /*
+ * Check for incompatible TypeDefs occurring between this local repository and the new member.
+ * The TypeDefManager will drive any error handling.
+ */
+ if ((typeDefValidator != null) && (typeDefList != null))
+ {
+ typeDefValidator.validateAgainstLocalTypeDefs(sourceName, typeDefList);
+ }
+
+ return true;
+ }
+ else
+ {
+ OMRSAuditCode auditCode = OMRSAuditCode.MISSING_MEMBER_REGISTRATION;
+ auditLog.logRecord(actionDescription,
+ auditCode.getLogMessageId(),
+ auditCode.getSeverity(),
+ auditCode.getFormattedLogMessage(originatorServerName,
+ cohortName),
+ null,
+ auditCode.getSystemAction(),
+ auditCode.getUserAction());
+
+ return false;
+ }
+ }
+
+
+ /**
+ * A server/repository is being removed from the metadata repository cohort.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - metadata collectionId of originator.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ */
+ public boolean processUnRegistrationEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName)
+ {
+ final String actionDescription = "Receiving Unregistration event";
+
+ if (registryStore != null)
+ {
+
+ /*
+ * Remove the remote member from the registry store.
+ */
+ registryStore.removeRemoteRegistration(originatorMetadataCollectionId);
+
+ /*
+ * Pass the new remote connection to the connection consumer.
+ */
+ this.unRegisterRemoteConnectionWithConsumer(originatorMetadataCollectionId);
+
+ OMRSAuditCode auditCode = OMRSAuditCode.MEMBER_LEFT_COHORT;
+ auditLog.logRecord(actionDescription,
+ auditCode.getLogMessageId(),
+ auditCode.getSeverity(),
+ auditCode.getFormattedLogMessage(originatorServerName,
+ originatorMetadataCollectionId,
+ cohortName),
+ null,
+ auditCode.getSystemAction(),
+ auditCode.getUserAction());
+
+ return true;
+ }
+ else
+ {
+ OMRSAuditCode auditCode = OMRSAuditCode.MISSING_MEMBER_REGISTRATION;
+ auditLog.logRecord(actionDescription,
+ auditCode.getLogMessageId(),
+ auditCode.getSeverity(),
+ auditCode.getFormattedLogMessage(originatorServerName,
+ cohortName),
+ null,
+ auditCode.getSystemAction(),
+ auditCode.getUserAction());
+
+ return false;
+ }
+ }
+
+
+ /**
+ * There is more than one member of the open metadata repository cohort that is using the same metadata
+ * collection Id. This means that their metadata instances can be updated in more than one server and their
+ * is a potential for data integrity issues.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - metadata collectionId of originator.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param conflictingMetadataCollectionId - unique identifier for the metadata collection that is registering with the cohort.
+ * @param errorMessage - details of the conflict
+ */
+ public void processConflictingCollectionIdEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ String conflictingMetadataCollectionId,
+ String errorMessage)
+ {
+ if (conflictingMetadataCollectionId != null)
+ {
+ final String actionDescription = "Receiving Conflicting Metadata Collection Id event";
+
+ if (conflictingMetadataCollectionId.equals(localMetadataCollectionId))
+ {
+ OMRSAuditCode auditCode = OMRSAuditCode.INCOMING_CONFLICTING_LOCAL_METADATA_COLLECTION_ID;
+ auditLog.logRecord(actionDescription,
+ auditCode.getLogMessageId(),
+ auditCode.getSeverity(),
+ auditCode.getFormattedLogMessage(cohortName,
+ originatorServerName,
+ originatorMetadataCollectionId,
+ conflictingMetadataCollectionId),
+ null,
+ auditCode.getSystemAction(),
+ auditCode.getUserAction());
+ }
+ else
+ {
+ OMRSAuditCode auditCode = OMRSAuditCode.INCOMING_CONFLICTING_METADATA_COLLECTION_ID;
+ auditLog.logRecord(actionDescription,
+ auditCode.getLogMessageId(),
+ auditCode.getSeverity(),
+ auditCode.getFormattedLogMessage(cohortName,
+ conflictingMetadataCollectionId),
+ null,
+ auditCode.getSystemAction(),
+ auditCode.getUserAction());
+ }
+ }
+ }
+
+
+ /**
+ * A connection to one of the members of the open metadata repository cohort is not usable by one of the members.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - metadata collectionId of originator.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param targetMetadataCollectionId - Id for the repository with the bad remote connection.
+ * @param remoteRepositoryConnection - the Connection properties for the connector used to call the registering server.
+ * @param errorMessage - details of the error that occurs when the connection is used.
+ */
+ public void processBadConnectionEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ String targetMetadataCollectionId,
+ Connection remoteRepositoryConnection,
+ String errorMessage)
+ {
+ if (targetMetadataCollectionId != null)
+ {
+ if (targetMetadataCollectionId.equals(localMetadataCollectionId))
+ {
+ /*
+ * The event is directed to this server.
+ */
+ final String actionDescription = "Receiving Bad Connection event";
+ OMRSAuditCode auditCode = OMRSAuditCode.INCOMING_BAD_CONNECTION;
+ auditLog.logRecord(actionDescription,
+ auditCode.getLogMessageId(),
+ auditCode.getSeverity(),
+ auditCode.getFormattedLogMessage(cohortName,
+ originatorServerName,
+ originatorMetadataCollectionId,
+ remoteRepositoryConnection.getConnectionName()),
+ remoteRepositoryConnection.toString(),
+ auditCode.getSystemAction(),
+ auditCode.getUserAction());
+ }
+ }
+ }
+
+
+ /**
+ * Standard toString method.
+ *
+ * @return JSON style description of variables.
+ */
+ @Override
+ public String toString()
+ {
+ return "OMRSCohortRegistry{" +
+ "cohortName='" + cohortName + '\'' +
+ ", localMetadataCollectionId='" + localMetadataCollectionId + '\'' +
+ ", localRepositoryRemoteConnection=" + localRepositoryRemoteConnection +
+ ", localServerName='" + localServerName + '\'' +
+ ", localServerType='" + localServerType + '\'' +
+ ", localOrganizationName='" + localOrganizationName + '\'' +
+ ", registryStore=" + registryStore +
+ ", outboundRegistryEventProcessor=" + outboundRegistryEventProcessor +
+ ", connectionConsumer=" + connectionConsumer +
+ ", typeDefValidator=" + typeDefValidator +
+ '}';
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/metadatahighway/cohortregistry/store/OMRSCohortRegistryStore.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/metadatahighway/cohortregistry/store/OMRSCohortRegistryStore.java b/omrs/src/main/java/org/apache/atlas/omrs/metadatahighway/cohortregistry/store/OMRSCohortRegistryStore.java
new file mode 100644
index 0000000..1539c3c
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/metadatahighway/cohortregistry/store/OMRSCohortRegistryStore.java
@@ -0,0 +1,114 @@
+/*
+ * 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.metadatahighway.cohortregistry.store;
+
+import org.apache.atlas.omrs.metadatahighway.cohortregistry.store.properties.MemberRegistration;
+
+import java.util.ArrayList;
+
+
+/**
+ * OMRSCohortRegistryStore is a connector to a repository that can store registration information for a cohort registry.
+ * Each repository store serves a single repository. It supports:
+ * <ul>
+ * <li>
+ * One LocalRegistration that describes information about the local repository and its registration with
+ * the metadata repository cohort. Note: the local registration is null if there is no local repository.
+ * </li>
+ * <li>
+ * None to many RemoteRegistrations. There is a RemoteRegistration for each of the other repositories
+ * registered in the metadata repository cohort.
+ * </li>
+ * </ul>
+ */
+public interface OMRSCohortRegistryStore
+{
+ /**
+ * Save the local registration to the cohort registry store. This provides details of the local repository's
+ * registration with the metadata repository cohort.
+ * Any previous local registration information is overwritten.
+ *
+ * @param localRegistration - details of the local repository's registration with the metadata cohort.
+ */
+ void saveLocalRegistration(MemberRegistration localRegistration);
+
+
+ /**
+ * Retrieve details of the local registration from the cohort registry store. A null may be returned if the
+ * local registration information has not been saved (typically because this is a new server instance).
+ *
+ * @return MemberRegistration object containing details for the local repository's registration with the
+ * metadata cohort
+ */
+ MemberRegistration retrieveLocalRegistration();
+
+
+ /**
+ * Remove details of the local registration from the cohort registry store. This is used when the local
+ * repository unregisters from the open metadata repository cohort.
+ */
+ void removeLocalRegistration();
+
+
+ /**
+ * Save details of a remote registration. This contains details of one of the other repositories in the
+ * metadata repository cohort. If a remote registration already exists, it is over-written.
+ *
+ * @param remoteRegistration - details of a remote repository in the metadata repository cohort.
+ */
+ void saveRemoteRegistration(MemberRegistration remoteRegistration);
+
+
+ /**
+ * Return a list of all of the remote metadata repositories registered in the metadata repository cohort.
+ *
+ * @return List of member registrations for remote servers/repositories
+ */
+ ArrayList<MemberRegistration> retrieveRemoteRegistrations();
+
+
+ /**
+ * Return the registration information for a specific metadata repository, identified by its repository's
+ * metadata collection Id. If the metadata collection Id is not recognized then null is returned.
+ *
+ * @param metadataCollectionId - unique identifier for the repository's metadata collection.
+ * @return MemberRegistration object containing details of the remote metadata repository.
+ */
+ MemberRegistration retrieveRemoteRegistration(String metadataCollectionId);
+
+
+ /**
+ * Remove details of the requested remote repository's registration from the store.
+ *
+ * @param metadataCollectionId - unique identifier for the repository's metadata collection
+ */
+ void removeRemoteRegistration(String metadataCollectionId);
+
+
+ /**
+ * Remove the local and remote registrations from the cohort registry store since the local server has
+ * unregistered from the cohort.
+ */
+ void clearAllRegistrations();
+
+
+ /**
+ * Flush all changes and close the registry store.
+ */
+ void close();
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/metadatahighway/cohortregistry/store/OMRSCohortRegistryStoreConnectorBase.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/metadatahighway/cohortregistry/store/OMRSCohortRegistryStoreConnectorBase.java b/omrs/src/main/java/org/apache/atlas/omrs/metadatahighway/cohortregistry/store/OMRSCohortRegistryStoreConnectorBase.java
new file mode 100644
index 0000000..dbd7b28
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/metadatahighway/cohortregistry/store/OMRSCohortRegistryStoreConnectorBase.java
@@ -0,0 +1,24 @@
+/*
+ * 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.metadatahighway.cohortregistry.store;
+
+import org.apache.atlas.ocf.ConnectorBase;
+
+public abstract class OMRSCohortRegistryStoreConnectorBase extends ConnectorBase implements OMRSCohortRegistryStore
+{
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/metadatahighway/cohortregistry/store/OMRSCohortRegistryStoreProviderBase.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/metadatahighway/cohortregistry/store/OMRSCohortRegistryStoreProviderBase.java b/omrs/src/main/java/org/apache/atlas/omrs/metadatahighway/cohortregistry/store/OMRSCohortRegistryStoreProviderBase.java
new file mode 100644
index 0000000..176760c
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/metadatahighway/cohortregistry/store/OMRSCohortRegistryStoreProviderBase.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.metadatahighway.cohortregistry.store;
+
+import org.apache.atlas.ocf.ConnectorProviderBase;
+
+/**
+ * The OMRSCohortRegistryStoreProviderBase provides a base class for the connector provider supporting OMRS
+ * cluster registry stores. It extends ConnectorProviderBase which does the creation of connector instances.
+ * The subclasses of OMRSCohortRegistryStoreProviderBase must initialize ConnectorProviderBase with the Java class
+ * name of the registry store connector implementation (by calling super.setConnectorClassName(className)).
+ * Then the connector provider will work.
+ */
+public abstract class OMRSCohortRegistryStoreProviderBase extends ConnectorProviderBase
+{
+ /**
+ * Default Constructor
+ */
+ public OMRSCohortRegistryStoreProviderBase()
+ {
+ /*
+ * Nothing to do
+ */
+ }
+}
+
[04/30] atlas git commit: ATLAS-2246: OMRS Connector API plus REST
and IGC Connector skeleton - 15th February 2018
Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/EntityDef.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/EntityDef.java b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/EntityDef.java
new file mode 100644
index 0000000..72e216a
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/EntityDef.java
@@ -0,0 +1,93 @@
+/*
+ * 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.metadatacollection.properties.typedefs;
+
+/**
+ * EntityDef describes a type of entity in the metadata collection. It is the simplest TypeDef that adds
+ * no other properties beyond TypeDef.
+ */
+public class EntityDef extends TypeDef
+{
+ /**
+ * Minimal constructor - initializes the superclass as an Entity
+ */
+ public EntityDef()
+ {
+ super(TypeDefCategory.ENTITY_DEF);
+ }
+
+
+ /**
+ * Typical constructor is passed the properties of the typedef's super class being constructed.
+ *
+ * @param category - category of this TypeDef
+ * @param guid - unique id for the TypeDef
+ * @param name - unique name for the TypeDef
+ * @param version - active version number for the TypeDef
+ * @param versionName - unique name for the TypeDef
+ */
+ public EntityDef(TypeDefCategory category,
+ String guid,
+ String name,
+ long version,
+ String versionName)
+ {
+ super(category, guid, name, version, versionName);
+ }
+
+
+ /**
+ * Copy/clone constructor - copies the values from the supplied template.
+ *
+ * @param template EntityDef
+ */
+ public EntityDef(EntityDef template)
+ {
+ super(template);
+ }
+
+ /**
+ * Standard toString method.
+ *
+ * @return JSON style description of variables.
+ */
+ @Override
+ public String toString()
+ {
+ return "EntityDef{" +
+ "superType=" + superType +
+ ", description='" + description + '\'' +
+ ", descriptionGUID='" + descriptionGUID + '\'' +
+ ", origin='" + origin + '\'' +
+ ", createdBy='" + createdBy + '\'' +
+ ", updatedBy='" + updatedBy + '\'' +
+ ", createTime=" + createTime +
+ ", updateTime=" + updateTime +
+ ", options=" + options +
+ ", externalStandardMappings=" + externalStandardMappings +
+ ", validInstanceStatusList=" + validInstanceStatusList +
+ ", initialStatus=" + initialStatus +
+ ", propertiesDefinition=" + propertiesDefinition +
+ ", version=" + version +
+ ", versionName='" + versionName + '\'' +
+ ", category=" + category +
+ ", guid='" + guid + '\'' +
+ ", name='" + name + '\'' +
+ '}';
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/EnumDef.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/EnumDef.java b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/EnumDef.java
new file mode 100644
index 0000000..5f7b881
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/EnumDef.java
@@ -0,0 +1,119 @@
+/*
+ * 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.metadatacollection.properties.typedefs;
+
+
+import java.util.ArrayList;
+
+/**
+ * The EnumDef describes an open metadata enumeration. This enumeration consists of a list of valid values
+ * (stored in EnumElementDef objects) and a default value.
+ */
+public class EnumDef extends AttributeTypeDef
+{
+ private ArrayList<EnumElementDef> elementDefs = null;
+ private EnumElementDef defaultValue = null;
+
+
+ /**
+ * Default constructor sets up an empty EnumDef.
+ */
+ public EnumDef()
+ {
+ super(AttributeTypeDefCategory.ENUM_DEF);
+ }
+
+
+ /**
+ * Copy/clone constructor sets the EnumDef based on the values from the supplied template.
+ *
+ * @param template EnumDef
+ */
+ public EnumDef(EnumDef template)
+ {
+ super(template);
+
+ if (template != null)
+ {
+ elementDefs = template.getElementDefs();
+ defaultValue = template.getDefaultValue();
+ }
+ }
+
+
+ /**
+ * Return the list of defined Enum values for this EnumDef.
+ *
+ * @return EnumElementDefs list
+ */
+ public ArrayList<EnumElementDef> getElementDefs()
+ {
+ if (elementDefs == null)
+ {
+ return elementDefs;
+ }
+ else
+ {
+ return new ArrayList<>(elementDefs);
+ }
+ }
+
+
+ /**
+ * Set up the list of defined Enum values for this EnumDef.
+ *
+ * @param elementDefs - EnumElementDefs list
+ */
+ public void setElementDefs(ArrayList<EnumElementDef> elementDefs) { this.elementDefs = elementDefs; }
+
+
+ /**
+ * Return the default value for the EnumDef.
+ *
+ * @return EnumElementDef representing the default value
+ */
+ public EnumElementDef getDefaultValue() { return defaultValue; }
+
+
+ /**
+ * Set up the default value for the EnumDef.
+ *
+ * @param defaultValue - EnumElementDef representing the default value
+ */
+ public void setDefaultValue(EnumElementDef defaultValue) { this.defaultValue = defaultValue; }
+
+
+ /**
+ * Standard toString method.
+ *
+ * @return JSON style description of variables.
+ */
+ @Override
+ public String toString()
+ {
+ return "EnumDef{" +
+ "elementDefs=" + elementDefs +
+ ", defaultValue=" + defaultValue +
+ ", category=" + category +
+ ", guid='" + guid + '\'' +
+ ", name='" + name + '\'' +
+ ", description='" + description + '\'' +
+ ", descriptionGUID='" + descriptionGUID + '\'' +
+ '}';
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/EnumElementDef.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/EnumElementDef.java b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/EnumElementDef.java
new file mode 100644
index 0000000..810bc85
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/EnumElementDef.java
@@ -0,0 +1,144 @@
+/*
+ * 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.metadatacollection.properties.typedefs;
+
+
+/**
+ * EnumElementDef describes a single valid value defined for an enum.
+ */
+public class EnumElementDef extends TypeDefElementHeader
+{
+ private int ordinal = 99;
+ private String value = null;
+ private String description = null;
+ private String descriptionGUID = null;
+
+
+ /**
+ * Default constructor - sets up an empty EnumElementDef
+ */
+ public EnumElementDef()
+ {
+ super();
+ }
+
+
+ /**
+ * Copy/clone constructor - sets up an EnumElementDef based on the values supplied in the template.
+ *
+ * @param template EnumElementDef
+ */
+ public EnumElementDef(EnumElementDef template)
+ {
+ super(template);
+
+ if (template != null)
+ {
+ ordinal = template.getOrdinal();
+ value = template.getValue();
+ description = template.getDescription();
+ descriptionGUID = template.getDescriptionGUID();
+ }
+ }
+
+
+ /**
+ * Return the numeric value used for the enum value.
+ *
+ * @return int ordinal
+ */
+ public int getOrdinal() { return ordinal; }
+
+
+ /**
+ * Set up the numeric value for the enum value.
+ *
+ * @param ordinal int
+ */
+ public void setOrdinal(int ordinal) { this.ordinal = ordinal; }
+
+
+ /**
+ * Return the symbolic name for the enum value.
+ *
+ * @return String name
+ */
+ public String getValue() { return value; }
+
+
+ /**
+ * Set up the symbolic name for the enum value.
+ *
+ * @param value String name
+ */
+ public void setValue(String value) { this.value = value; }
+
+
+ /**
+ * Return the description for the enum value.
+ *
+ * @return String description
+ */
+ public String getDescription() { return description; }
+
+
+ /**
+ * Set up the description for the enum value.
+ *
+ * @param description String
+ */
+ public void setDescription(String description) { this.description = description; }
+
+
+ /**
+ * Return the unique identifier (guid) of the glossary term that describes this EnumElementDef.
+ *
+ * @return String guid
+ */
+ public String getDescriptionGUID()
+ {
+ return descriptionGUID;
+ }
+
+
+ /**
+ * Set up the unique identifier (guid) of the glossary term that describes this EnumElementDef.
+ *
+ * @param descriptionGUID - String guid
+ */
+ public void setDescriptionGUID(String descriptionGUID)
+ {
+ this.descriptionGUID = descriptionGUID;
+ }
+
+ /**
+ * Standard toString method.
+ *
+ * @return JSON style description of variables.
+ */
+ @Override
+ public String toString()
+ {
+ return "EnumElementDef{" +
+ "ordinal=" + ordinal +
+ ", value='" + value + '\'' +
+ ", description='" + description + '\'' +
+ ", descriptionGUID='" + descriptionGUID + '\'' +
+ '}';
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/ExternalStandardMapping.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/ExternalStandardMapping.java b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/ExternalStandardMapping.java
new file mode 100644
index 0000000..e9cca34
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/ExternalStandardMapping.java
@@ -0,0 +1,141 @@
+/*
+ * 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.metadatacollection.properties.typedefs;
+
+/**
+ * ExternalStandardMapping defines a mapping of TypeDefs and TypeDefAttributes to an external standard. It includes the name
+ * of the standard, the organization that owns the standard and the equivalent type in the external standard.
+ * This mapping is done on a property type by property type basis. The aim is to create clarity on the meaning
+ * of the open metadata types and support importers and exporters between open metadata types and external standards.
+ */
+public class ExternalStandardMapping extends TypeDefElementHeader
+{
+ private String standardName = null;
+ private String standardOrganization = null;
+ private String standardTypeName = null;
+
+
+ /**
+ * Default Constructor - initializes to null.
+ */
+ public ExternalStandardMapping()
+ {
+ /*
+ * Initialize superclass.
+ */
+ super();
+ }
+
+
+ /**
+ * Copy/clone constructor - copies values from supplied template.
+ *
+ * @param templateElement - template to copy.
+ */
+ public ExternalStandardMapping(ExternalStandardMapping templateElement)
+ {
+ /*
+ * Initialize superclass.
+ */
+ super(templateElement);
+
+ /*
+ * Copy the template values over.
+ */
+ this.standardName = templateElement.getStandardName();
+ this.standardOrganization = templateElement.getStandardOrganization();
+ this.standardTypeName = templateElement.getStandardTypeName();
+ }
+
+
+ /**
+ * Return the name of the standard that this mapping relates to.
+ *
+ * @return String standard name
+ */
+ public String getStandardName() {
+ return standardName;
+ }
+
+
+ /**
+ * Set up the name of the standard that this mapping relates to.
+ *
+ * @param standardName - String standard name
+ */
+ public void setStandardName(String standardName) {
+ this.standardName = standardName;
+ }
+
+
+ /**
+ * Return the name of organization that owns the standard that this mapping refers to.
+ *
+ * @return String organization name
+ */
+ public String getStandardOrganization() {
+ return standardOrganization;
+ }
+
+
+ /**
+ * Set up the name of the organization that owns the standard that this mapping refers to.
+ *
+ * @param standardOrganization - String organization name
+ */
+ public void setStandardOrganization(String standardOrganization)
+ {
+ this.standardOrganization = standardOrganization;
+ }
+
+
+ /**
+ * Return the name of the type from the standard that is equivalent to the linked open metadata type.
+ *
+ * @return String type name from standard
+ */
+ public String getStandardTypeName() {
+ return standardTypeName;
+ }
+
+
+ /**
+ * Set up the name of the type from the standard that is equivalent to the linked open metadata type.
+ *
+ * @param standardTypeName - String type name from standard
+ */
+ public void setStandardTypeName(String standardTypeName) {
+ this.standardTypeName = standardTypeName;
+ }
+
+
+ /**
+ * Standard toString method.
+ *
+ * @return JSON style description of variables.
+ */
+ @Override
+ public String toString()
+ {
+ return "ExternalStandardMapping{" +
+ "standardName='" + standardName + '\'' +
+ ", standardOrganization='" + standardOrganization + '\'' +
+ ", standardTypeName='" + standardTypeName + '\'' +
+ '}';
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/PrimitiveDef.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/PrimitiveDef.java b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/PrimitiveDef.java
new file mode 100644
index 0000000..94ab27b
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/PrimitiveDef.java
@@ -0,0 +1,83 @@
+/*
+ * 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.metadatacollection.properties.typedefs;
+
+/**
+ * PrimitiveDef supports the definition of a primitive type. This information is managed in the
+ * PrimitiveDefCategory.
+ */
+public class PrimitiveDef extends AttributeTypeDef
+{
+ private PrimitiveDefCategory primitiveDefCategory = null;
+
+
+ /**
+ * Default constructor initializes the PrimitiveDef based on the supplied category.
+ *
+ * @param primitiveDefCategory - PrimitiveDefCategory Enum
+ */
+ public PrimitiveDef(PrimitiveDefCategory primitiveDefCategory)
+ {
+ super(AttributeTypeDefCategory.PRIMITIVE);
+
+ this.primitiveDefCategory = primitiveDefCategory;
+ }
+
+
+ /**
+ * Copy/clone constructor creates a copy of the supplied template.
+ *
+ * @param template PrimitiveDef to copy
+ */
+ public PrimitiveDef(PrimitiveDef template)
+ {
+ super(template);
+
+ if (template != null)
+ {
+ this.primitiveDefCategory = template.getPrimitiveDefCategory();
+ }
+ }
+
+
+ /**
+ * Return the type category for this primitive type.
+ *
+ * @return PrimitiveDefCategory Enum
+ */
+ public PrimitiveDefCategory getPrimitiveDefCategory() { return primitiveDefCategory; }
+
+
+ /**
+ * Standard toString method.
+ *
+ * @return JSON style description of variables.
+ */
+ @Override
+ public String toString()
+ {
+ return "PrimitiveDef{" +
+ "primitiveDefCategory=" + primitiveDefCategory +
+ ", category=" + category +
+ ", guid='" + guid + '\'' +
+ ", name='" + name + '\'' +
+ ", description='" + description + '\'' +
+ ", descriptionGUID='" + descriptionGUID + '\'' +
+ '}';
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/PrimitiveDefCategory.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/PrimitiveDefCategory.java b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/PrimitiveDefCategory.java
new file mode 100644
index 0000000..2c5f65a
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/PrimitiveDefCategory.java
@@ -0,0 +1,103 @@
+/*
+ * 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.metadatacollection.properties.typedefs;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+
+/**
+ * This enumeration defines the list of open metadata primitive types. This includes a code value, a string
+ * name for the type (used in self describing structures such as JSON or XML) and the name of the Java Class
+ * that supports this type.
+ */
+public enum PrimitiveDefCategory implements Serializable
+{
+ OM_PRIMITIVE_TYPE_UNKNOWN (0, "<>", null, null),
+ OM_PRIMITIVE_TYPE_BOOLEAN (1, "boolean", "java.lang.Boolean", "3863f010-611c-41fe-aaae-5d4d427f863b"),
+ OM_PRIMITIVE_TYPE_BYTE (2, "byte", "java.lang.Byte", "6b7d410a-2e8a-4d12-981a-a806449f9bdb"),
+ OM_PRIMITIVE_TYPE_CHAR (3, "char", "java.Lang.Char", "b0abebe5-cf85-4065-86ad-f3c6360ed9c7"),
+ OM_PRIMITIVE_TYPE_SHORT (4, "short", "java.lang.Short", "8e95b966-ab60-46d4-a03f-40c5a1ba6c2a"),
+ OM_PRIMITIVE_TYPE_INT (5, "int", "java.lang.Integer", "7fc49104-fd3a-46c8-b6bf-f16b6074cd35"),
+ OM_PRIMITIVE_TYPE_LONG (6, "long", "java.lang.Long", "33a91510-92ee-4825-9f49-facd7a6f9db6"),
+ OM_PRIMITIVE_TYPE_FLOAT (7, "float", "java.lang.Float", "52aeb769-37b7-4b30-b949-ddc7dcebcfa2"),
+ OM_PRIMITIVE_TYPE_DOUBLE (8, "double", "java.lang.Double", "e13572e8-25c3-4994-acb6-2ea66c95812e"),
+ OM_PRIMITIVE_TYPE_BIGINTEGER(9, "biginteger", "java.math.BigInteger", "8aa56e52-1076-4e0d-9b66-3873a1ed7392"),
+ OM_PRIMITIVE_TYPE_BIGDECIMAL(10, "bigdecimal", "java.math.BigDecimal", "d5c8ad9f-8fee-4a64-80b3-63ce1e47f6bb"),
+ OM_PRIMITIVE_TYPE_STRING (11, "string", "java.lang.String", "b34a64b9-554a-42b1-8f8a-7d5c2339f9c4"),
+ OM_PRIMITIVE_TYPE_DATE (12, "date", "java.util.Date", "1bef35ca-d4f9-48db-87c2-afce4649362d");
+
+ private static final long serialVersionUID = 1L;
+
+ private int code;
+ private String name;
+ private String javaClassName;
+ private String guid;
+
+
+ /**
+ * Constructor to set up a single instances of the enum.
+ *
+ * @param code - int code for enum
+ * @param name - String name of the primitive type
+ * @param javaClassName - String name of the class that stores the primitive attribute.
+ */
+ PrimitiveDefCategory(int code, String name, String javaClassName, String guid)
+ {
+ this.code = code;
+ this.name = name;
+ this.javaClassName = javaClassName;
+ this.guid = guid;
+ }
+
+ /**
+ * Return the numeric code for the primitive type which can be used in optimized data flows.
+ *
+ * @return int type code
+ */
+ public int getCode() {
+ return code;
+ }
+
+
+ /**
+ * Return the name of type - which can be used for text-based interchange formats such as JSON or XML.
+ *
+ * @return String type name
+ */
+ public String getName() {
+ return name;
+ }
+
+
+ /**
+ * Return the name of the java class that can be used to store properties of this type.
+ *
+ * @return String java class name.
+ */
+ public String getJavaClassName() {
+ return javaClassName;
+ }
+
+
+ /**
+ * Return the guid for this primitive type.
+ *
+ * @return String guid
+ */
+ public String getGUID() { return guid; }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/RelationshipCategory.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/RelationshipCategory.java b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/RelationshipCategory.java
new file mode 100644
index 0000000..da21faa
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/RelationshipCategory.java
@@ -0,0 +1,94 @@
+/*
+ * 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.metadatacollection.properties.typedefs;
+
+import java.io.Serializable;
+
+/**
+ * <p>
+ * The RelationshipCategory determines the style of relationship around containment and lifecycle.
+ * UML terminology is used for the values. All relationships are navigable in both directions.
+ * </p>
+ * <p>
+ * Association is a simple relationship with no containment.
+ * Composition and Aggregation are containment relationships which means there is a notion of
+ * control or collective management of the contained entities by the containing entity.
+ * </p>
+ * <p>
+ * Entities in an aggregation relationship can be
+ * aggregated by many other entities and their lifecycle is not controlled by the containing entity.
+ * For example, contained entities are not deleted when the containing entity is deleted.
+ * </p>
+ * <p>
+ * Composition relationship is a "part of" relationship where the contained entities can only exist in the
+ * scope/context of the containing entity. Often the fully qualified name of a contained entity
+ * in a composition relationship includes the name of its containing entity.
+ * </p>
+ */
+public enum RelationshipCategory implements Serializable
+{
+ UNKNOWN (0, "<Unknown>", "Uninitialized Relationship."),
+ ASSOCIATION(1, "Association", "Simple relationship."),
+ AGGREGATION(2, "Aggregation", "A grouping of entities that are managed together."),
+ COMPOSITION(3, "Composition", "A grouping of entities that are part of a bigger concept.");
+
+ private static final long serialVersionUID = 1L;
+
+ private int ordinal;
+ private String name;
+ private String description;
+
+
+ /**
+ * Constructor to set up a single instances of the enum.
+ *
+ * @param ordinal - code value
+ * @param name - name
+ * @param description - default description
+ */
+ RelationshipCategory(int ordinal, String name, String description)
+ {
+ this.ordinal = ordinal;
+ this.name = name;
+ this.description = description;
+ }
+
+
+ /**
+ * Return the numeric representation of the relationship category.
+ *
+ * @return int ordinal
+ */
+ public int getOrdinal() { return ordinal; }
+
+
+ /**
+ * Return the default name of the relationship category.
+ *
+ * @return String name
+ */
+ public String getName() { return name; }
+
+
+ /**
+ * Return the default description of the relationship category.
+ *
+ * @return String description
+ */
+ public String getDescription() { return description; }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/RelationshipContainerEnd.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/RelationshipContainerEnd.java b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/RelationshipContainerEnd.java
new file mode 100644
index 0000000..4c533c1
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/RelationshipContainerEnd.java
@@ -0,0 +1,75 @@
+/*
+ * 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.metadatacollection.properties.typedefs;
+
+
+import java.io.Serializable;
+
+/**
+ * The RelationshipContainerEnd enum defines which end of the relationship is the container (where the diamond is
+ * in UML-speak). NOT_APPLICABLE is used on an association. END1 or END2 is used on an aggregation or composition.
+ */
+public enum RelationshipContainerEnd implements Serializable
+{
+ NOT_APPLICABLE (0, "Not Applicable", "This relationship does not support containment."),
+ END1 (1, "End 1", "The containment is at end 1."),
+ END2 (2, "End 2", "The containment is at end 2.");
+
+ private static final long serialVersionUID = 1L;
+
+ private int ordinal;
+ private String name;
+ private String description;
+
+ /**
+ * Constructor to set up a single instances of the enum.
+ *
+ * @param ordinal - numerical representation of the container end
+ * @param name - default string name of the container end
+ * @param description - default string description of the container
+ */
+ RelationshipContainerEnd(int ordinal, String name, String description)
+ {
+ this.ordinal = ordinal;
+ this.name = name;
+ this.description = description;
+ }
+
+ /**
+ * Return the numeric representation of the container end indicator.
+ *
+ * @return int ordinal
+ */
+ public int getOrdinal() { return ordinal; }
+
+
+ /**
+ * Return the default name of the container end indicator.
+ *
+ * @return String name
+ */
+ public String getName() { return name; }
+
+
+ /**
+ * Return the default description of the container end indicator.
+ *
+ * @return String description
+ */
+ public String getDescription() { return description; }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/RelationshipDef.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/RelationshipDef.java b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/RelationshipDef.java
new file mode 100644
index 0000000..44f7adb
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/RelationshipDef.java
@@ -0,0 +1,217 @@
+/*
+ * 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.metadatacollection.properties.typedefs;
+
+
+/**
+ * RelationshipDef describes the type of a relationship. A relationships links two entities together.
+ * The RelationshipDef defines the types of those entities in the RelationshipEndDefs. It
+ * defines if this relationship allows classifications to propagate through it and also it defines the type of
+ * relationship - such as association, composition and aggregation.
+ */
+public class RelationshipDef extends TypeDef
+{
+ private RelationshipCategory relationshipCategory = RelationshipCategory.UNKNOWN;
+ private RelationshipContainerEnd relationshipContainerEnd = RelationshipContainerEnd.NOT_APPLICABLE;
+ private ClassificationPropagationRule propagationRule = ClassificationPropagationRule.NONE;
+ private RelationshipEndDef endDef1 = null;
+ private RelationshipEndDef endDef2 = null;
+
+
+ /**
+ * Minimal constructor builds an empty RelationshipDef
+ */
+ public RelationshipDef()
+ {
+ super(TypeDefCategory.RELATIONSHIP_DEF);
+ }
+
+
+ /**
+ * Typical constructor is passed the properties of the typedef's super class being constructed.
+ *
+ * @param category - category of this TypeDef
+ * @param guid - unique id for the TypeDef
+ * @param name - unique name for the TypeDef
+ * @param version - active version number for the TypeDef
+ * @param versionName - unique name for the TypeDef
+ */
+ public RelationshipDef(TypeDefCategory category,
+ String guid,
+ String name,
+ long version,
+ String versionName)
+ {
+ super(category, guid, name, version, versionName);
+ }
+
+
+ /**
+ * Copy/clone constructor creates a copy of the supplied template.
+ *
+ * @param templateTypeDef - template to copy
+ */
+ public RelationshipDef(RelationshipDef templateTypeDef)
+ {
+ super(templateTypeDef);
+
+ if (templateTypeDef != null)
+ {
+ this.relationshipCategory = templateTypeDef.getRelationshipCategory();
+ this.propagationRule = templateTypeDef.getPropagationRule();
+ this.endDef1 = templateTypeDef.getEndDef1();
+ this.endDef2 = templateTypeDef.getEndDef2();
+ }
+ }
+
+
+ /**
+ * Return the specific category for this relationship.
+ *
+ * @return RelationshipCategory Enum
+ */
+ public RelationshipCategory getRelationshipCategory() { return relationshipCategory; }
+
+
+ /**
+ * Set up the specific category for this relationship.
+ *
+ * @param relationshipCategory - RelationshipCategory enum
+ */
+ public void setRelationshipCategory(RelationshipCategory relationshipCategory)
+ {
+ this.relationshipCategory = relationshipCategory;
+ }
+
+
+ /**
+ * Return the enum that defines which end of the relationship is the container (the diamond end in UML-speak).
+ * This is used in conjunction with relationship categories AGGREGATION and COMPOSITION.
+ *
+ * @return RelationshipContainerEnd enum value
+ */
+ public RelationshipContainerEnd getRelationshipContainerEnd()
+ {
+ return relationshipContainerEnd;
+ }
+
+
+ /**
+ * Set up the enum that defines which end of the relationship is the container (the diamond end in UML-speak).
+ * This is used in conjunction with relationship categories AGGREGATION and COMPOSITION.
+ *
+ * @param relationshipContainerEnd - RelationshipContainerEnd enum value
+ */
+ public void setRelationshipContainerEnd(RelationshipContainerEnd relationshipContainerEnd)
+ {
+ this.relationshipContainerEnd = relationshipContainerEnd;
+ }
+
+
+ /**
+ * Return the rule that determines if classifications are propagated across this relationship.
+ *
+ * @return ClassificationPropagationRule Enum
+ */
+ public ClassificationPropagationRule getPropagationRule() { return propagationRule; }
+
+
+ /**
+ * Set up the rule that determines if classifications are propagated across this relationship.
+ *
+ * @param propagationRule - ClassificationPropagationRule Enum
+ */
+ public void setPropagationRule(ClassificationPropagationRule propagationRule)
+ {
+ this.propagationRule = propagationRule;
+ }
+
+
+ /**
+ * Return the details associated with the first end of the relationship.
+ *
+ * @return endDef1 RelationshipEndDef
+ */
+ public RelationshipEndDef getEndDef1()
+ {
+ return endDef1;
+ }
+
+
+ /**
+ * Set up the details associated with the first end of the relationship.
+ *
+ * @param endDef1 RelationshipEndDef
+ */
+ public void setEndDef1(RelationshipEndDef endDef1) { this.endDef1 = endDef1; }
+
+
+ /**
+ * Return the details associated with the second end of the relationship.
+ *
+ * @return endDef2 RelationshipEndDef
+ */
+ public RelationshipEndDef getEndDef2()
+ {
+ return endDef2;
+ }
+
+
+ /**
+ * Set up the details associated with the second end of the relationship.
+ *
+ * @param endDef2 RelationshipEndDef
+ */
+ public void setEndDef2(RelationshipEndDef endDef2) { this.endDef2 = endDef2; }
+
+
+ /**
+ * Standard toString method.
+ *
+ * @return JSON style description of variables.
+ */
+ @Override
+ public String toString()
+ {
+ return "RelationshipDef{" +
+ "relationshipCategory=" + relationshipCategory +
+ ", relationshipContainerEnd=" + relationshipContainerEnd +
+ ", propagationRule=" + propagationRule +
+ ", endDef1=" + endDef1 +
+ ", endDef2=" + endDef2 +
+ ", superType=" + superType +
+ ", description='" + description + '\'' +
+ ", descriptionGUID='" + descriptionGUID + '\'' +
+ ", origin='" + origin + '\'' +
+ ", createdBy='" + createdBy + '\'' +
+ ", updatedBy='" + updatedBy + '\'' +
+ ", createTime=" + createTime +
+ ", updateTime=" + updateTime +
+ ", options=" + options +
+ ", externalStandardMappings=" + externalStandardMappings +
+ ", validInstanceStatusList=" + validInstanceStatusList +
+ ", initialStatus=" + initialStatus +
+ ", propertiesDefinition=" + propertiesDefinition +
+ ", version=" + version +
+ ", versionName='" + versionName + '\'' +
+ ", category=" + category +
+ ", guid='" + guid + '\'' +
+ ", name='" + name + '\'' +
+ '}';
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/RelationshipEndDef.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/RelationshipEndDef.java b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/RelationshipEndDef.java
new file mode 100644
index 0000000..3ff3837
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/RelationshipEndDef.java
@@ -0,0 +1,193 @@
+/*
+ * 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.metadatacollection.properties.typedefs;
+
+
+/**
+ * RelationshipEndDef describes the type of the entity and the attribute information for one end of a RelationshipDef.
+ */
+public class RelationshipEndDef extends TypeDefElementHeader
+{
+ private TypeDefLink entityType = null;
+ private String attributeName = null;
+ private String attributeDescription = null;
+ private String attributeDescriptionGUID = null;
+ private AttributeCardinality attributeCardinality = AttributeCardinality.UNKNOWN;
+
+
+ /**
+ * Default constructor - create an empty end
+ */
+ public RelationshipEndDef()
+ {
+ super();
+ }
+
+
+ /**
+ * Copy/clone constructor - copy the supplied template into the new end.
+ *
+ * @param template - RelationshipEndDef
+ */
+ public RelationshipEndDef(RelationshipEndDef template)
+ {
+ super(template);
+
+ if (template != null)
+ {
+ entityType = template.getEntityType();
+ attributeName = template.getAttributeName();
+ attributeCardinality = template.getAttributeCardinality();
+ attributeDescription = template.getAttributeDescription();
+ }
+ }
+
+
+ /**
+ * Return the identifiers of the EntityDef describing the type of entity on this end of the relationship.
+ *
+ * @return TypeDefLink unique identifiers
+ */
+ public TypeDefLink getEntityType()
+ {
+ if (entityType == null)
+ {
+ return entityType;
+ }
+ else
+ {
+ return new TypeDefLink(entityType);
+ }
+ }
+
+
+ /**
+ * Set up the guid of the EntityDef describing the type of entity on this end of the relationship.
+ *
+ * @param entityType - TypeDefLink unique identifiers for the entity's type
+ */
+ public void setEntityType(TypeDefLink entityType)
+ {
+ this.entityType = entityType;
+ }
+
+
+ /**
+ * Return the attribute name used to describe this end of the relationship
+ *
+ * @return String name for the attribute
+ */
+ public String getAttributeName()
+ {
+ return attributeName;
+ }
+
+
+ /**
+ * Set up the attribute name used to describe this end of the relationship.
+ *
+ * @param attributeName - String name for the attribute
+ */
+ public void setAttributeName(String attributeName)
+ {
+ this.attributeName = attributeName;
+ }
+
+
+ /**
+ * Return the cardinality for this end of the relationship.
+ *
+ * @return AttributeCardinality Enum
+ */
+ public AttributeCardinality getAttributeCardinality()
+ {
+ return attributeCardinality;
+ }
+
+
+ /**
+ * Set up the cardinality for this end of the relationship.
+ *
+ * @param attributeCardinality - AttributeCardinality Enum
+ */
+ public void setAttributeCardinality(AttributeCardinality attributeCardinality)
+ {
+ this.attributeCardinality = attributeCardinality;
+ }
+
+
+ /**
+ * Return the attributeDescription of this end of the relationship.
+ *
+ * @return String attributeDescription
+ */
+ public String getAttributeDescription()
+ {
+ return attributeDescription;
+ }
+
+
+ /**
+ * Set up the attributeDescription for this end of the relationship.
+ *
+ * @param attributeDescription - String
+ */
+ public void setAttributeDescription(String attributeDescription)
+ {
+ this.attributeDescription = attributeDescription;
+ }
+
+
+ /**
+ * Return the unique identifier (guid) of the glossary term that describes this RelationshipEndDef.
+ *
+ * @return String guid
+ */
+ public String getAttributeDescriptionGUID()
+ {
+ return attributeDescriptionGUID;
+ }
+
+
+ /**
+ * Set up the unique identifier (guid) of the glossary term that describes this RelationshipEndDef.
+ *
+ * @param attributeDescriptionGUID - String guid
+ */
+ public void setAttributeDescriptionGUID(String attributeDescriptionGUID)
+ {
+ this.attributeDescriptionGUID = attributeDescriptionGUID;
+ }
+
+
+ /**
+ * Standard toString method.
+ *
+ * @return JSON style attributeDescription of variables.
+ */
+ @Override
+ public String toString()
+ {
+ return "RelationshipEndDef{" +
+ "entityType='" + entityType + '\'' +
+ ", attributeName='" + attributeName + '\'' +
+ ", attributeDescription='" + attributeDescription + '\'' +
+ ", attributeCardinality=" + attributeCardinality +
+ '}';
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/TypeDef.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/TypeDef.java b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/TypeDef.java
new file mode 100644
index 0000000..710f78d
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/TypeDef.java
@@ -0,0 +1,437 @@
+/*
+ * 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.metadatacollection.properties.typedefs;
+
+import org.apache.atlas.omrs.metadatacollection.properties.instances.InstanceStatus;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.Map;
+
+/**
+ * The TypeDef is the base class for objects that store the properties of an open metadata type
+ * definition (call ed a TypeDef).
+ * <p>
+ * The different categories of Typedefs are listed in TypeDefCategory.
+ */
+public abstract class TypeDef extends TypeDefSummary
+{
+ protected TypeDefLink superType = null;
+ protected String description = null;
+ protected String descriptionGUID = null;
+ protected String origin = null;
+ protected String createdBy = null;
+ protected String updatedBy = null;
+ protected Date createTime = null;
+ protected Date updateTime = null;
+ protected Map<String, String> options = null;
+ protected ArrayList<ExternalStandardMapping> externalStandardMappings = null;
+ protected ArrayList<InstanceStatus> validInstanceStatusList = null;
+ protected InstanceStatus initialStatus = null;
+ protected ArrayList<TypeDefAttribute> propertiesDefinition = null;
+
+
+ /**
+ * Minimal constructor is passed the category of the typedef being constructed.
+ * The rest of the properties are null.
+ *
+ * @param category - TypeDefCategory enum
+ */
+ public TypeDef(TypeDefCategory category)
+ {
+ super();
+ this.category = category;
+ }
+
+
+ /**
+ * Typical constructor is passed the properties of the typedef's super class being constructed.
+ *
+ * @param category - category of this TypeDef
+ * @param guid - unique id for the TypeDef
+ * @param name - unique name for the TypeDef
+ * @param version - active version number for the TypeDef
+ * @param versionName - unique name for the TypeDef
+ */
+ public TypeDef(TypeDefCategory category,
+ String guid,
+ String name,
+ long version,
+ String versionName)
+ {
+ super(category, guid, name, version, versionName);
+ }
+
+
+ /**
+ * Copy/clone constructor copies the values from the supplied template.
+ *
+ * @param template TypeDef
+ */
+ public TypeDef(TypeDef template)
+ {
+ super(template);
+
+ if (template != null)
+ {
+ this.superType = template.getSuperType();
+ this.description = template.getDescription();
+ this.descriptionGUID = template.getDescriptionGUID();
+ this.origin = template.getOrigin();
+ this.createdBy = template.getCreatedBy();
+ this.updatedBy = template.getUpdatedBy();
+ this.createTime = template.getCreateTime();
+ this.updateTime = template.getUpdateTime();
+ this.options = template.getOptions();
+ this.externalStandardMappings = template.getExternalStandardMappings();
+ this.validInstanceStatusList = template.getValidInstanceStatusList();
+ this.propertiesDefinition = template.getPropertiesDefinition();
+ }
+ }
+
+
+ /**
+ * Return the super type for the TypeDef (or null if top-level)
+ *
+ * @return TypeDefLink for the super type
+ */
+ public TypeDefLink getSuperType()
+ {
+ return superType;
+ }
+
+
+ /**
+ * Set up supertype for the TypeDef. Only single inheritance is supported. Use null if this type
+ * is top-level.
+ *
+ * @param superType TypeDefLink for the super type
+ */
+ public void setSuperType(TypeDefLink superType) { this.superType = superType; }
+
+
+ /**
+ * Return the description of this TypeDef.
+ *
+ * @return String description
+ */
+ public String getDescription()
+ {
+ return description;
+ }
+
+
+ /**
+ * Set up the description of this TypeDef.
+ *
+ * @param description String
+ */
+ public void setDescription(String description)
+ {
+ this.description = description;
+ }
+
+
+ /**
+ * Return the unique identifier (guid) of the glossary term that describes this TypeDef.
+ *
+ * @return String guid
+ */
+ public String getDescriptionGUID()
+ {
+ return descriptionGUID;
+ }
+
+
+ /**
+ * Set up the unique identifier (guid) of the glossary term that describes this TypeDef.
+ *
+ * @param descriptionGUID - String guid
+ */
+ public void setDescriptionGUID(String descriptionGUID)
+ {
+ this.descriptionGUID = descriptionGUID;
+ }
+
+
+ /**
+ * Return the unique identifier for metadata collection Id where this TypeDef came from.
+ *
+ * @return String guid
+ */
+ public String getOrigin()
+ {
+ return origin;
+ }
+
+
+ /**
+ * Set up the unique identifier for metadata collection Id where this TypeDef came from.
+ *
+ * @param origin - String guid
+ */
+ public void setOrigin(String origin)
+ {
+ this.origin = origin;
+ }
+
+
+ /**
+ * Return the user name of the person that created this TypeDef.
+ *
+ * @return String name
+ */
+ public String getCreatedBy()
+ {
+ return createdBy;
+ }
+
+
+ /**
+ * Set up the user name of the person that created this TypeDef.
+ *
+ * @param createdBy String name
+ */
+ public void setCreatedBy(String createdBy)
+ {
+ this.createdBy = createdBy;
+ }
+
+
+ /**
+ * Return the user name of the person that last updated this TypeDef.
+ *
+ * @return String name
+ */
+ public String getUpdatedBy()
+ {
+ return updatedBy;
+ }
+
+
+ /**
+ * Set up the user name of the person that last updated this TypeDef.
+ *
+ * @param updatedBy String name
+ */
+ public void setUpdatedBy(String updatedBy)
+ {
+ this.updatedBy = updatedBy;
+ }
+
+
+ /**
+ * Return the date/time that this TypeDef was created.
+ *
+ * @return Date
+ */
+ public Date getCreateTime()
+ {
+ return createTime;
+ }
+
+
+ /**
+ * Set up the date/time that this TypeDef was created.
+ *
+ * @param createTime Date
+ */
+ public void setCreateTime(Date createTime)
+ {
+ this.createTime = createTime;
+ }
+
+
+ /**
+ * Return the date/time that this TypeDef was last updated.
+ *
+ * @return Date
+ */
+ public Date getUpdateTime()
+ {
+ return updateTime;
+ }
+
+
+ /**
+ * Set up the date/time that this TypeDef was last updated.
+ *
+ * @param updateTime Date
+ */
+ public void setUpdateTime(Date updateTime)
+ {
+ this.updateTime = updateTime;
+ }
+
+
+ /**
+ * Return the options for this TypeDef. These are private properties used by the processors of this TypeDef
+ * and ignored by the OMRS.
+ *
+ * @return Map from String to String
+ */
+ public Map<String, String> getOptions()
+ {
+ return options;
+ }
+
+
+ /**
+ * Set up the options for this TypeDef. These are private properties used by the processors of this TypeDef
+ * and ignored by the OMRS.
+ *
+ * @param options - Map from String to String
+ */
+ public void setOptions(Map<String, String> options)
+ {
+ this.options = options;
+ }
+
+
+ /**
+ * Return the list of mappings to external standards.
+ *
+ * @return ExternalStandardMappings list
+ */
+ public ArrayList<ExternalStandardMapping> getExternalStandardMappings()
+ {
+ if (externalStandardMappings == null)
+ {
+ return externalStandardMappings;
+ }
+ else
+ {
+ return new ArrayList<>(externalStandardMappings);
+ }
+ }
+
+
+ /**
+ * Set up the list of mappings to external standards.
+ *
+ * @param externalStandardMappings - ExternalStandardMappings list
+ */
+ public void setExternalStandardMappings(ArrayList<ExternalStandardMapping> externalStandardMappings)
+ {
+ this.externalStandardMappings = externalStandardMappings;
+ }
+
+
+ /**
+ * Return the list of valid instance statuses supported by this TypeDef.
+ *
+ * @return InstanceStatus array of supported status values.
+ */
+ public ArrayList<InstanceStatus> getValidInstanceStatusList()
+ {
+ return validInstanceStatusList;
+ }
+
+
+ /**
+ * Set up the list of valid instance statuses supported by this TypeDef.
+ *
+ * @param validInstanceStatusList - InstanceStatus Array
+ */
+ public void setValidInstanceStatusList(ArrayList<InstanceStatus> validInstanceStatusList)
+ {
+ this.validInstanceStatusList = validInstanceStatusList;
+ }
+
+
+ /**
+ * Return the initial status setting for an instance of this type.
+ *
+ * @return InstanceStatus enum
+ */
+ public InstanceStatus getInitialStatus()
+ {
+ return initialStatus;
+ }
+
+
+ /**
+ * Set up the initial status setting for an instance of this type.
+ *
+ * @param initialStatus - InstanceStatus enum
+ */
+ public void setInitialStatus(InstanceStatus initialStatus)
+ {
+ this.initialStatus = initialStatus;
+ }
+
+
+ /**
+ * Return the list of AttributeDefs that define the valid properties for this type of classification.
+ *
+ * @return AttributeDefs list
+ */
+ public ArrayList<TypeDefAttribute> getPropertiesDefinition()
+ {
+ if(propertiesDefinition == null)
+ {
+ return propertiesDefinition;
+ }
+ else
+ {
+ return new ArrayList<>(propertiesDefinition);
+ }
+ }
+
+
+ /**
+ * Set up the list of AttributeDefs that define the valid properties for this type of classification.
+ *
+ * @param propertiesDefinition - AttributeDefs list
+ */
+ public void setPropertiesDefinition(ArrayList<TypeDefAttribute> propertiesDefinition)
+ {
+ this.propertiesDefinition = propertiesDefinition;
+ }
+
+
+ /**
+ * Standard toString method.
+ *
+ * @return JSON style description of variables.
+ */
+ @Override
+ public String toString()
+ {
+ return "TypeDef{" +
+ "superType=" + superType +
+ ", description='" + description + '\'' +
+ ", descriptionGUID='" + descriptionGUID + '\'' +
+ ", origin='" + origin + '\'' +
+ ", createdBy='" + createdBy + '\'' +
+ ", updatedBy='" + updatedBy + '\'' +
+ ", createTime=" + createTime +
+ ", updateTime=" + updateTime +
+ ", options=" + options +
+ ", externalStandardMappings=" + externalStandardMappings +
+ ", validInstanceStatusList=" + validInstanceStatusList +
+ ", initialStatus=" + initialStatus +
+ ", propertiesDefinition=" + propertiesDefinition +
+ ", version=" + version +
+ ", versionName='" + versionName + '\'' +
+ ", category=" + category +
+ ", guid='" + guid + '\'' +
+ ", name='" + name + '\'' +
+ '}';
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/TypeDefAttribute.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/TypeDefAttribute.java b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/TypeDefAttribute.java
new file mode 100644
index 0000000..36c4b24
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/TypeDefAttribute.java
@@ -0,0 +1,310 @@
+/*
+ * 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.metadatacollection.properties.typedefs;
+
+
+import java.util.ArrayList;
+
+/**
+ * TypeDefAttribute stores the properties used to describe a attribute within a Classification,
+ * Entity or Relationship. The attribute may itself be of types Enum, Collection or Primitive Types.
+ */
+public class TypeDefAttribute extends TypeDefElementHeader
+{
+ protected String attributeName = null;
+ protected AttributeTypeDef attributeType = null;
+ protected String attributeDescription = null;
+ protected String attributeDescriptionGUID = null;
+ protected AttributeCardinality cardinality = AttributeCardinality.UNKNOWN;
+ protected int valuesMinCount = 0;
+ protected int valuesMaxCount = 1;
+ protected boolean isIndexable = true;
+ protected boolean isUnique = false;
+ protected String defaultValue = null;
+ protected ArrayList<ExternalStandardMapping> externalStandardMappings = null;
+
+
+ /**
+ * Default constructor creates an empty TypeDefAttribute.
+ */
+ public TypeDefAttribute()
+ {
+ super();
+ }
+
+
+ /**
+ * Copy/clone constructor initialized with the values from the supplied template.
+ *
+ * @param template - TypeDefAttribute to copy
+ */
+ public TypeDefAttribute(TypeDefAttribute template)
+ {
+ super(template);
+
+ if (template != null)
+ {
+ attributeName = template.getAttributeName();
+ attributeType = template.getAttributeType();
+ attributeDescription = template.getAttributeDescription();
+ attributeDescriptionGUID = template.getAttributeDescriptionGUID();
+ cardinality = template.getAttributeCardinality();
+ valuesMinCount = template.getValuesMinCount();
+ valuesMaxCount = template.getValuesMaxCount();
+ isUnique = template.isUnique();
+ isIndexable = template.isIndexable();
+ defaultValue = template.getDefaultValue();
+ externalStandardMappings = template.getExternalStandardMappings();
+ }
+ }
+
+
+ /**
+ * Return the name of this attribute.
+ *
+ * @return String name
+ */
+ public String getAttributeName()
+ {
+ return attributeName;
+ }
+
+
+ /**
+ * Set up the name of this attribute.
+ *
+ * @param attributeName - String name
+ */
+ public void setAttributeName(String attributeName)
+ {
+ this.attributeName = attributeName;
+ }
+
+
+ /**
+ * Return the name of the type for the value in this attribute.
+ *
+ * @return AttributeTypeDef - definition of attribute type
+ */
+ public AttributeTypeDef getAttributeType() { return attributeType; }
+
+
+ /**
+ * Set up the name of the type for the value in this attribute.
+ *
+ * @param attributeType AttributeTypeDef
+ */
+ public void setAttributeType(AttributeTypeDef attributeType) { this.attributeType = attributeType; }
+
+
+ /**
+ * Return the short description of the attribute.
+ *
+ * @return String description
+ */
+ public String getAttributeDescription()
+ {
+ return attributeDescription;
+ }
+
+
+ /**
+ * Set up the short description of the attribute.
+ *
+ * @param attributeDescription - String description
+ */
+ public void setAttributeDescription(String attributeDescription)
+ {
+ this.attributeDescription = attributeDescription;
+ }
+
+
+ /**
+ * Return the unique id of the glossary term that describes this attribute (or null if
+ * no attribute defined).
+ *
+ * @return String guid
+ */
+ public String getAttributeDescriptionGUID()
+ {
+ return attributeDescriptionGUID;
+ }
+
+
+ /**
+ * Set up the unique id of the glossary term that describes this attribute (or null if
+ * no attribute defined).
+ *
+ * @param attributeDescriptionGUID - String guid
+ */
+ public void setAttributeDescriptionGUID(String attributeDescriptionGUID)
+ {
+ this.attributeDescriptionGUID = attributeDescriptionGUID;
+ }
+
+
+ /**
+ * Return the cardinality of this attribute.
+ *
+ * @return AttributeCardinality Enum.
+ */
+ public AttributeCardinality getAttributeCardinality() { return cardinality; }
+
+
+ /**
+ * Set up the cardinality for this attribute.
+ *
+ * @param attributeCardinality enum value
+ */
+ public void setAttributeCardinality(AttributeCardinality attributeCardinality) { this.cardinality = attributeCardinality; }
+
+
+ /**
+ * Return the minimum number of values for this attribute (relevant for Arrays, Sets and Maps).
+ *
+ * @return int minimum count
+ */
+ public int getValuesMinCount() { return valuesMinCount; }
+
+
+ /**
+ * Set up the minimum number of values for this attribute (relevant for Arrays, Sets and Maps).
+ *
+ * @param valuesMinCount int minimum count
+ */
+ public void setValuesMinCount(int valuesMinCount) { this.valuesMinCount = valuesMinCount; }
+
+
+ /**
+ * Return the maximum number of values for this attribute (relevant for Arrays, Sets and Maps).
+ *
+ * @return int maximum count
+ */
+ public int getValuesMaxCount() { return valuesMaxCount; }
+
+
+ /**
+ * Set up the maximum number of values for this attribute (relevant for Arrays, Sets and Maps).
+ *
+ * @param valuesMaxCount int maximum count
+ */
+ public void setValuesMaxCount(int valuesMaxCount) { this.valuesMaxCount = valuesMaxCount; }
+
+
+ /**
+ * Return whether the value for this attribute is unique across the specific instances of Struct, Classification,
+ * Entity or Relationship types that this attribute included in.
+ *
+ * @return boolean isUnique flag
+ */
+ public boolean isUnique() { return isUnique; }
+
+
+ /**
+ * Set up the isUnique flag. This indicates whether the value for this attribute is unique
+ * across the specific instances of Struct, Classification,
+ * Entity or Relationship types that this attribute included in.
+ *
+ * @param unique boolean isUnique flag
+ */
+ public void setUnique(boolean unique) { isUnique = unique; }
+
+
+ /**
+ * Return whether this attribute should be included in the metadata collection's search index.
+ *
+ * @return boolean isIndexable flag
+ */
+ public boolean isIndexable() { return isIndexable; }
+
+
+ /**
+ * Set up the isIndexable flag. This indicates whether this attribute should be included in the
+ * metadata collection's search index.
+ *
+ * @param indexable boolean isIndexable flag
+ */
+ public void setIndexable(boolean indexable) { isIndexable = indexable; }
+
+
+ /**
+ * Return the default value for this attribute.
+ *
+ * @return String default value
+ */
+ public String getDefaultValue() { return defaultValue; }
+
+
+ /**
+ * Set up the default value for this attribute.
+ *
+ * @param defaultValue String
+ */
+ public void setDefaultValue(String defaultValue) { this.defaultValue = defaultValue; }
+
+
+ /**
+ * Return the list of mappings to external standards.
+ *
+ * @return ExternalStandardMappings list
+ */
+ public ArrayList<ExternalStandardMapping> getExternalStandardMappings()
+ {
+ if (externalStandardMappings == null)
+ {
+ return externalStandardMappings;
+ }
+ else
+ {
+ return new ArrayList<>(externalStandardMappings);
+ }
+ }
+
+
+ /**
+ * Set up the list of mappings to external standards.
+ *
+ * @param externalStandardMappings - ExternalStandardMappings list
+ */
+ public void setExternalStandardMappings(ArrayList<ExternalStandardMapping> externalStandardMappings)
+ {
+ this.externalStandardMappings = externalStandardMappings;
+ }
+
+
+ /**
+ * Standard toString method.
+ *
+ * @return JSON style description of variables.
+ */
+ @Override
+ public String toString()
+ {
+ return "TypeDefAttribute{" +
+ "attributeName='" + attributeName + '\'' +
+ ", attributeType=" + attributeType +
+ ", cardinality=" + cardinality +
+ ", valuesMinCount=" + valuesMinCount +
+ ", valuesMaxCount=" + valuesMaxCount +
+ ", isIndexable=" + isIndexable +
+ ", isUnique=" + isUnique +
+ ", defaultValue='" + defaultValue + '\'' +
+ ", externalStandardMappings=" + externalStandardMappings +
+ '}';
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/TypeDefCategory.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/TypeDefCategory.java b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/TypeDefCategory.java
new file mode 100644
index 0000000..1cd3b71
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/TypeDefCategory.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.metadatacollection.properties.typedefs;
+
+import java.io.Serializable;
+
+/**
+ * The TypeDefCategory defines the list of valid types of TypeDef for open metadata instances.
+ */
+public enum TypeDefCategory implements Serializable
+{
+ UNKNOWN_DEF (0, "<Unknown>", "Uninitialized TypeDef object."),
+ CLASSIFICATION_DEF (5, "ClassificationDef", "A description of a specific characteristic or grouping for entities."),
+ ENTITY_DEF (6, "EntityDef", "An object or concept of interest."),
+ RELATIONSHIP_DEF (8, "RelationshipDef", "A link between two entities.");
+
+ private static final long serialVersionUID = 1L;
+
+ private int typeCode;
+ private String typeName;
+ private String typeDescription;
+
+
+ /**
+ * Constructor to set up a single instances of the enum.
+ */
+ TypeDefCategory(int typeCode, String typeName, String typeDescription)
+ {
+ /*
+ * Save the values supplied
+ */
+ this.typeCode = typeCode;
+ this.typeName = typeName;
+ this.typeDescription = typeDescription;
+ }
+
+
+ /**
+ * Return the code for this enum instance
+ *
+ * @return int - type code
+ */
+ public int getTypeCode()
+ {
+ return typeCode;
+ }
+
+
+ /**
+ * Return the default name for this enum instance.
+ *
+ * @return String - default name
+ */
+ public String getTypeName()
+ {
+ return typeName;
+ }
+
+
+ /**
+ * Return the default description for the type for this enum instance.
+ *
+ * @return String - default description
+ */
+ public String getTypeDescription()
+ {
+ return typeDescription;
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/TypeDefElementHeader.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/TypeDefElementHeader.java b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/TypeDefElementHeader.java
new file mode 100644
index 0000000..6323bbf
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/TypeDefElementHeader.java
@@ -0,0 +1,51 @@
+/*
+ * 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.metadatacollection.properties.typedefs;
+
+import java.io.Serializable;
+
+/**
+ * TypeDefElementHeader provides a common base for all typedef information.
+ */
+public class TypeDefElementHeader implements Serializable
+{
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Default constructor sets TypeDef to nulls.
+ */
+ public TypeDefElementHeader()
+ {
+ /*
+ * Nothing to do
+ */
+ }
+
+
+ /**
+ * Copy/clone constructor set TypeDef to value in template.
+ *
+ * @param template - TypeDefElementHeader
+ */
+ public TypeDefElementHeader(TypeDefElementHeader template)
+ {
+ /*
+ * Nothing to do
+ */
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/TypeDefGallery.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/TypeDefGallery.java b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/TypeDefGallery.java
new file mode 100644
index 0000000..a29c57c
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/TypeDefGallery.java
@@ -0,0 +1,121 @@
+/*
+ * 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.metadatacollection.properties.typedefs;
+
+import java.util.ArrayList;
+
+/**
+ * TypeDefGallery contains details of the AttributeTypeDefs and full TypeDefs supported by a rep
+ */
+public class TypeDefGallery
+{
+ private ArrayList<AttributeTypeDef> attributeTypeDefs = null;
+ private ArrayList<TypeDef> typeDefs = null;
+
+
+ /**
+ * Default constructor
+ */
+ public TypeDefGallery()
+ {
+ }
+
+
+ /**
+ * Copy/clone constructor
+ *
+ * @param template - template to copy
+ */
+ public TypeDefGallery(TypeDefGallery template)
+ {
+ if (template != null)
+ {
+ ArrayList<AttributeTypeDef> templateAttributeTypeDefs = template.getAttributeTypeDefs();
+ ArrayList<TypeDef> templateTypeDefs = template.getTypeDefs();
+
+ if (templateAttributeTypeDefs != null)
+ {
+ attributeTypeDefs = new ArrayList<>(templateAttributeTypeDefs);
+ }
+
+ if (templateTypeDefs != null)
+ {
+ typeDefs = new ArrayList<>(templateTypeDefs);
+ }
+ }
+ }
+
+
+ /**
+ * Return the list of attribute type definitions from the gallery.
+ *
+ * @return list of attribute type definitions
+ */
+ public ArrayList<AttributeTypeDef> getAttributeTypeDefs()
+ {
+ if (attributeTypeDefs == null)
+ {
+ return attributeTypeDefs;
+ }
+ else
+ {
+ return new ArrayList<>(attributeTypeDefs);
+ }
+ }
+
+
+ /**
+ * Set up the list of attribute type definitions from the gallery.
+ *
+ * @param attributeTypeDefs - list of attribute type definitions
+ */
+ public void setAttributeTypeDefs(ArrayList<AttributeTypeDef> attributeTypeDefs)
+ {
+ this.attributeTypeDefs = attributeTypeDefs;
+ }
+
+
+ /**
+ * Return the list of type definitions from the gallery.
+ *
+ * @return list of type definitions
+ */
+ public ArrayList<TypeDef> getTypeDefs()
+ {
+ if (typeDefs == null)
+ {
+ return typeDefs;
+ }
+ else
+ {
+ return new ArrayList<>(typeDefs);
+ }
+ }
+
+
+ /**
+ * Set up the list of type definitions from the gallery.
+ *
+ * @param typeDefs - list of type definitions
+ */
+ public void setTypeDefs(ArrayList<TypeDef> typeDefs)
+ {
+ this.typeDefs = typeDefs;
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/TypeDefLink.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/TypeDefLink.java b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/TypeDefLink.java
new file mode 100644
index 0000000..83b63ed
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/typedefs/TypeDefLink.java
@@ -0,0 +1,175 @@
+/*
+ * 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.metadatacollection.properties.typedefs;
+
+
+import java.util.Objects;
+
+/**
+ * The TypeDefHolds holds basic identifying information used to link one TypeDef to another. It is used in
+ * the definition of types - ie in the TypeDefs themselves. Examples include linking a classification to an
+ * entity, identifying super types and defining the entities at either end of a relationship.
+ * <p>
+ * TypeDefs are identified using both the guid and the type name. Both should be unique and most processing is
+ * with the type name because that is easiest for people to work with. The guid provides a means to check the
+ * identity of the types since it is easy to introduce two types with the same name in the distributed model.
+ * </p>
+ */
+public class TypeDefLink extends TypeDefElementHeader
+{
+ protected String guid = null;
+ protected String name = null;
+
+
+ /**
+ * Default constructor
+ */
+ public TypeDefLink()
+ {
+ super();
+ }
+
+
+ /**
+ * Typical constructor is passed the unique identifier and name of the typedef being constructed.
+ *
+ * @param guid - unique id for the TypeDef
+ * @param name - unique name for the TypeDef
+ */
+ public TypeDefLink(String guid,
+ String name)
+ {
+ super();
+
+ this.guid = guid;
+ this.name = name;
+ }
+
+
+ /**
+ * Copy/clone constructor copies the values from the supplied template.
+ *
+ * @param template TypeDefSummary
+ */
+ public TypeDefLink(TypeDefLink template)
+ {
+ super(template);
+
+ if (template != null)
+ {
+ this.guid = template.getGUID();
+ this.name = template.getName();
+ }
+ }
+
+
+ /**
+ * Return the unique identifier for this TypeDef.
+ *
+ * @return String guid
+ */
+ public String getGUID() {
+ return guid;
+ }
+
+
+ /**
+ * Set up the unique identifier for this TypeDef.
+ *
+ * @param guid - String guid
+ */
+ public void setGUID(String guid)
+ {
+ this.guid = guid;
+ }
+
+
+ /**
+ * Return the type name for this TypeDef. In simple environments, the type name is unique but where metadata
+ * repositories from different vendors are in operation it is possible that 2 types may have a name clash. The
+ * GUID is the reliable unique identifier.
+ *
+ * @return String name
+ */
+ public String getName() {
+ return name;
+ }
+
+
+ /**
+ * Set up the type name for this TypeDef. In simple environments, the type name is unique but where metadata
+ * repositories from different vendors are in operation it is possible that 2 types may have a name clash. The
+ * GUID is the reliable unique identifier.
+ *
+ * @param name - String name
+ */
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+
+ /**
+ * Standard toString method.
+ *
+ * @return JSON style description of variables.
+ */
+ @Override
+ public String toString()
+ {
+ return "TypeDefSummary{" +
+ ", guid='" + guid + '\'' +
+ ", name='" + name + '\'' +
+ '}';
+ }
+
+
+ /**
+ * Validated that the GUID, name and version number of a TypeDef are equal.
+ *
+ *
+ * @param object to test
+ * @return boolean flag to say object is the same TypeDefSummary
+ */
+ @Override
+ public boolean equals(Object object)
+ {
+ if (this == object)
+ {
+ return true;
+ }
+ if (object == null || getClass() != object.getClass())
+ {
+ return false;
+ }
+ TypeDefLink that = (TypeDefLink) object;
+ return Objects.equals(guid, that.guid) &&
+ Objects.equals(name, that.name);
+ }
+
+ /**
+ * Using the GUID as a hashcode - it should be unique if all connected metadata repositories are behaving properly.
+ *
+ * @return int hash code
+ */
+ @Override
+ public int hashCode()
+ {
+ return guid != null ? guid.hashCode() : 0;
+ }
+}
[21/30] atlas git commit: ATLAS-2246: OMRS Connector API plus REST
and IGC Connector skeleton - 15th February 2018
Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/OMRSEventPublisher.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/OMRSEventPublisher.java b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/OMRSEventPublisher.java
new file mode 100644
index 0000000..14a8e69
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/OMRSEventPublisher.java
@@ -0,0 +1,1972 @@
+/*
+ * 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.ocf.properties.Connection;
+import org.apache.atlas.omrs.admin.properties.OpenMetadataEventProtocolVersion;
+import org.apache.atlas.omrs.auditlog.*;
+import org.apache.atlas.omrs.eventmanagement.events.*;
+import org.apache.atlas.omrs.ffdc.OMRSErrorCode;
+import org.apache.atlas.omrs.ffdc.exception.OMRSLogicErrorException;
+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.AttributeTypeDef;
+import org.apache.atlas.omrs.metadatacollection.properties.typedefs.TypeDef;
+import org.apache.atlas.omrs.metadatacollection.properties.typedefs.TypeDefPatch;
+import org.apache.atlas.omrs.metadatacollection.properties.typedefs.TypeDefSummary;
+import org.apache.atlas.omrs.topicconnectors.OMRSTopicConnector;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.Date;
+
+
+/**
+ * OMRSEventPublisher publishes OMRS Events to the supplied OMRSTopicConnector.
+ */
+public class OMRSEventPublisher implements OMRSRegistryEventProcessor, OMRSTypeDefEventProcessor, OMRSInstanceEventProcessor
+{
+ private static final OMRSAuditLog auditLog = new OMRSAuditLog(OMRSAuditingComponent.EVENT_PUBLISHER);
+
+ private static final Logger log = LoggerFactory.getLogger(OMRSEventPublisher.class);
+
+ private String publisherName = null;
+ private OMRSTopicConnector omrsTopicConnector = null;
+ private OpenMetadataEventProtocolVersion eventProtocolVersion = null;
+
+
+ /**
+ * Typical constructor sets up the local metadata collection id for events.
+ *
+ * @param publisherName - name of the cohort (or enterprise virtual repository) that this event publisher
+ * is sending events to.
+ * @param localProtocolVersion - protocol versionName to use
+ * @param topicConnector - OMRS Topic to send requests on
+ */
+ public OMRSEventPublisher(String publisherName,
+ OpenMetadataEventProtocolVersion localProtocolVersion,
+ OMRSTopicConnector topicConnector)
+ {
+ String actionDescription = "Initialize event publisher";
+
+ /*
+ * Save the publisherName and protocol versionName
+ */
+ this.eventProtocolVersion = localProtocolVersion;
+ this.publisherName = publisherName;
+
+ /*
+ * The topic connector is needed to publish events.
+ */
+ if (topicConnector == null)
+ {
+ if (log.isDebugEnabled())
+ {
+ log.debug("Null topic connector");
+ }
+
+ OMRSErrorCode errorCode = OMRSErrorCode.NULL_TOPIC_CONNECTOR;
+ String errorMessage = errorCode.getErrorMessageId()
+ + errorCode.getFormattedErrorMessage(publisherName);
+
+ throw new OMRSLogicErrorException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ actionDescription,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+
+ }
+
+ this.omrsTopicConnector = topicConnector;
+
+
+ if (log.isDebugEnabled())
+ {
+ log.debug("New Event Publisher: " + publisherName);
+ }
+ }
+
+
+ /**
+ * Send the registry event to the OMRS Topic connector and manage errors
+ *
+ * @param registryEvent - properties of the event to send
+ * @return boolean flag to report if the call succeeded or not.
+ */
+ private boolean sendRegistryEvent(OMRSRegistryEvent registryEvent)
+ {
+ String actionDescription = "Send Registry Event";
+ boolean successFlag = false;
+
+ if (log.isDebugEnabled())
+ {
+ log.debug("Sending registryEvent for cohort: " + publisherName);
+ log.debug("topicConnector: " + omrsTopicConnector);
+ log.debug("registryEvent: " + registryEvent);
+ log.debug("localEventOriginator: " + registryEvent.getEventOriginator());
+ }
+
+ try
+ {
+ if (eventProtocolVersion == OpenMetadataEventProtocolVersion.V1)
+ {
+ omrsTopicConnector.sendEvent(registryEvent.getOMRSEventV1());
+ successFlag = true;
+ }
+ }
+ catch (Throwable error)
+ {
+ OMRSAuditCode auditCode = OMRSAuditCode.SEND_REGISTRY_EVENT_ERROR;
+
+ auditLog.logException(actionDescription,
+ auditCode.getLogMessageId(),
+ auditCode.getSeverity(),
+ auditCode.getFormattedLogMessage(publisherName),
+ "registryEvent : " + registryEvent.toString(),
+ auditCode.getSystemAction(),
+ auditCode.getUserAction(),
+ error);
+
+ if (log.isDebugEnabled())
+ {
+ log.debug("Exception: ", error, registryEvent);
+ }
+ }
+
+ return successFlag;
+ }
+
+
+ /**
+ * Send the TypeDef event to the OMRS Topic connector (providing TypeDef Events are enabled).
+ *
+ * @param typeDefEvent - properties of the event to send
+ * @return boolean flag to report if the call succeeded or not.
+ */
+ private boolean sendTypeDefEvent(OMRSTypeDefEvent typeDefEvent)
+ {
+ String actionDescription = "Send TypeDef Event";
+ boolean successFlag = false;
+
+ if (log.isDebugEnabled())
+ {
+ log.debug("Sending typeDefEvent for cohort: " + publisherName);
+ log.debug("topicConnector: ", omrsTopicConnector);
+ log.debug("typeDefEvent: ", typeDefEvent);
+ log.debug("localEventOriginator: ", typeDefEvent.getEventOriginator());
+ }
+
+ try
+ {
+ if (eventProtocolVersion == OpenMetadataEventProtocolVersion.V1)
+ {
+ omrsTopicConnector.sendEvent(typeDefEvent.getOMRSEventV1());
+ successFlag = true;
+ }
+ }
+ catch (Throwable error)
+ {
+ OMRSAuditCode auditCode = OMRSAuditCode.SEND_TYPEDEF_EVENT_ERROR;
+
+ auditLog.logException(actionDescription,
+ auditCode.getLogMessageId(),
+ auditCode.getSeverity(),
+ auditCode.getFormattedLogMessage(publisherName),
+ "typeDefEvent {" + typeDefEvent.toString() + "}",
+ auditCode.getSystemAction(),
+ auditCode.getUserAction(),
+ error);
+
+ if (log.isDebugEnabled())
+ {
+ log.debug("Exception: ", error);
+ }
+ }
+
+ return successFlag;
+ }
+
+
+ /**
+ * Set the instance event to the OMRS Topic connector if the instance
+ * event is of the permitted type.
+ *
+ * @param instanceEvent - properties of the event to send
+ * @return boolean flag to report if the call succeeded or not.
+ * */
+ private boolean sendInstanceEvent(OMRSInstanceEvent instanceEvent)
+ {
+ String actionDescription = "Send Instance Event";
+ boolean successFlag = false;
+
+ if (log.isDebugEnabled())
+ {
+ log.debug("Sending instanceEvent for cohort: " + publisherName);
+ log.debug("topicConnector: ", omrsTopicConnector);
+ log.debug("instanceEvent: ", instanceEvent);
+ log.debug("localEventOriginator: ", instanceEvent.getEventOriginator());
+ }
+
+ try
+ {
+ if (eventProtocolVersion == OpenMetadataEventProtocolVersion.V1)
+ {
+ omrsTopicConnector.sendEvent(instanceEvent.getOMRSEventV1());
+ successFlag = true;
+ }
+ }
+ catch (Throwable error)
+ {
+ OMRSAuditCode auditCode = OMRSAuditCode.SEND_INSTANCE_EVENT_ERROR;
+
+ auditLog.logException(actionDescription,
+ auditCode.getLogMessageId(),
+ auditCode.getSeverity(),
+ auditCode.getFormattedLogMessage(publisherName),
+ "instanceEvent {" + instanceEvent.toString() + "}",
+ auditCode.getSystemAction(),
+ auditCode.getUserAction(),
+ error);
+
+ if (log.isDebugEnabled())
+ {
+ log.debug("Exception: ", error);
+ }
+ }
+
+ return successFlag;
+ }
+
+
+ /**
+ * Introduces the local server/repository to the metadata repository cohort.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param metadataCollectionId - unique identifier for the metadata collection that is registering with the cohort.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param registrationTimestamp - the time that the server/repository issued the registration request.
+ * @param remoteConnection - the Connection properties for the connector used to call the registering server.
+ * @param typeDefList - the list of TypeDefs supported by the registering server/repository.
+ */
+ public boolean processRegistrationEvent(String sourceName,
+ String metadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ Date registrationTimestamp,
+ Connection remoteConnection,
+ ArrayList<TypeDefSummary> typeDefList)
+ {
+ OMRSEventOriginator eventOriginator = new OMRSEventOriginator();
+
+ eventOriginator.setMetadataCollectionId(metadataCollectionId);
+ eventOriginator.setServerName(originatorServerName);
+ eventOriginator.setServerType(originatorServerType);
+ eventOriginator.setOrganizationName(originatorOrganizationName);
+
+ OMRSRegistryEvent registryEvent = new OMRSRegistryEvent(OMRSRegistryEventType.REGISTRATION_EVENT,
+ registrationTimestamp,
+ remoteConnection,
+ typeDefList);
+
+ registryEvent.setEventOriginator(eventOriginator);
+
+ return sendRegistryEvent(registryEvent);
+ }
+
+
+ /**
+ * Requests that the other servers in the cohort send re-registration events.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ */
+ public boolean processRegistrationRefreshRequest(String sourceName,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName)
+ {
+ OMRSEventOriginator eventOriginator = new OMRSEventOriginator();
+
+ eventOriginator.setServerName(originatorServerName);
+ eventOriginator.setServerType(originatorServerType);
+ eventOriginator.setOrganizationName(originatorOrganizationName);
+
+ OMRSRegistryEvent registryEvent = new OMRSRegistryEvent(OMRSRegistryEventType.REFRESH_REGISTRATION_REQUEST);
+
+ registryEvent.setEventOriginator(eventOriginator);
+
+ return sendRegistryEvent(registryEvent);
+ }
+
+
+ /**
+ * Refreshes the other servers in the cohort with the local server's registration.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param metadataCollectionId - unique identifier for the metadata collection that is registering with the cohort.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param registrationTimestamp - the time that the server/repository first registered with the cohort.
+ * @param remoteConnection - the Connection properties for the connector used to call the registering server.
+ * @param typeDefList - the list of TypeDefs supported by the registering server/repository.
+ */
+ public boolean processReRegistrationEvent(String sourceName,
+ String metadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ Date registrationTimestamp,
+ Connection remoteConnection,
+ ArrayList<TypeDefSummary> typeDefList)
+ {
+ OMRSEventOriginator eventOriginator = new OMRSEventOriginator();
+
+ eventOriginator.setMetadataCollectionId(metadataCollectionId);
+ eventOriginator.setServerName(originatorServerName);
+ eventOriginator.setServerType(originatorServerType);
+ eventOriginator.setOrganizationName(originatorOrganizationName);
+
+ OMRSRegistryEvent registryEvent = new OMRSRegistryEvent(OMRSRegistryEventType.RE_REGISTRATION_EVENT,
+ registrationTimestamp,
+ remoteConnection,
+ typeDefList);
+
+ registryEvent.setEventOriginator(eventOriginator);
+
+ return sendRegistryEvent(registryEvent);
+ }
+
+
+ /**
+ * A server/repository is being removed from the metadata repository cohort.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param metadataCollectionId - unique identifier for the metadata collection that is registering with the cohort.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ */
+ public boolean processUnRegistrationEvent(String sourceName,
+ String metadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName)
+ {
+ OMRSEventOriginator eventOriginator = new OMRSEventOriginator();
+
+ eventOriginator.setMetadataCollectionId(metadataCollectionId);
+ eventOriginator.setServerName(originatorServerName);
+ eventOriginator.setServerType(originatorServerType);
+ eventOriginator.setOrganizationName(originatorOrganizationName);
+
+ OMRSRegistryEvent registryEvent = new OMRSRegistryEvent(OMRSRegistryEventType.UN_REGISTRATION_EVENT);
+
+ registryEvent.setEventOriginator(eventOriginator);
+
+ return sendRegistryEvent(registryEvent);
+ }
+
+
+ /**
+ * There is more than one member of the open metadata repository cohort that is using the same metadata
+ * collection Id. This means that their metadata instances can be updated in more than one server and there
+ * is a potential for data integrity issues.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param conflictingMetadataCollectionId - unique identifier for the remote metadata collection that is
+ * registering with the cohort.
+ * @param errorMessage - details of the conflict
+ */
+ public void processConflictingCollectionIdEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ String conflictingMetadataCollectionId,
+ String errorMessage)
+ {
+ OMRSEventOriginator eventOriginator = new OMRSEventOriginator();
+
+ eventOriginator.setMetadataCollectionId(originatorMetadataCollectionId);
+ eventOriginator.setServerName(originatorServerName);
+ eventOriginator.setServerType(originatorServerType);
+ eventOriginator.setOrganizationName(originatorOrganizationName);
+
+ OMRSRegistryEvent registryEvent = new OMRSRegistryEvent(OMRSRegistryEventErrorCode.CONFLICTING_COLLECTION_ID,
+ errorMessage,
+ conflictingMetadataCollectionId,
+ null);
+
+ registryEvent.setEventOriginator(eventOriginator);
+
+ sendRegistryEvent(registryEvent);
+ }
+
+
+ /**
+ * A connection to one of the members of the open metadata repository cohort is not usable by one of the members.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param targetMetadataCollectionId - Id for the repository with the bad remote connection.
+ * @param remoteConnection - the Connection properties for the connector used to call the registering server.
+ * @param errorMessage - details of the error that occurs when the connection is used.
+ */
+ public void processBadConnectionEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ String targetMetadataCollectionId,
+ Connection remoteConnection,
+ String errorMessage)
+ {
+ OMRSEventOriginator eventOriginator = new OMRSEventOriginator();
+
+ eventOriginator.setMetadataCollectionId(originatorMetadataCollectionId);
+ eventOriginator.setServerName(originatorServerName);
+ eventOriginator.setServerType(originatorServerType);
+ eventOriginator.setOrganizationName(originatorOrganizationName);
+
+ OMRSRegistryEvent registryEvent = new OMRSRegistryEvent(OMRSRegistryEventErrorCode.CONFLICTING_COLLECTION_ID,
+ errorMessage,
+ targetMetadataCollectionId,
+ remoteConnection);
+
+ registryEvent.setEventOriginator(eventOriginator);
+
+ sendRegistryEvent(registryEvent);
+ }
+
+
+ /**
+ * A new TypeDef has been defined.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param typeDef - details of the new TypeDef
+ */
+ public void processNewTypeDefEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ TypeDef typeDef)
+ {
+ OMRSEventOriginator eventOriginator = new OMRSEventOriginator();
+
+ eventOriginator.setMetadataCollectionId(originatorMetadataCollectionId);
+ eventOriginator.setServerName(originatorServerName);
+ eventOriginator.setServerType(originatorServerType);
+ eventOriginator.setOrganizationName(originatorOrganizationName);
+
+ OMRSTypeDefEvent typeDefEvent = new OMRSTypeDefEvent(OMRSTypeDefEventType.NEW_TYPEDEF_EVENT, typeDef);
+
+ typeDefEvent.setEventOriginator(eventOriginator);
+
+ this.sendTypeDefEvent(typeDefEvent);
+ }
+
+ /**
+ * A new AttributeTypeDef has been defined in an open metadata repository.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param attributeTypeDef - details of the new AttributeTypeDef.
+ */
+ public void processNewAttributeTypeDefEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ AttributeTypeDef attributeTypeDef)
+ {
+ OMRSEventOriginator eventOriginator = new OMRSEventOriginator();
+
+ eventOriginator.setMetadataCollectionId(originatorMetadataCollectionId);
+ eventOriginator.setServerName(originatorServerName);
+ eventOriginator.setServerType(originatorServerType);
+ eventOriginator.setOrganizationName(originatorOrganizationName);
+
+ OMRSTypeDefEvent typeDefEvent = new OMRSTypeDefEvent(OMRSTypeDefEventType.NEW_ATTRIBUTE_TYPEDEF_EVENT, attributeTypeDef);
+
+ typeDefEvent.setEventOriginator(eventOriginator);
+
+ this.sendTypeDefEvent(typeDefEvent);
+ }
+
+
+ /**
+ * An existing TypeDef has been updated.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param typeDefPatch - details of the new versionName of the TypeDef
+ */
+ public void processUpdatedTypeDefEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ TypeDefPatch typeDefPatch)
+ {
+ OMRSEventOriginator eventOriginator = new OMRSEventOriginator();
+
+ eventOriginator.setMetadataCollectionId(originatorMetadataCollectionId);
+ eventOriginator.setServerName(originatorServerName);
+ eventOriginator.setServerType(originatorServerType);
+ eventOriginator.setOrganizationName(originatorOrganizationName);
+
+ OMRSTypeDefEvent typeDefEvent = new OMRSTypeDefEvent(OMRSTypeDefEventType.UPDATED_TYPEDEF_EVENT, typeDefPatch);
+
+ typeDefEvent.setEventOriginator(eventOriginator);
+
+ this.sendTypeDefEvent(typeDefEvent);
+ }
+
+
+ /**
+ * An existing TypeDef has been deleted. Both the name and the GUID are provided to ensure the right TypeDef is
+ * deleted in remote repositories.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param typeDefGUID - unique identifier of the TypeDef
+ * @param typeDefName - unique name of the TypeDef
+ */
+ public void processDeletedTypeDefEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ String typeDefGUID,
+ String typeDefName)
+ {
+ OMRSEventOriginator eventOriginator = new OMRSEventOriginator();
+
+ eventOriginator.setMetadataCollectionId(originatorMetadataCollectionId);
+ eventOriginator.setServerName(originatorServerName);
+ eventOriginator.setServerType(originatorServerType);
+ eventOriginator.setOrganizationName(originatorOrganizationName);
+
+ OMRSTypeDefEvent typeDefEvent = new OMRSTypeDefEvent(OMRSTypeDefEventType.DELETED_TYPEDEF_EVENT,
+ typeDefGUID,
+ typeDefName);
+
+ typeDefEvent.setEventOriginator(eventOriginator);
+
+ this.sendTypeDefEvent(typeDefEvent);
+ }
+
+
+ /**
+ * An existing AttributeTypeDef has been deleted in an open metadata repository. Both the name and the
+ * GUID are provided to ensure the right AttributeTypeDef is deleted in other cohort member repositories.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param attributeTypeDefGUID - unique identifier of the AttributeTypeDef
+ * @param attributeTypeDefName - unique name of the AttributeTypeDef
+ */
+ public void processDeletedAttributeTypeDefEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ String attributeTypeDefGUID,
+ String attributeTypeDefName)
+ {
+ OMRSEventOriginator eventOriginator = new OMRSEventOriginator();
+
+ eventOriginator.setMetadataCollectionId(originatorMetadataCollectionId);
+ eventOriginator.setServerName(originatorServerName);
+ eventOriginator.setServerType(originatorServerType);
+ eventOriginator.setOrganizationName(originatorOrganizationName);
+
+ OMRSTypeDefEvent typeDefEvent = new OMRSTypeDefEvent(OMRSTypeDefEventType.DELETED_ATTRIBUTE_TYPEDEF_EVENT,
+ attributeTypeDefGUID,
+ attributeTypeDefName);
+
+ typeDefEvent.setEventOriginator(eventOriginator);
+
+ this.sendTypeDefEvent(typeDefEvent);
+ }
+
+
+ /**
+ * The guid or name of an existing TypeDef has been changed to a new value. This is used if two different
+ * Typedefs are discovered to have either the same guid or, most likely, the same name. This type of conflict
+ * is rare but typically occurs when a new repository joins the cohort.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param originalTypeDefSummary - the details for the original TypeDef.
+ * @param typeDef - updated TypeDef with new identifiers
+ */
+ public void processReIdentifiedTypeDefEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ TypeDefSummary originalTypeDefSummary,
+ TypeDef typeDef)
+ {
+ OMRSEventOriginator eventOriginator = new OMRSEventOriginator();
+
+ eventOriginator.setMetadataCollectionId(originatorMetadataCollectionId);
+ eventOriginator.setServerName(originatorServerName);
+ eventOriginator.setServerType(originatorServerType);
+ eventOriginator.setOrganizationName(originatorOrganizationName);
+
+
+ OMRSTypeDefEvent typeDefEvent = new OMRSTypeDefEvent(OMRSTypeDefEventType.RE_IDENTIFIED_TYPEDEF_EVENT,
+ originalTypeDefSummary,
+ typeDef);
+
+ typeDefEvent.setEventOriginator(eventOriginator);
+
+ this.sendTypeDefEvent(typeDefEvent);
+ }
+
+ /**
+ * Process an event that changes either the name or guid of an AttributeTypeDef.
+ * It is resolving a Conflicting AttributeTypeDef Error.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param originalAttributeTypeDef - description of original AttributeTypeDef
+ * @param attributeTypeDef - updated AttributeTypeDef with new identifiers inside.
+ */
+ public void processReIdentifiedAttributeTypeDefEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ AttributeTypeDef originalAttributeTypeDef,
+ AttributeTypeDef attributeTypeDef)
+ {
+ OMRSEventOriginator eventOriginator = new OMRSEventOriginator();
+
+ eventOriginator.setMetadataCollectionId(originatorMetadataCollectionId);
+ eventOriginator.setServerName(originatorServerName);
+ eventOriginator.setServerType(originatorServerType);
+ eventOriginator.setOrganizationName(originatorOrganizationName);
+
+
+ OMRSTypeDefEvent typeDefEvent = new OMRSTypeDefEvent(OMRSTypeDefEventType.RE_IDENTIFIED_ATTRIBUTE_TYPEDEF_EVENT,
+ originalAttributeTypeDef,
+ attributeTypeDef);
+
+ typeDefEvent.setEventOriginator(eventOriginator);
+
+ this.sendTypeDefEvent(typeDefEvent);
+ }
+
+
+ /**
+ * Process a detected conflict in type definitions (TypeDefs) used in the cohort.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param originatorTypeDefSummary - details of the TypeDef in the event originator
+ * @param otherMetadataCollectionId - the metadataCollection using the conflicting TypeDef
+ * @param conflictingTypeDefSummary - the details of the TypeDef in the other metadata collection
+ * @param errorMessage - details of the error that occurs when the connection is used.
+ */
+ public void processTypeDefConflictEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ TypeDefSummary originatorTypeDefSummary,
+ String otherMetadataCollectionId,
+ TypeDefSummary conflictingTypeDefSummary,
+ String errorMessage)
+
+ {
+ OMRSEventOriginator eventOriginator = new OMRSEventOriginator();
+
+ eventOriginator.setMetadataCollectionId(originatorMetadataCollectionId);
+ eventOriginator.setServerName(originatorServerName);
+ eventOriginator.setServerType(originatorServerType);
+ eventOriginator.setOrganizationName(originatorOrganizationName);
+
+ OMRSTypeDefEvent typeDefEvent = new OMRSTypeDefEvent(OMRSTypeDefEventErrorCode.CONFLICTING_TYPEDEFS,
+ errorMessage,
+ originatorMetadataCollectionId,
+ originatorTypeDefSummary,
+ conflictingTypeDefSummary);
+
+ typeDefEvent.setEventOriginator(eventOriginator);
+
+ this.sendTypeDefEvent(typeDefEvent);
+ }
+
+
+ /**
+ * Process a detected conflict in the attribute type definitions (AttributeTypeDefs) used in the cohort.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param originatorAttributeTypeDef- description of the AttributeTypeDef in the event originator.
+ * @param otherMetadataCollectionId - the metadataCollection using the conflicting AttributeTypeDef.
+ * @param conflictingAttributeTypeDef - description of the AttributeTypeDef in the other metadata collection.
+ * @param errorMessage - details of the error that occurs when the connection is used.
+ */
+ public void processAttributeTypeDefConflictEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ AttributeTypeDef originatorAttributeTypeDef,
+ String otherMetadataCollectionId,
+ AttributeTypeDef conflictingAttributeTypeDef,
+ String errorMessage)
+ {
+ OMRSEventOriginator eventOriginator = new OMRSEventOriginator();
+
+ eventOriginator.setMetadataCollectionId(originatorMetadataCollectionId);
+ eventOriginator.setServerName(originatorServerName);
+ eventOriginator.setServerType(originatorServerType);
+ eventOriginator.setOrganizationName(originatorOrganizationName);
+
+ OMRSTypeDefEvent typeDefEvent = new OMRSTypeDefEvent(OMRSTypeDefEventErrorCode.CONFLICTING_ATTRIBUTE_TYPEDEFS,
+ errorMessage,
+ originatorMetadataCollectionId,
+ originatorAttributeTypeDef,
+ conflictingAttributeTypeDef);
+
+ typeDefEvent.setEventOriginator(eventOriginator);
+
+ this.sendTypeDefEvent(typeDefEvent);
+ }
+
+
+ /**
+ * A TypeDef from another member in the cohort is at a different versionName than the local repository. This may
+ * create some inconsistencies in the different copies of instances of this type in different members of the
+ * cohort. The recommended action is to update all TypeDefs to the latest versionName.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param targetMetadataCollectionId - identifier of the metadata collection that is reporting a TypeDef at a
+ * different level to the local repository.
+ * @param targetTypeDefSummary - details of the TypeDef being patched
+ * @param otherTypeDef - details of the TypeDef in the local repository.
+ */
+ public void processTypeDefPatchMismatchEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ String targetMetadataCollectionId,
+ TypeDefSummary targetTypeDefSummary,
+ TypeDef otherTypeDef,
+ String errorMessage)
+ {
+ OMRSEventOriginator eventOriginator = new OMRSEventOriginator();
+
+ eventOriginator.setMetadataCollectionId(originatorMetadataCollectionId);
+ eventOriginator.setServerName(originatorServerName);
+ eventOriginator.setServerType(originatorServerType);
+ eventOriginator.setOrganizationName(originatorOrganizationName);
+
+
+
+ OMRSTypeDefEvent typeDefEvent = new OMRSTypeDefEvent(OMRSTypeDefEventErrorCode.TYPEDEF_PATCH_MISMATCH,
+ errorMessage,
+ targetMetadataCollectionId,
+ targetTypeDefSummary,
+ otherTypeDef);
+
+ typeDefEvent.setEventOriginator(eventOriginator);
+
+ this.sendTypeDefEvent(typeDefEvent);
+ }
+
+
+ /**
+ * A new entity has been created.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param entity - details of the new entity
+ */
+ public void processNewEntityEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ EntityDetail entity)
+ {
+ OMRSEventOriginator eventOriginator = new OMRSEventOriginator();
+
+ eventOriginator.setMetadataCollectionId(originatorMetadataCollectionId);
+ eventOriginator.setServerName(originatorServerName);
+ eventOriginator.setServerType(originatorServerType);
+ eventOriginator.setOrganizationName(originatorOrganizationName);
+
+ OMRSInstanceEvent instanceEvent = new OMRSInstanceEvent(OMRSInstanceEventType.NEW_ENTITY_EVENT,
+ entity);
+
+
+ instanceEvent.setEventOriginator(eventOriginator);
+
+ this.sendInstanceEvent(instanceEvent);
+ }
+
+
+ /**
+ * An existing entity has been updated.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param entity - details of the new versionName of the entity.
+ */
+ public void processUpdatedEntityEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ EntityDetail entity)
+ {
+ OMRSEventOriginator eventOriginator = new OMRSEventOriginator();
+
+ eventOriginator.setMetadataCollectionId(originatorMetadataCollectionId);
+ eventOriginator.setServerName(originatorServerName);
+ eventOriginator.setServerType(originatorServerType);
+ eventOriginator.setOrganizationName(originatorOrganizationName);
+
+ OMRSInstanceEvent instanceEvent = new OMRSInstanceEvent(OMRSInstanceEventType.UPDATED_ENTITY_EVENT,
+ entity);
+
+
+ instanceEvent.setEventOriginator(eventOriginator);
+
+ this.sendInstanceEvent(instanceEvent);
+ }
+
+
+ /**
+ * An update to an entity has been undone.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param entity - details of the versionName of the entity that has been restored.
+ */
+ public void processUndoneEntityEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ EntityDetail entity)
+ {
+ OMRSEventOriginator eventOriginator = new OMRSEventOriginator();
+
+ eventOriginator.setMetadataCollectionId(originatorMetadataCollectionId);
+ eventOriginator.setServerName(originatorServerName);
+ eventOriginator.setServerType(originatorServerType);
+ eventOriginator.setOrganizationName(originatorOrganizationName);
+
+ OMRSInstanceEvent instanceEvent = new OMRSInstanceEvent(OMRSInstanceEventType.UNDONE_ENTITY_EVENT,
+ entity);
+
+
+ instanceEvent.setEventOriginator(eventOriginator);
+
+ this.sendInstanceEvent(instanceEvent);
+ }
+
+
+ /**
+ * A new classification has been added to an entity.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param entity - details of the entity with the new classification added.
+ */
+ public void processClassifiedEntityEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ EntityDetail entity)
+ {
+ OMRSEventOriginator eventOriginator = new OMRSEventOriginator();
+
+ eventOriginator.setMetadataCollectionId(originatorMetadataCollectionId);
+ eventOriginator.setServerName(originatorServerName);
+ eventOriginator.setServerType(originatorServerType);
+ eventOriginator.setOrganizationName(originatorOrganizationName);
+
+ OMRSInstanceEvent instanceEvent = new OMRSInstanceEvent(OMRSInstanceEventType.CLASSIFIED_ENTITY_EVENT,
+ entity);
+
+
+ instanceEvent.setEventOriginator(eventOriginator);
+
+ this.sendInstanceEvent(instanceEvent);
+ }
+
+
+ /**
+ * A classification has been removed from an entity.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param entity - details of the entity after the classification has been removed.
+ */
+ public void processDeclassifiedEntityEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ EntityDetail entity)
+ {
+ OMRSEventOriginator eventOriginator = new OMRSEventOriginator();
+
+ eventOriginator.setMetadataCollectionId(originatorMetadataCollectionId);
+ eventOriginator.setServerName(originatorServerName);
+ eventOriginator.setServerType(originatorServerType);
+ eventOriginator.setOrganizationName(originatorOrganizationName);
+
+ OMRSInstanceEvent instanceEvent = new OMRSInstanceEvent(OMRSInstanceEventType.DECLASSIFIED_ENTITY_EVENT,
+ entity);
+
+
+ instanceEvent.setEventOriginator(eventOriginator);
+
+ this.sendInstanceEvent(instanceEvent);
+ }
+
+
+ /**
+ * An existing classification has been changed on an entity.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param entity - details of the entity after the classification has been changed.
+ */
+ public void processReclassifiedEntityEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ EntityDetail entity)
+ {
+ OMRSEventOriginator eventOriginator = new OMRSEventOriginator();
+
+ eventOriginator.setMetadataCollectionId(originatorMetadataCollectionId);
+ eventOriginator.setServerName(originatorServerName);
+ eventOriginator.setServerType(originatorServerType);
+ eventOriginator.setOrganizationName(originatorOrganizationName);
+
+ OMRSInstanceEvent instanceEvent = new OMRSInstanceEvent(OMRSInstanceEventType.RECLASSIFIED_ENTITY_EVENT,
+ entity);
+
+
+ instanceEvent.setEventOriginator(eventOriginator);
+
+ this.sendInstanceEvent(instanceEvent);
+ }
+
+
+ /**
+ * An existing entity has been deleted. This is a soft delete. This means it is still in the repository
+ * but it is no longer returned on queries.
+ *
+ * All relationships to the entity are also soft-deleted and will no longer be usable. These deleted relationships
+ * will be notified through separate events.
+ *
+ * Details of the TypeDef are included with the entity's unique id (guid) to ensure the right entity is deleted in
+ * the remote repositories.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param typeDefGUID - unique identifier for this entity's TypeDef
+ * @param typeDefName - name of this entity's TypeDef
+ * @param instanceGUID - unique identifier for the entity
+ */
+ public void processDeletedEntityEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ String typeDefGUID,
+ String typeDefName,
+ String instanceGUID)
+ {
+ OMRSEventOriginator eventOriginator = new OMRSEventOriginator();
+
+ eventOriginator.setMetadataCollectionId(originatorMetadataCollectionId);
+ eventOriginator.setServerName(originatorServerName);
+ eventOriginator.setServerType(originatorServerType);
+ eventOriginator.setOrganizationName(originatorOrganizationName);
+
+ OMRSInstanceEvent instanceEvent = new OMRSInstanceEvent(OMRSInstanceEventType.DELETED_ENTITY_EVENT,
+ typeDefGUID,
+ typeDefName,
+ instanceGUID);
+
+ instanceEvent.setEventOriginator(eventOriginator);
+
+ this.sendInstanceEvent(instanceEvent);
+ }
+
+
+ /**
+ * A deleted entity has been permanently removed from the repository. This request can not be undone.
+ *
+ * Details of the TypeDef are included with the entity's unique id (guid) to ensure the right entity is purged in
+ * the remote repositories.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param typeDefGUID - unique identifier for this entity's TypeDef
+ * @param typeDefName - name of this entity's TypeDef
+ * @param instanceGUID - unique identifier for the entity
+ */
+ public void processPurgedEntityEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ String typeDefGUID,
+ String typeDefName,
+ String instanceGUID)
+ {
+ OMRSEventOriginator eventOriginator = new OMRSEventOriginator();
+
+ eventOriginator.setMetadataCollectionId(originatorMetadataCollectionId);
+ eventOriginator.setServerName(originatorServerName);
+ eventOriginator.setServerType(originatorServerType);
+ eventOriginator.setOrganizationName(originatorOrganizationName);
+
+ OMRSInstanceEvent instanceEvent = new OMRSInstanceEvent(OMRSInstanceEventType.PURGED_ENTITY_EVENT,
+ typeDefGUID,
+ typeDefName,
+ instanceGUID);
+
+ instanceEvent.setEventOriginator(eventOriginator);
+
+ this.sendInstanceEvent(instanceEvent);
+ }
+
+
+ /**
+ * A deleted entity has been restored to the state it was before it was deleted.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param entity - details of the versionName of the entity that has been restored.
+ */
+ public void processRestoredEntityEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ EntityDetail entity)
+ {
+ OMRSEventOriginator eventOriginator = new OMRSEventOriginator();
+
+ eventOriginator.setMetadataCollectionId(originatorMetadataCollectionId);
+ eventOriginator.setServerName(originatorServerName);
+ eventOriginator.setServerType(originatorServerType);
+ eventOriginator.setOrganizationName(originatorOrganizationName);
+
+ OMRSInstanceEvent instanceEvent = new OMRSInstanceEvent(OMRSInstanceEventType.RESTORED_ENTITY_EVENT,
+ entity);
+
+
+ instanceEvent.setEventOriginator(eventOriginator);
+
+ this.sendInstanceEvent(instanceEvent);
+ }
+
+
+ /**
+ * The guid of an existing entity has been changed to a new value. This is used if two different
+ * entities are discovered to have the same guid. This is extremely unlikely but not impossible so
+ * the open metadata protocol has provision for this.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param originalEntityGUID - the existing identifier for the entity.
+ * @param entity - new values for this entity, including the new guid.
+ */
+ public void processReIdentifiedEntityEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ String originalEntityGUID,
+ EntityDetail entity)
+ {
+ OMRSEventOriginator eventOriginator = new OMRSEventOriginator();
+
+ eventOriginator.setMetadataCollectionId(originatorMetadataCollectionId);
+ eventOriginator.setServerName(originatorServerName);
+ eventOriginator.setServerType(originatorServerType);
+ eventOriginator.setOrganizationName(originatorOrganizationName);
+
+ OMRSInstanceEvent instanceEvent = new OMRSInstanceEvent(OMRSInstanceEventType.RE_IDENTIFIED_ENTITY_EVENT,
+ entity);
+
+ instanceEvent.setEventOriginator(eventOriginator);
+ instanceEvent.setOriginalInstanceGUID(originalEntityGUID);
+
+ this.sendInstanceEvent(instanceEvent);
+ }
+
+
+ /**
+ * An existing entity has had its type changed. Typically this action is taken to move an entity's
+ * type to either a super type (so the subtype can be deleted) or a new subtype (so additional properties can be
+ * added.) However, the type can be changed to any compatible type.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param originalTypeDefSummary - original details for this entity's TypeDef.
+ * @param entity - new values for this entity, including the new type information.
+ */
+ public void processReTypedEntityEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ TypeDefSummary originalTypeDefSummary,
+ EntityDetail entity)
+ {
+ OMRSEventOriginator eventOriginator = new OMRSEventOriginator();
+
+ eventOriginator.setMetadataCollectionId(originatorMetadataCollectionId);
+ eventOriginator.setServerName(originatorServerName);
+ eventOriginator.setServerType(originatorServerType);
+ eventOriginator.setOrganizationName(originatorOrganizationName);
+
+ OMRSInstanceEvent instanceEvent = new OMRSInstanceEvent(OMRSInstanceEventType.RETYPED_ENTITY_EVENT,
+ entity);
+
+ instanceEvent.setEventOriginator(eventOriginator);
+ instanceEvent.setOriginalTypeDefSummary(originalTypeDefSummary);
+
+ this.sendInstanceEvent(instanceEvent);
+ }
+
+
+ /**
+ * An existing entity has changed home repository. This action is taken for example, if a repository
+ * becomes permanently unavailable, or if the user community updating this entity move to working
+ * from a different repository in the open metadata repository cohort.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param originalHomeMetadataCollectionId - unique identifier for the original home repository.
+ * @param entity - new values for this entity, including the new home information.
+ */
+ public void processReHomedEntityEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ String originalHomeMetadataCollectionId,
+ EntityDetail entity)
+ {
+ OMRSEventOriginator eventOriginator = new OMRSEventOriginator();
+
+ eventOriginator.setMetadataCollectionId(originatorMetadataCollectionId);
+ eventOriginator.setServerName(originatorServerName);
+ eventOriginator.setServerType(originatorServerType);
+ eventOriginator.setOrganizationName(originatorOrganizationName);
+
+ OMRSInstanceEvent instanceEvent = new OMRSInstanceEvent(OMRSInstanceEventType.RE_HOMED_ENTITY_EVENT,
+ entity);
+
+ instanceEvent.setEventOriginator(eventOriginator);
+ instanceEvent.setOriginalHomeMetadataCollectionId(originalHomeMetadataCollectionId);
+
+ this.sendInstanceEvent(instanceEvent);
+ }
+
+
+ /**
+ * The local repository is requesting that an entity from another repository's metadata collection is
+ * refreshed so the local repository can create a reference copy.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param typeDefGUID - - unique identifier for this entity's TypeDef
+ * @param typeDefName - name of this entity's TypeDef
+ * @param instanceGUID - unique identifier for the entity
+ * @param homeMetadataCollectionId - metadata collection id for the home of this instance.
+ */
+ public void processRefreshEntityRequested(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ String typeDefGUID,
+ String typeDefName,
+ String instanceGUID,
+ String homeMetadataCollectionId)
+ {
+ OMRSEventOriginator eventOriginator = new OMRSEventOriginator();
+
+ eventOriginator.setMetadataCollectionId(originatorMetadataCollectionId);
+ eventOriginator.setServerName(originatorServerName);
+ eventOriginator.setServerType(originatorServerType);
+ eventOriginator.setOrganizationName(originatorOrganizationName);
+
+ OMRSInstanceEvent instanceEvent = new OMRSInstanceEvent(OMRSInstanceEventType.REFRESH_ENTITY_REQUEST,
+ typeDefGUID,
+ typeDefName,
+ instanceGUID);
+
+ instanceEvent.setEventOriginator(eventOriginator);
+ instanceEvent.setHomeMetadataCollectionId(homeMetadataCollectionId);
+
+ this.sendInstanceEvent(instanceEvent);
+ }
+
+
+ /**
+ * A remote repository in the cohort has sent entity details in response to a refresh request.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param entity - details of the requested entity
+ */
+ public void processRefreshEntityEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ EntityDetail entity)
+ {
+ OMRSEventOriginator eventOriginator = new OMRSEventOriginator();
+
+ eventOriginator.setMetadataCollectionId(originatorMetadataCollectionId);
+ eventOriginator.setServerName(originatorServerName);
+ eventOriginator.setServerType(originatorServerType);
+ eventOriginator.setOrganizationName(originatorOrganizationName);
+
+ OMRSInstanceEvent instanceEvent = new OMRSInstanceEvent(OMRSInstanceEventType.REFRESHED_ENTITY_EVENT,
+ entity);
+
+ instanceEvent.setEventOriginator(eventOriginator);
+
+ this.sendInstanceEvent(instanceEvent);
+ }
+
+
+ /**
+ * A new relationship has been created.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param relationship - details of the new relationship
+ */
+ public void processNewRelationshipEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ Relationship relationship)
+ {
+ OMRSEventOriginator eventOriginator = new OMRSEventOriginator();
+
+ eventOriginator.setMetadataCollectionId(originatorMetadataCollectionId);
+ eventOriginator.setServerName(originatorServerName);
+ eventOriginator.setServerType(originatorServerType);
+ eventOriginator.setOrganizationName(originatorOrganizationName);
+
+ OMRSInstanceEvent instanceEvent = new OMRSInstanceEvent(OMRSInstanceEventType.NEW_RELATIONSHIP_EVENT,
+ relationship);
+
+ instanceEvent.setEventOriginator(eventOriginator);
+
+ this.sendInstanceEvent(instanceEvent);
+ }
+
+
+ /**
+ * An existing relationship has been updated.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param relationship - details of the new versionName of the relationship.
+ */
+ public void processUpdatedRelationshipEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ Relationship relationship)
+ {
+ OMRSEventOriginator eventOriginator = new OMRSEventOriginator();
+
+ eventOriginator.setMetadataCollectionId(originatorMetadataCollectionId);
+ eventOriginator.setServerName(originatorServerName);
+ eventOriginator.setServerType(originatorServerType);
+ eventOriginator.setOrganizationName(originatorOrganizationName);
+
+ OMRSInstanceEvent instanceEvent = new OMRSInstanceEvent(OMRSInstanceEventType.UPDATED_RELATIONSHIP_EVENT,
+ relationship);
+
+ instanceEvent.setEventOriginator(eventOriginator);
+
+ this.sendInstanceEvent(instanceEvent);
+ }
+
+
+ /**
+ * An update to a relationship has been undone.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param relationship - details of the versionName of the relationship that has been restored.
+ */
+ public void processUndoneRelationshipEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ Relationship relationship)
+ {
+ OMRSEventOriginator eventOriginator = new OMRSEventOriginator();
+
+ eventOriginator.setMetadataCollectionId(originatorMetadataCollectionId);
+ eventOriginator.setServerName(originatorServerName);
+ eventOriginator.setServerType(originatorServerType);
+ eventOriginator.setOrganizationName(originatorOrganizationName);
+
+ OMRSInstanceEvent instanceEvent = new OMRSInstanceEvent(OMRSInstanceEventType.UNDONE_RELATIONSHIP_EVENT,
+ relationship);
+
+ instanceEvent.setEventOriginator(eventOriginator);
+
+ this.sendInstanceEvent(instanceEvent);
+ }
+
+ /**
+ * An existing relationship has been deleted. This is a soft delete. This means it is still in the repository
+ * but it is no longer returned on queries.
+ *
+ * Details of the TypeDef are included with the relationship's unique id (guid) to ensure the right
+ * relationship is deleted in the remote repositories.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param typeDefGUID - unique identifier for this relationship's TypeDef
+ * @param typeDefName - name of this relationship's TypeDef
+ * @param instanceGUID - unique identifier for the relationship
+ */
+ public void processDeletedRelationshipEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ String typeDefGUID,
+ String typeDefName,
+ String instanceGUID)
+ {
+ OMRSEventOriginator eventOriginator = new OMRSEventOriginator();
+
+ eventOriginator.setMetadataCollectionId(originatorMetadataCollectionId);
+ eventOriginator.setServerName(originatorServerName);
+ eventOriginator.setServerType(originatorServerType);
+ eventOriginator.setOrganizationName(originatorOrganizationName);
+
+ OMRSInstanceEvent instanceEvent = new OMRSInstanceEvent(OMRSInstanceEventType.DELETED_RELATIONSHIP_EVENT,
+ typeDefGUID,
+ typeDefName,
+ instanceGUID);
+
+ instanceEvent.setEventOriginator(eventOriginator);
+
+ this.sendInstanceEvent(instanceEvent);
+ }
+
+
+ /**
+ * A deleted relationship has been permanently removed from the repository. This request can not be undone.
+ *
+ * Details of the TypeDef are included with the relationship's unique id (guid) to ensure the right
+ * relationship is purged in the remote repositories.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param typeDefGUID - unique identifier for this relationship's TypeDef.
+ * @param typeDefName - name of this relationship's TypeDef.
+ * @param instanceGUID - unique identifier for the relationship.
+ */
+ public void processPurgedRelationshipEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServe
<TRUNCATED>
[08/30] atlas git commit: ATLAS-2246: OMRS Connector API plus REST
and IGC Connector skeleton - 15th February 2018
Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/OMRSMetadataCollection.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/OMRSMetadataCollection.java b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/OMRSMetadataCollection.java
new file mode 100644
index 0000000..5f0bd8b
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/OMRSMetadataCollection.java
@@ -0,0 +1,1957 @@
+/*
+ * 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.metadatacollection;
+
+import org.apache.atlas.omrs.ffdc.*;
+import org.apache.atlas.omrs.ffdc.exception.*;
+import org.apache.atlas.omrs.metadatacollection.properties.MatchCriteria;
+import org.apache.atlas.omrs.metadatacollection.properties.SequencingOrder;
+import org.apache.atlas.omrs.metadatacollection.properties.instances.*;
+import org.apache.atlas.omrs.metadatacollection.properties.typedefs.*;
+
+import java.util.ArrayList;
+import java.util.Date;
+
+/**
+ * <p>
+ * OMRSMetadataCollection is the common interface for working with the contents of a metadata repository.
+ * Within a metadata collection are the type definitions (TypeDefs) and metadata instances (Entities and
+ * Relationships).
+ *
+ * The methods on OMRSMetadataCollection are in the following major groups:
+ * </p>
+ * <ul>
+ * <li><b>Methods to retrieve information about the metadata repository</b> -
+ * Used to retrieve or confirm the identity of the metadata repository
+ * </li>
+ * <li><b>Methods for working with typedefs</b> -
+ * Typedefs are used to define the type model for open metadata.
+ * The open metadata support had a comprehensive set of typedefs implemented, and these can be augmented by
+ * different vendors or applications. The typedefs can be queried, created, updated and deleted though the
+ * metadata collection.
+ * </li>
+ *
+ * <li><b>Methods for querying Entities and Relationships</b> -
+ * The metadata repository stores instances of the typedefs as metadata instances.
+ * Principally these are entities (nodes in the graph) and relationships (links between nodes).
+ * Both the entities and relationships can have properties.
+ * The entity may also have structured properties called structs and classifications attached.
+ * This second group of methods supports a range of queries to retrieve these instances.
+ * </li>
+ *
+ * <li><b>Methods for maintaining the instances</b> -
+ * The fourth group of methods supports the maintenance of the metadata instances. Each instance as a status
+ * (see InstanceStatus) that allows an instance to be proposed, drafted and approved before it becomes
+ * active. The instances can also be soft-deleted and restored or purged from the metadata
+ * collection.
+ * </li>
+ * <li>
+ * <b>Methods for repairing the metadata collections of the cohort</b> -
+ * The fifth group of methods are for editing the control information of entities and relationships to
+ * manage changes in the cohort. These methods are advanced methods and are rarely used.
+ * </li>
+ * <li>
+ * <b>Methods for local maintenance of a metadata collection</b>
+ * The final group of methods are for removing reference copies of the metadata instances. These updates
+ * are not broadcast to the rest of the Cohort as events.
+ * </li>
+ * </ul>
+ */
+public abstract class OMRSMetadataCollection
+{
+ protected String metadataCollectionId;
+
+ /**
+ * Constructor to save the metadata collection id.
+ *
+ * @param metadataCollectionId - unique identifier for the metadata collection
+ */
+ public OMRSMetadataCollection(String metadataCollectionId)
+ {
+ this.metadataCollectionId = metadataCollectionId;
+
+ if (metadataCollectionId == null)
+ {
+ String actionDescription = "OMRS Metadata Collection Constructor";
+
+ OMRSErrorCode errorCode = OMRSErrorCode.NULL_METADATA_COLLECTION_ID;
+ String errorMessage = errorCode.getErrorMessageId()
+ + errorCode.getFormattedErrorMessage();
+
+ throw new OMRSLogicErrorException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ actionDescription,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+
+ }
+ }
+
+
+ /* ======================================================================
+ * Group 1: Confirm the identity of the metadata repository being called.
+ */
+
+ /**
+ * Returns the identifier of the metadata repository. This is the identifier used to register the
+ * metadata repository with the metadata repository cohort. It is also the identifier used to
+ * identify the home repository of a metadata instance.
+ *
+ * @return String - metadata collection id.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository.
+ */
+ public String getMetadataCollectionId() throws RepositoryErrorException
+ {
+ return metadataCollectionId;
+ }
+
+
+ /* ==============================
+ * Group 2: Working with typedefs
+ */
+
+
+ /**
+ * Returns the list of different types of metadata organized into two groups. The first are the
+ * attribute type definitions (AttributeTypeDefs). These provide types for properties in full
+ * type definitions. Full type definitions (TypeDefs) describe types for entities, relationships
+ * and classifications.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @return TypeDefs - List of different categories of TypeDefs.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public abstract TypeDefGallery getAllTypes(String userId) throws RepositoryErrorException,
+ UserNotAuthorizedException;
+
+
+ /**
+ * Returns a list of type definitions that have the specified name. Type names should be unique. This
+ * method allows wildcard character to be included in the name. These are * (asterisk) for an
+ * arbitrary string of characters and ampersand for an arbitrary character.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param name - name of the TypeDefs to return (including wildcard characters).
+ * @return TypeDefs list.
+ * @throws InvalidParameterException - the name of the TypeDef is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public abstract TypeDefGallery findTypesByName(String userId,
+ String name) throws InvalidParameterException,
+ RepositoryErrorException,
+ UserNotAuthorizedException;
+
+
+ /**
+ * Returns all of the TypeDefs for a specific category.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param category - enum value for the category of TypeDef to return.
+ * @return TypeDefs list.
+ * @throws InvalidParameterException - the TypeDefCategory is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public abstract ArrayList<TypeDef> findTypeDefsByCategory(String userId,
+ TypeDefCategory category) throws InvalidParameterException,
+ RepositoryErrorException,
+ UserNotAuthorizedException;
+
+ /**
+ * Returns all of the AttributeTypeDefs for a specific category.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param category - enum value for the category of an AttributeTypeDef to return.
+ * @return TypeDefs list.
+ * @throws InvalidParameterException - the TypeDefCategory is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public abstract ArrayList<AttributeTypeDef> findAttributeTypeDefsByCategory(String userId,
+ AttributeTypeDefCategory category) throws InvalidParameterException,
+ RepositoryErrorException,
+ UserNotAuthorizedException;
+
+ /**
+ * Return the TypeDefs that have the properties matching the supplied match criteria.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param matchCriteria - TypeDefProperties - a list of property names and values.
+ * @return TypeDefs list.
+ * @throws InvalidParameterException - the matchCriteria is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public abstract ArrayList<TypeDef> findTypeDefsByProperty(String userId,
+ TypeDefProperties matchCriteria) throws InvalidParameterException,
+ RepositoryErrorException,
+ UserNotAuthorizedException;
+
+
+ /**
+ * Return the types that are linked to the elements from the specified standard.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param standard - name of the standard - null means any.
+ * @param organization - name of the organization - null means any.
+ * @param identifier - identifier of the element in the standard - null means any.
+ * @return TypeDefs list - each entry in the list contains a typedef. This is is a structure
+ * describing the TypeDef's category and properties.
+ * @throws InvalidParameterException - all attributes of the external id are null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public abstract TypeDefGallery findTypesByExternalID(String userId,
+ String standard,
+ String organization,
+ String identifier) throws InvalidParameterException,
+ RepositoryErrorException,
+ UserNotAuthorizedException;
+
+ /**
+ * Return the TypeDefs that match the search criteria.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param searchCriteria - String - search criteria.
+ * @return TypeDefs list - each entry in the list contains a typedef. This is is a structure
+ * describing the TypeDef's category and properties.
+ * @throws InvalidParameterException - the searchCriteria is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public abstract ArrayList<TypeDef> searchForTypeDefs(String userId,
+ String searchCriteria) throws InvalidParameterException,
+ RepositoryErrorException,
+ UserNotAuthorizedException;
+
+
+ /**
+ * Return the TypeDef identified by the GUID.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param guid - String unique id of the TypeDef
+ * @return TypeDef structure describing its category and properties.
+ * @throws InvalidParameterException - the guid is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws TypeDefNotKnownException - The requested TypeDef is not known in the metadata collection.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public abstract TypeDef getTypeDefByGUID(String userId,
+ String guid) throws InvalidParameterException,
+ RepositoryErrorException,
+ TypeDefNotKnownException,
+ UserNotAuthorizedException;
+
+ /**
+ * Return the AttributeTypeDef identified by the GUID.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param guid - String unique id of the TypeDef
+ * @return TypeDef structure describing its category and properties.
+ * @throws InvalidParameterException - the guid is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws TypeDefNotKnownException - The requested TypeDef is not known in the metadata collection.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public abstract AttributeTypeDef getAttributeTypeDefByGUID(String userId,
+ String guid) throws InvalidParameterException,
+ RepositoryErrorException,
+ TypeDefNotKnownException,
+ UserNotAuthorizedException;
+
+
+ /**
+ * Return the TypeDef identified by the unique name.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param name - String name of the TypeDef.
+ * @return TypeDef structure describing its category and properties.
+ * @throws InvalidParameterException - the name is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws TypeDefNotKnownException - the requested TypeDef is not found in the metadata collection.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public abstract TypeDef getTypeDefByName(String userId,
+ String name) throws InvalidParameterException,
+ RepositoryErrorException,
+ TypeDefNotKnownException,
+ UserNotAuthorizedException;
+
+
+ /**
+ * Return the AttributeTypeDef identified by the unique name.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param name - String name of the TypeDef.
+ * @return TypeDef structure describing its category and properties.
+ * @throws InvalidParameterException - the name is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws TypeDefNotKnownException - the requested TypeDef is not found in the metadata collection.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public abstract AttributeTypeDef getAttributeTypeDefByName(String userId,
+ String name) throws InvalidParameterException,
+ RepositoryErrorException,
+ TypeDefNotKnownException,
+ UserNotAuthorizedException;
+
+
+ /**
+ * Create a collection of related types.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param newTypes - TypeDefGallery structure describing the new AttributeTypeDefs and TypeDefs.
+ * @throws InvalidParameterException - the new TypeDef is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws TypeDefNotSupportedException - the repository is not able to support this TypeDef.
+ * @throws TypeDefKnownException - the TypeDef is already stored in the repository.
+ * @throws TypeDefConflictException - the new TypeDef conflicts with an existing TypeDef.
+ * @throws InvalidTypeDefException - the new TypeDef has invalid contents.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public abstract void addTypeDefGallery(String userId,
+ TypeDefGallery newTypes) throws InvalidParameterException,
+ RepositoryErrorException,
+ TypeDefNotSupportedException,
+ TypeDefKnownException,
+ TypeDefConflictException,
+ InvalidTypeDefException,
+ UserNotAuthorizedException;
+
+
+ /**
+ * Create a definition of a new TypeDef.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param newTypeDef - TypeDef structure describing the new TypeDef.
+ * @throws InvalidParameterException - the new TypeDef is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws TypeDefNotSupportedException - the repository is not able to support this TypeDef.
+ * @throws TypeDefKnownException - the TypeDef is already stored in the repository.
+ * @throws TypeDefConflictException - the new TypeDef conflicts with an existing TypeDef.
+ * @throws InvalidTypeDefException - the new TypeDef has invalid contents.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public abstract void addTypeDef(String userId,
+ TypeDef newTypeDef) throws InvalidParameterException,
+ RepositoryErrorException,
+ TypeDefNotSupportedException,
+ TypeDefKnownException,
+ TypeDefConflictException,
+ InvalidTypeDefException,
+ UserNotAuthorizedException;
+
+ /**
+ * Create a definition of a new AttributeTypeDef.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param newAttributeTypeDef - TypeDef structure describing the new TypeDef.
+ * @throws InvalidParameterException - the new TypeDef is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws TypeDefNotSupportedException - the repository is not able to support this TypeDef.
+ * @throws TypeDefKnownException - the TypeDef is already stored in the repository.
+ * @throws TypeDefConflictException - the new TypeDef conflicts with an existing TypeDef.
+ * @throws InvalidTypeDefException - the new TypeDef has invalid contents.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public abstract void addAttributeTypeDef(String userId,
+ AttributeTypeDef newAttributeTypeDef) throws InvalidParameterException,
+ RepositoryErrorException,
+ TypeDefNotSupportedException,
+ TypeDefKnownException,
+ TypeDefConflictException,
+ InvalidTypeDefException,
+ UserNotAuthorizedException;
+
+
+ /**
+ * Verify that a definition of a TypeDef is either new - or matches the definition already stored.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param typeDef - TypeDef structure describing the TypeDef to test.
+ * @return boolean - true means the TypeDef matches the local definition - false means the TypeDef is not known.
+ * @throws InvalidParameterException - the TypeDef is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws TypeDefNotSupportedException - the repository is not able to support this TypeDef.
+ * @throws TypeDefConflictException - the new TypeDef conflicts with an existing TypeDef.
+ * @throws InvalidTypeDefException - the new TypeDef has invalid contents.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public abstract boolean verifyTypeDef(String userId,
+ TypeDef typeDef) throws InvalidParameterException,
+ RepositoryErrorException,
+ TypeDefNotSupportedException,
+ TypeDefConflictException,
+ InvalidTypeDefException,
+ UserNotAuthorizedException;
+
+
+ /**
+ * Verify that a definition of an AttributeTypeDef is either new - or matches the definition already stored.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param attributeTypeDef - TypeDef structure describing the TypeDef to test.
+ * @return boolean - true means the TypeDef matches the local definition - false means the TypeDef is not known.
+ * @throws InvalidParameterException - the TypeDef is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws TypeDefNotSupportedException - the repository is not able to support this TypeDef.
+ * @throws TypeDefConflictException - the new TypeDef conflicts with an existing TypeDef.
+ * @throws InvalidTypeDefException - the new TypeDef has invalid contents.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public abstract boolean verifyAttributeTypeDef(String userId,
+ AttributeTypeDef attributeTypeDef) throws InvalidParameterException,
+ RepositoryErrorException,
+ TypeDefNotSupportedException,
+ TypeDefConflictException,
+ InvalidTypeDefException,
+ UserNotAuthorizedException;
+
+
+ /**
+ * Update one or more properties of the TypeDef. The TypeDefPatch controls what types of updates
+ * are safe to make to the TypeDef.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param typeDefPatch - TypeDef patch describing change to TypeDef.
+ * @return updated TypeDef
+ * @throws InvalidParameterException - the TypeDefPatch is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws TypeDefNotKnownException - the requested TypeDef is not found in the metadata collection.
+ * @throws PatchErrorException - the TypeDef can not be updated because the supplied patch is incompatible
+ * with the stored TypeDef.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public abstract TypeDef updateTypeDef(String userId,
+ TypeDefPatch typeDefPatch) throws InvalidParameterException,
+ RepositoryErrorException,
+ TypeDefNotKnownException,
+ PatchErrorException,
+ UserNotAuthorizedException;
+
+
+ /**
+ * Delete the TypeDef. This is only possible if the TypeDef has never been used to create instances or any
+ * instances of this TypeDef have been purged from the metadata collection.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param obsoleteTypeDefGUID - String unique identifier for the TypeDef.
+ * @param obsoleteTypeDefName - String unique name for the TypeDef.
+ * @throws InvalidParameterException - the one of TypeDef identifiers is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws TypeDefNotKnownException - the requested TypeDef is not found in the metadata collection.
+ * @throws TypeDefInUseException - the TypeDef can not be deleted because there are instances of this type in the
+ * the metadata collection. These instances need to be purged before the
+ * TypeDef can be deleted.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public abstract void deleteTypeDef(String userId,
+ String obsoleteTypeDefGUID,
+ String obsoleteTypeDefName) throws InvalidParameterException,
+ RepositoryErrorException,
+ TypeDefNotKnownException,
+ TypeDefInUseException,
+ UserNotAuthorizedException;
+
+
+ /**
+ * Delete an AttributeTypeDef. This is only possible if the AttributeTypeDef has never been used to create
+ * instances or any instances of this AttributeTypeDef have been purged from the metadata collection.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param obsoleteTypeDefGUID - String unique identifier for the AttributeTypeDef.
+ * @param obsoleteTypeDefName - String unique name for the AttributeTypeDef.
+ * @throws InvalidParameterException - the one of AttributeTypeDef identifiers is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws TypeDefNotKnownException - the requested AttributeTypeDef is not found in the metadata collection.
+ * @throws TypeDefInUseException - the AttributeTypeDef can not be deleted because there are instances of this type in the
+ * the metadata collection. These instances need to be purged before the
+ * AttributeTypeDef can be deleted.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public abstract void deleteAttributeTypeDef(String userId,
+ String obsoleteTypeDefGUID,
+ String obsoleteTypeDefName) throws InvalidParameterException,
+ RepositoryErrorException,
+ TypeDefNotKnownException,
+ TypeDefInUseException,
+ UserNotAuthorizedException;
+
+
+ /**
+ * Change the guid or name of an existing TypeDef to a new value. This is used if two different
+ * TypeDefs are discovered to have the same guid. This is extremely unlikely but not impossible so
+ * the open metadata protocol has provision for this.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param originalTypeDefGUID - the original guid of the TypeDef.
+ * @param originalTypeDefName - the original name of the TypeDef.
+ * @param newTypeDefGUID - the new identifier for the TypeDef.
+ * @param newTypeDefName - new name for this TypeDef.
+ * @return typeDef - new values for this TypeDef, including the new guid/name.
+ * @throws InvalidParameterException - one of the parameters is invalid or null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws TypeDefNotKnownException - the TypeDef identified by the original guid/name is not found
+ * in the metadata collection.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public abstract TypeDef reIdentifyTypeDef(String userId,
+ String originalTypeDefGUID,
+ String originalTypeDefName,
+ String newTypeDefGUID,
+ String newTypeDefName) throws InvalidParameterException,
+ RepositoryErrorException,
+ TypeDefNotKnownException,
+ UserNotAuthorizedException;
+
+
+ /**
+ * Change the guid or name of an existing TypeDef to a new value. This is used if two different
+ * TypeDefs are discovered to have the same guid. This is extremely unlikely but not impossible so
+ * the open metadata protocol has provision for this.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param originalAttributeTypeDefGUID - the original guid of the AttributeTypeDef.
+ * @param originalAttributeTypeDefName - the original name of the AttributeTypeDef.
+ * @param newAttributeTypeDefGUID - the new identifier for the AttributeTypeDef.
+ * @param newAttributeTypeDefName - new name for this AttributeTypeDef.
+ * @return attributeTypeDef - new values for this AttributeTypeDef, including the new guid/name.
+ * @throws InvalidParameterException - one of the parameters is invalid or null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws TypeDefNotKnownException - the AttributeTypeDef identified by the original guid/name is not
+ * found in the metadata collection.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public abstract AttributeTypeDef reIdentifyAttributeTypeDef(String userId,
+ String originalAttributeTypeDefGUID,
+ String originalAttributeTypeDefName,
+ String newAttributeTypeDefGUID,
+ String newAttributeTypeDefName) throws InvalidParameterException,
+ RepositoryErrorException,
+ TypeDefNotKnownException,
+ UserNotAuthorizedException;
+
+
+ /* ===================================================
+ * Group 3: Locating entity and relationship instances
+ */
+
+
+ /**
+ * Returns a boolean indicating if the entity is stored in the metadata collection.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param guid - String unique identifier for the entity
+ * @return the entity details if the entity is found in the metadata collection; otherwise return null
+ * @throws InvalidParameterException - the guid is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public abstract EntityDetail isEntityKnown(String userId,
+ String guid) throws InvalidParameterException,
+ RepositoryErrorException,
+ UserNotAuthorizedException;
+
+
+ /**
+ * Return the header and classifications for a specific entity.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param guid - String unique identifier for the entity
+ * @return EntitySummary structure
+ * @throws InvalidParameterException - the guid is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws EntityNotKnownException - the requested entity instance is not known in the metadata collection.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public abstract EntitySummary getEntitySummary(String userId,
+ String guid) throws InvalidParameterException,
+ RepositoryErrorException,
+ EntityNotKnownException,
+ UserNotAuthorizedException;
+
+
+
+ /**
+ * Return the header, classifications and properties of a specific entity.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param guid - String unique identifier for the entity.
+ * @return EntityDetail structure.
+ * @throws InvalidParameterException - the guid is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws EntityNotKnownException - the requested entity instance is not known in the metadata collection.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public abstract EntityDetail getEntityDetail(String userId,
+ String guid) throws InvalidParameterException,
+ RepositoryErrorException,
+ EntityNotKnownException,
+ UserNotAuthorizedException;
+
+
+ /**
+ * Return a historical version of an entity - includes the header, classifications and properties of the entity.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param guid - String unique identifier for the entity.
+ * @param asOfTime - the time used to determine which version of the entity that is desired.
+ * @return EntityDetail structure.
+ * @throws InvalidParameterException - the guid or date is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws EntityNotKnownException - the requested entity instance is not known in the metadata collection
+ * at the time requested.
+ * @throws PropertyErrorException - the asOfTime property is for a future time.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public abstract EntityDetail getEntityDetail(String userId,
+ String guid,
+ Date asOfTime) throws InvalidParameterException,
+ RepositoryErrorException,
+ EntityNotKnownException,
+ PropertyErrorException,
+ UserNotAuthorizedException;
+
+
+ /**
+ * Return the header, classifications, properties and relationships for a specific entity.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param guid - String unique identifier for the entity.
+ * @return EntityUniverse structure.
+ * @throws InvalidParameterException - the guid is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws EntityNotKnownException - the requested entity instance is not known in the metadata collection.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public abstract EntityUniverse getEntityUniverse(String userId,
+ String guid) throws InvalidParameterException,
+ RepositoryErrorException,
+ EntityNotKnownException,
+ UserNotAuthorizedException;
+
+
+
+ /**
+ * Return the relationships for a specific entity.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param entityGUID - String unique identifier for the entity.
+ * @param fromRelationshipElement - the starting element number of the relationships to return.
+ * This is used when retrieving elements
+ * beyond the first page of results. Zero means start from the first element.
+ * @param limitResultsByStatus - By default, relationships in all statuses are returned. However, it is possible
+ * to specify a list of statuses (eg ACTIVE) to restrict the results to. Null means all
+ * status values.
+ * @param asOfTime - Requests a historical query of the relationships for the entity. Null means return the
+ * present values.
+ * @param sequencingProperty - String name of the property that is to be used to sequence the results.
+ * Null means do not sequence on a property name (see SequencingOrder).
+ * @param sequencingOrder - Enum defining how the results should be ordered.
+ * @param pageSize -- the maximum number of result classifications that can be returned on this request. Zero means
+ * unrestricted return results size.
+ * @return Relationships list. Null means no relationships associated with the entity.
+ * @throws InvalidParameterException - a parameter is invalid or null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws EntityNotKnownException - the requested entity instance is not known in the metadata collection.
+ * @throws PropertyErrorException - the sequencing property is not valid for the attached classifications.
+ * @throws PagingErrorException - the paging/sequencing parameters are set up incorrectly.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public abstract ArrayList<Relationship> getRelationshipsForEntity(String userId,
+ String entityGUID,
+ int fromRelationshipElement,
+ ArrayList<InstanceStatus> limitResultsByStatus,
+ Date asOfTime,
+ String sequencingProperty,
+ SequencingOrder sequencingOrder,
+ int pageSize) throws InvalidParameterException,
+ RepositoryErrorException,
+ EntityNotKnownException,
+ PropertyErrorException,
+ PagingErrorException,
+ UserNotAuthorizedException;
+
+
+
+ /**
+ * Return a list of entities that match the supplied properties according to the match criteria. The results
+ * can be returned over many pages.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param entityTypeGUID - String unique identifier for the entity type of interest (null means any entity type).
+ * @param matchProperties - List of entity properties to match to (null means match on entityTypeGUID only).
+ * @param matchCriteria - Enum defining how the properties should be matched to the entities in the repository.
+ * @param fromEntityDetailElement - the starting element number of the entities to return.
+ * This is used when retrieving elements
+ * beyond the first page of results. Zero means start from the first element.
+ * @param limitResultsByStatus - By default, entities in all statuses are returned. However, it is possible
+ * to specify a list of statuses (eg ACTIVE) to restrict the results to. Null means all
+ * status values.
+ * @param limitResultsByClassification - List of classifications that must be present on all returned entities.
+ * @param asOfTime - Requests a historical query of the entity. Null means return the present values.
+ * @param sequencingProperty - String name of the entity property that is to be used to sequence the results.
+ * Null means do not sequence on a property name (see SequencingOrder).
+ * @param sequencingOrder - Enum defining how the results should be ordered.
+ * @param pageSize - the maximum number of result entities that can be returned on this request. Zero means
+ * unrestricted return results size.
+ * @return a list of entities matching the supplied criteria - null means no matching entities in the metadata
+ * collection.
+ * @throws InvalidParameterException - a parameter is invalid or null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws TypeErrorException - the type guid passed on the request is not known by the
+ * metadata collection.
+ * @throws PropertyErrorException - the properties specified are not valid for any of the requested types of
+ * entity.
+ * @throws PagingErrorException - the paging/sequencing parameters are set up incorrectly.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public abstract ArrayList<EntityDetail> findEntitiesByProperty(String userId,
+ String entityTypeGUID,
+ InstanceProperties matchProperties,
+ MatchCriteria matchCriteria,
+ int fromEntityDetailElement,
+ ArrayList<InstanceStatus> limitResultsByStatus,
+ ArrayList<String> limitResultsByClassification,
+ Date asOfTime,
+ String sequencingProperty,
+ SequencingOrder sequencingOrder,
+ int pageSize) throws InvalidParameterException,
+ RepositoryErrorException,
+ TypeErrorException,
+ PropertyErrorException,
+ PagingErrorException,
+ UserNotAuthorizedException;
+
+
+ /**
+ * Return a list of entities that have the requested type of classification attached.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param entityTypeGUID - unique identifier for the type of entity requested. Null mans any type of entity.
+ * @param classificationName - name of the classification - a null is not valid.
+ * @param matchClassificationProperties - list of classification properties used to narrow the search.
+ * @param matchCriteria - Enum defining how the properties should be matched to the classifications in the repository.
+ * @param fromEntityDetailElement - the starting element number of the entities to return.
+ * This is used when retrieving elements
+ * beyond the first page of results. Zero means start from the first element.
+ * @param limitResultsByStatus - By default, entities in all statuses are returned. However, it is possible
+ * to specify a list of statuses (eg ACTIVE) to restrict the results to. Null means all
+ * status values.
+ * @param asOfTime - Requests a historical query of the entity. Null means return the present values.
+ * @param sequencingProperty - String name of the entity property that is to be used to sequence the results.
+ * Null means do not sequence on a property name (see SequencingOrder).
+ * @param sequencingOrder - Enum defining how the results should be ordered.
+ * @param pageSize - the maximum number of result entities that can be returned on this request. Zero means
+ * unrestricted return results size.
+ * @return a list of entities matching the supplied criteria - null means no matching entities in the metadata
+ * collection.
+ * @throws InvalidParameterException - a parameter is invalid or null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws TypeErrorException - the type guid passed on the request is not known by the
+ * metadata collection.
+ * @throws ClassificationErrorException - the classification request is not known to the metadata collection.
+ * @throws PropertyErrorException - the properties specified are not valid for the requested type of
+ * classification.
+ * @throws PagingErrorException - the paging/sequencing parameters are set up incorrectly.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public abstract ArrayList<EntityDetail> findEntitiesByClassification(String userId,
+ String entityTypeGUID,
+ String classificationName,
+ InstanceProperties matchClassificationProperties,
+ MatchCriteria matchCriteria,
+ ArrayList<InstanceStatus> limitResultsByStatus,
+ Date asOfTime,
+ String sequencingProperty,
+ SequencingOrder sequencingOrder,
+ int fromEntityDetailElement,
+ int pageSize) throws InvalidParameterException,
+ RepositoryErrorException,
+ TypeErrorException,
+ ClassificationErrorException,
+ PropertyErrorException,
+ PagingErrorException,
+ UserNotAuthorizedException;
+
+
+ /**
+ * Return a list of entities matching the search criteria.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param searchCriteria - String expression of the characteristics of the required relationships.
+ * @param fromEntityDetailElement - the starting element number of the entities to return.
+ * This is used when retrieving elements
+ * beyond the first page of results. Zero means start from the first element.
+ * @param limitResultsByStatus - By default, entities in all statuses are returned. However, it is possible
+ * to specify a list of statuses (eg ACTIVE) to restrict the results to. Null means all
+ * status values.
+ * @param limitResultsByClassification - List of classifications that must be present on all returned entities.
+ * @param asOfTime - Requests a historical query of the entity. Null means return the present values.
+ * @param sequencingProperty - String name of the property that is to be used to sequence the results.
+ * Null means do not sequence on a property name (see SequencingOrder).
+ * @param sequencingOrder - Enum defining how the results should be ordered.
+ * @param pageSize - the maximum number of result entities that can be returned on this request. Zero means
+ * unrestricted return results size.
+ * @return a list of entities matching the supplied criteria - null means no matching entities in the metadata
+ * collection.
+ * @throws InvalidParameterException - a parameter is invalid or null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws PropertyErrorException - the sequencing property specified is not valid for any of the requested types of
+ * entity.
+ * @throws PagingErrorException - the paging/sequencing parameters are set up incorrectly.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public abstract ArrayList<EntityDetail> searchForEntities(String userId,
+ String searchCriteria,
+ int fromEntityDetailElement,
+ ArrayList<InstanceStatus> limitResultsByStatus,
+ ArrayList<String> limitResultsByClassification,
+ Date asOfTime,
+ String sequencingProperty,
+ SequencingOrder sequencingOrder,
+ int pageSize) throws InvalidParameterException,
+ RepositoryErrorException,
+ PropertyErrorException,
+ PagingErrorException,
+ UserNotAuthorizedException;
+
+
+ /**
+ * Returns a boolean indicating if the relationship is stored in the metadata collection.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param guid - String unique identifier for the relationship.
+ * @return relationship if the relationship is found in the metadata collection; otherwise return null.
+ * @throws InvalidParameterException - the guid is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public abstract Relationship isRelationshipKnown(String userId,
+ String guid) throws InvalidParameterException,
+ RepositoryErrorException,
+ UserNotAuthorizedException;
+
+
+ /**
+ * Return the current version of a requested relationship.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param guid - String unique identifier for the relationship.
+ * @return a relationship structure.
+ * @throws InvalidParameterException - the guid is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws RelationshipNotKnownException - the metadata collection does not have a relationship with
+ * the requested GUID stored.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public abstract Relationship getRelationship(String userId,
+ String guid) throws InvalidParameterException,
+ RepositoryErrorException,
+ RelationshipNotKnownException,
+ UserNotAuthorizedException;
+
+ /**
+ * Return a historical version of a relationship.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param guid - String unique identifier for the relationship.
+ * @param asOfTime - the time used to determine which version of the entity that is desired.
+ * @return EntityDetail structure.
+ * @throws InvalidParameterException - the guid or date is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws RelationshipNotKnownException - the requested entity instance is not known in the metadata collection
+ * at the time requested.
+ * @throws PropertyErrorException - the asOfTime property is for a future time.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public abstract Relationship getRelationship(String userId,
+ String guid,
+ Date asOfTime) throws InvalidParameterException,
+ RepositoryErrorException,
+ RelationshipNotKnownException,
+ PropertyErrorException,
+ UserNotAuthorizedException;
+
+ /**
+ * Return a list of relationships that match the requested properties by hte matching criteria. The results
+ * can be broken into pages.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param relationshipTypeGUID - unique identifier (guid) for the new relationship's type.
+ * @param matchProperties - list of properties used to narrow the search.
+ * @param matchCriteria - Enum defining how the properties should be matched to the relationships in the repository.
+ * @param fromEntityDetailElement - the starting element number of the entities to return.
+ * This is used when retrieving elements
+ * beyond the first page of results. Zero means start from the first element.
+ * @param limitResultsByStatus - By default, relationships in all statuses are returned. However, it is possible
+ * to specify a list of statuses (eg ACTIVE) to restrict the results to. Null means all
+ * status values.
+ * @param asOfTime - Requests a historical query of the relationships for the entity. Null means return the
+ * present values.
+ * @param sequencingProperty - String name of the property that is to be used to sequence the results.
+ * Null means do not sequence on a property name (see SequencingOrder).
+ * @param sequencingOrder - Enum defining how the results should be ordered.
+ * @param pageSize - the maximum number of result relationships that can be returned on this request. Zero means
+ * unrestricted return results size.
+ * @return a list of relationships. Null means no matching relationships.
+ * @throws InvalidParameterException - one of the parameters is invalid or null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws TypeErrorException - the type guid passed on the request is not known by the
+ * metadata collection.
+ * @throws PropertyErrorException - the properties specified are not valid for any of the requested types of
+ * relationships.
+ * @throws PagingErrorException - the paging/sequencing parameters are set up incorrectly.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public abstract ArrayList<Relationship> findRelationshipsByProperty(String userId,
+ String relationshipTypeGUID,
+ InstanceProperties matchProperties,
+ MatchCriteria matchCriteria,
+ int fromEntityDetailElement,
+ ArrayList<InstanceStatus> limitResultsByStatus,
+ Date asOfTime,
+ String sequencingProperty,
+ SequencingOrder sequencingOrder,
+ int pageSize) throws InvalidParameterException,
+ RepositoryErrorException,
+ TypeErrorException,
+ PropertyErrorException,
+ PagingErrorException,
+ UserNotAuthorizedException;
+
+
+ /**
+ * Return a list of relationships that match the search criteria. The results can be paged.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param searchCriteria - String expression of the characteristics of the required relationships.
+ * @param fromRelationshipElement - Element number of the results to skip to when building the results list
+ * to return. Zero means begin at the start of the results. This is used
+ * to retrieve the results over a number of pages.
+ * @param limitResultsByStatus - By default, relationships in all statuses are returned. However, it is possible
+ * to specify a list of statuses (eg ACTIVE) to restrict the results to. Null means all
+ * status values.
+ * @param asOfTime - Requests a historical query of the relationships for the entity. Null means return the
+ * present values.
+ * @param sequencingProperty - String name of the property that is to be used to sequence the results.
+ * Null means do not sequence on a property name (see SequencingOrder).
+ * @param sequencingOrder - Enum defining how the results should be ordered.
+ * @param pageSize - the maximum number of result relationships that can be returned on this request. Zero means
+ * unrestricted return results size.
+ * @return a list of relationships. Null means no matching relationships.
+ * @throws InvalidParameterException - one of the parameters is invalid or null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws PropertyErrorException - there is a problem with one of the other parameters.
+ * @throws PagingErrorException - the paging/sequencing parameters are set up incorrectly.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public abstract ArrayList<Relationship> searchForRelationships(String userId,
+ String searchCriteria,
+ int fromRelationshipElement,
+ ArrayList<InstanceStatus> limitResultsByStatus,
+ Date asOfTime,
+ String sequencingProperty,
+ SequencingOrder sequencingOrder,
+ int pageSize) throws InvalidParameterException,
+ RepositoryErrorException,
+ PropertyErrorException,
+ PagingErrorException,
+ UserNotAuthorizedException;
+
+
+ /**
+ * Return all of the relationships and intermediate entities that connect the startEntity with the endEntity.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param startEntityGUID - The entity that is used to anchor the query.
+ * @param endEntityGUID - the other entity that defines the scope of the query.
+ * @param limitResultsByStatus - By default, relationships in all statuses are returned. However, it is possible
+ * to specify a list of statuses (eg ACTIVE) to restrict the results to. Null means all
+ * status values.
+ * @param asOfTime - Requests a historical query of the relationships for the entity. Null means return the
+ * present values.
+ * @return InstanceGraph - the sub-graph that represents the returned linked entities and their relationships.
+ * @throws InvalidParameterException - one of the parameters is invalid or null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws EntityNotKnownException - the entity identified by either the startEntityGUID or the endEntityGUID
+ * is not found in the metadata collection.
+ * @throws PropertyErrorException - there is a problem with one of the other parameters.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public abstract InstanceGraph getLinkingEntities(String userId,
+ String startEntityGUID,
+ String endEntityGUID,
+ ArrayList<InstanceStatus> limitResultsByStatus,
+ Date asOfTime) throws InvalidParameterException,
+ RepositoryErrorException,
+ EntityNotKnownException,
+ PropertyErrorException,
+ UserNotAuthorizedException;
+
+
+ /**
+ * Return the entities and relationships that radiate out from the supplied entity GUID.
+ * The results are scoped both the instance type guids and the level.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param entityGUID - the starting point of the query.
+ * @param entityTypeGUIDs - list of entity types to include in the query results. Null means include
+ * all entities found, irrespective of their type.
+ * @param relationshipTypeGUIDs - list of relationship types to include in the query results. Null means include
+ * all relationships found, irrespective of their type.
+ * @param limitResultsByStatus - By default, relationships in all statuses are returned. However, it is possible
+ * to specify a list of statuses (eg ACTIVE) to restrict the results to. Null means all
+ * status values.
+ * @param limitResultsByClassification - List of classifications that must be present on all returned entities.
+ * @param asOfTime - Requests a historical query of the relationships for the entity. Null means return the
+ * present values.
+ * @param level - the number of the relationships out from the starting entity that the query will traverse to
+ * gather results.
+ * @return InstanceGraph - the sub-graph that represents the returned linked entities and their relationships.
+ * @throws InvalidParameterException - one of the parameters is invalid or null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws TypeErrorException - one or more of the type guids passed on the request is not known by the
+ * metadata collection.
+ * @throws EntityNotKnownException - the entity identified by the entityGUID is not found in the metadata collection.
+ * @throws PropertyErrorException - there is a problem with one of the other parameters.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public abstract InstanceGraph getEntityNeighborhood(String userId,
+ String entityGUID,
+ ArrayList<String> entityTypeGUIDs,
+ ArrayList<String> relationshipTypeGUIDs,
+ ArrayList<InstanceStatus> limitResultsByStatus,
+ ArrayList<String> limitResultsByClassification,
+ Date asOfTime,
+ int level) throws InvalidParameterException,
+ RepositoryErrorException,
+ TypeErrorException,
+ EntityNotKnownException,
+ PropertyErrorException,
+ UserNotAuthorizedException;
+
+
+ /**
+ * Return the list of entities that are of the types listed in instanceTypes and are connected, either directly or
+ * indirectly to the entity identified by startEntityGUID.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param startEntityGUID - unique identifier of the starting entity.
+ * @param instanceTypes - list of types to search for. Null means an type.
+ * @param fromEntityElement - starting element for results list. Used in paging. Zero means first element.
+ * @param limitResultsByStatus - By default, relationships in all statuses are returned. However, it is possible
+ * to specify a list of statuses (eg ACTIVE) to restrict the results to. Null means all
+ * status values.
+ * @param limitResultsByClassification - List of classifications that must be present on all returned entities.
+ * @param asOfTime - Requests a historical query of the relationships for the entity. Null means return the
+ * present values.
+ * @param sequencingProperty - String name of the property that is to be used to sequence the results.
+ * Null means do not sequence on a property name (see SequencingOrder).
+ * @param sequencingOrder - Enum defining how the results should be ordered.
+ * @param pageSize - the maximum number of result entities that can be returned on this request. Zero means
+ * unrestricted return results size.
+ * @return list of entities either directly or indirectly connected to the start entity
+ * @throws InvalidParameterException - one of the parameters is invalid or null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws TypeErrorException - the requested type is not known, or not supported in the metadata repository
+ * hosting the metadata collection.
+ * @throws EntityNotKnownException - the entity identified by the startEntityGUID
+ * is not found in the metadata collection.
+ * @throws PropertyErrorException - the sequencing property specified is not valid for any of the requested types of
+ * entity.
+ * @throws PagingErrorException - the paging/sequencing parameters are set up incorrectly.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public abstract ArrayList<EntityDetail> getRelatedEntities(String userId,
+ String startEntityGUID,
+ ArrayList<String> instanceTypes,
+ int fromEntityElement,
+ ArrayList<InstanceStatus> limitResultsByStatus,
+ ArrayList<String> limitResultsByClassification,
+ Date asOfTime,
+ String sequencingProperty,
+ SequencingOrder sequencingOrder,
+ int pageSize) throws InvalidParameterException,
+ RepositoryErrorException,
+ TypeErrorException,
+ EntityNotKnownException,
+ PropertyErrorException,
+ PagingErrorException,
+ UserNotAuthorizedException;
+
+
+ /* ======================================================
+ * Group 4: Maintaining entity and relationship instances
+ */
+
+ /**
+ * Create a new entity and put it in the requested state. The new entity is returned.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param entityTypeGUID - unique identifier (guid) for the new entity's type.
+ * @param initialProperties - initial list of properties for the new entity - null means no properties.
+ * @param initialClassifications - initial list of classifications for the new entity - null means no classifications.
+ * @param initialStatus - initial status - typically DRAFT, PREPARED or ACTIVE.
+ * @return EntityDetail showing the new header plus the requested properties and classifications. The entity will
+ * not have any relationships at this stage.
+ * @throws InvalidParameterException - one of the parameters is invalid or null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws TypeErrorException - the requested type is not known, or not supported in the metadata repository
+ * hosting the metadata collection.
+ * @throws PropertyErrorException - one or more of the requested properties are not defined, or have different
+ * characteristics in the TypeDef for this entity's type.
+ * @throws ClassificationErrorException - one or more of the requested classifications are either not known or
+ * not defined for this entity type.
+ * @throws StatusNotSupportedException - the metadata repository hosting the metadata collection does not support
+ * the requested status.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public abstract EntityDetail addEntity(String userId,
+ String entityTypeGUID,
+ InstanceProperties initialProperties,
+ ArrayList<Classification> initialClassifications,
+ InstanceStatus initialStatus) throws InvalidParameterException,
+ RepositoryErrorException,
+ TypeErrorException,
+ PropertyErrorException,
+ ClassificationErrorException,
+ StatusNotSupportedException,
+ UserNotAuthorizedException;
+
+
+ /**
+ * Create an entity proxy in the metadata collection. This is used to store relationships that span metadata
+ * repositories.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param entityProxy - details of entity to add.
+ * @throws InvalidParameterException - the entity proxy is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws TypeErrorException - the requested type is not known, or not supported in the metadata repository
+ * hosting the metadata collection.
+ * @throws PropertyErrorException - one or more of the requested properties are not defined, or have different
+ * characteristics in the TypeDef for this entity's type.
+ * @throws ClassificationErrorException - one or more of the requested classifications are either not known or
+ * not defined for this entity type.
+ * @throws StatusNotSupportedException - the metadata repository hosting the metadata collection does not support
+ * the requested status.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public abstract void addEntityProxy(String userId,
+ EntityProxy entityProxy) throws InvalidParameterException,
+
<TRUNCATED>
[18/30] atlas git commit: ATLAS-2246: OMRS Connector API plus REST
and IGC Connector skeleton - 15th February 2018
Posted by da...@apache.org.
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
[15/30] atlas git commit: ATLAS-2246: OMRS Connector API plus REST
and IGC Connector skeleton - 15th February 2018
Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/ffdc/OMRSErrorCode.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/ffdc/OMRSErrorCode.java b/omrs/src/main/java/org/apache/atlas/omrs/ffdc/OMRSErrorCode.java
new file mode 100644
index 0000000..f40f2c6
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/ffdc/OMRSErrorCode.java
@@ -0,0 +1,413 @@
+/*
+ * 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.ffdc;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.text.MessageFormat;
+import java.util.Arrays;
+
+/**
+ * The OMRSErrorCode is used to define first failure data capture (FFDC) for errors that occur within the OMRS
+ * It is used in conjunction with all OMRS Exceptions, both Checked and Runtime (unchecked).
+ *
+ * The 5 fields in the enum are:
+ * <ul>
+ * <li>HTTP Error Code - for translating between REST and JAVA - Typically the numbers used are:</li>
+ * <li><ul>
+ * <li>500 - internal error</li>
+ * <li>501 - not implemented </li>
+ * <li>503 - Service not available</li>
+ * <li>400 - invalid parameters</li>
+ * <li>401 - unauthorized</li>
+ * <li>404 - not found</li>
+ * <li>405 - method not allowed</li>
+ * <li>409 - data conflict errors - eg item already defined</li>
+ * </ul></li>
+ * <li>Error Message Id - to uniquely identify the message</li>
+ * <li>Error Message Text - includes placeholder to allow additional values to be captured</li>
+ * <li>SystemAction - describes the result of the error</li>
+ * <li>UserAction - describes how a user should correct the error</li>
+ * </ul>
+ */
+public enum OMRSErrorCode
+{
+ ENTITY_NOT_KNOWN(400, "OMRS-REPOSITORY-400-001",
+ "The entity identified with guid \"{0}\" is not known to the open metadata repository {1}.",
+ "The system is unable to retrieve the properties for the requested entity because the supplied guid is not recognized.",
+ "The guid is supplied by the caller to the OMRS. It may have a logic problem that has corrupted the guid, or the entity has been deleted since the guid was retrieved."),
+ RELATIONSHIP_NOT_KNOWN(400, "OMRS-REPOSITORY-400-002",
+ "The relationship identified with guid \"{0}\" is not known to the open metadata repository {1}.",
+ "The system is unable to retrieve the properties for the requested relationship because the supplied guid is not recognized.",
+ "The guid is supplied by the caller to the OMRS. It may have a logic problem that has corrupted the guid, or the relationship has been deleted since the guid was retrieved."),
+ TYPEDEF_NOT_KNOWN(400, "OMRS-REPOSITORY-400-003",
+ "The typedef \"{0}\" is not known to the metadata repository.",
+ "The system is unable to retrieve the properties for the requested typedef because the supplied identifier is not recognized.",
+ "The identifier is supplied by the caller. It may have a logic problem that has corrupted the identifier, or the typedef has been deleted since the identifier was retrieved."),
+ TYPEDEF_IN_USE(400, "OMRS-REPOSITORY-400-004",
+ "Unable to delete the typedef identified with guid \"{0}\" since it is still in use in the metadata repository.",
+ "The system is unable to delete the typedef because there are still instances in the metadata repository that are using it.",
+ "Remove the existing instances from the open metadata repositories and try the delete again."),
+ UNKNOWN_CLASSIFICATION(400, "OMRS-REPOSITORY-400-005",
+ "Classification \"{0}\" is not a recognized classification type",
+ "The system is unable to create a new classification for an entity because the local repository does not recognize the type.",
+ "Create a ClassificationDef for the classification and retry the request."),
+ INVALID_CLASSIFICATION_FOR_ENTITY(400, "OMRS-REPOSITORY-400-006",
+ "Unable to assign a classification of type \"{0}\" to an entity of type \"{1}\" because this classification is not valid for this type of entity.",
+ "The system is unable to classify an entity because the ClassificationDef for the classification does not list this entity type, or one of its super-types.",
+ "Update the ClassificationDef to include the entity's type and rerun the request."),
+ NO_TYPEDEF_NAME(400, "OMRS-REPOSITORY-400-007",
+ "A null TypeDef name has been passed on a metadata repository request.",
+ "The system is unable to perform the request because the TypeDef name is needed.",
+ "Correct the caller's code and retry the request."),
+ NO_TYPEDEF_CATEGORY(400, "OMRS-REPOSITORY-400-008",
+ "A null TypeDef category has been passed on a metadata repository request.",
+ "The system is unable to perform the request because the TypeDef category is needed.",
+ "Correct the caller's code and retry the request."),
+ NO_MATCH_CRITERIA(400, "OMRS-REPOSITORY-400-009",
+ "A null list of match criteria properties has been passed on a metadata repository request.",
+ "The system is unable to perform the request because the match criteria is needed.",
+ "Correct the caller's code and retry the request."),
+ NO_EXTERNAL_ID(400, "OMRS-REPOSITORY-400-010",
+ "Null values for all of the parameters describing an external id for a standard has been passed on a metadata repository request.",
+ "The system is unable to perform the request because at least one of the values are needed.",
+ "Correct the caller's code and retry the request."),
+ NO_SEARCH_CRITERIA(400, "OMRS-REPOSITORY-400-011",
+ "A null search criteria has been passed on a metadata repository request.",
+ "The system is unable to perform the request because the search criteria is needed.",
+ "Correct the caller's code and retry the request."),
+ NO_GUID(400, "OMRS-REPOSITORY-400-012",
+ "A null unique identifier (guid) has been passed on a metadata repository request.",
+ "The system is unable to perform the request because the TypeDef name is needed.",
+ "Correct the caller's code and retry the request."),
+ NO_TYPEDEF(400, "OMRS-REPOSITORY-400-013",
+ "A null TypeDef has been passed on a metadata repository request.",
+ "The system is unable to perform the request because the TypeDef is needed.",
+ "Correct the caller's code and retry the request."),
+ INVALID_TYPEDEF(400, "OMRS-REPOSITORY-400-013",
+ "An invalid TypeDef has been passed on a metadata repository request.",
+ "The system is unable to perform the request because the TypeDef is needed.",
+ "Correct the caller's code and retry the request."),
+ NO_MORE_ELEMENTS(400, "OMRS-PROPERTIES-400-001",
+ "No more elements in {0} iterator",
+ "A caller stepping through an iterator has requested more elements when there are none left.",
+ "Recode the caller to use the hasNext() method to check for more elements before calling next() and then retry."),
+ NULL_CLASSIFICATION_NAME(400, "OMRS-PROPERTIES-400-002",
+ "No name provided for entity classification",
+ "A classification with a null name is assigned to an entity. This value should come from a metadata repository, and always be filled in.",
+ "Look for other error messages to identify the source of the problem. Identify the metadata repository where the asset came from. Correct the cause of the error and then retry."),
+ NULL_PROPERTY_NAME(400, "OMRS-PROPERTIES-400-003",
+ "Null property name passed to properties object",
+ "A request to set an additional property failed because the property name passed was null",
+ "Recode the call to the property object with a valid property name and retry."),
+ ARRAY_OUT_OF_BOUNDS(400, "OMRS-PROPERTIES-400-004",
+ "{0} is unable to add a new element to location {1} of an array of size {2} value",
+ "There is an error in the update of an ArrayPropertyValue.",
+ "Recode the call to the property object with a valid element location and retry."),
+ BAD_ATTRIBUTE_TYPE(400, "OMRS-PROPERTIES-400-005",
+ "AttributeDefs may only be of primitive, collection or enum type. {0} of category {1} is not allowed.",
+ "There is an error in the creation of an AttributeDefType.",
+ "Recode the call to the AttributeDefType object with a valid type."),
+ REPOSITORY_URL_MALFORMED(400, "OMRS-CONNECTOR-400-001",
+ "The Open Metadata Repository Server URL {0} is not in a recognized format",
+ "The system is unable to connect to the open metadata repository to retrieve metadata properties.",
+ "Retry the request when the connection configuration for this repository is corrected."),
+ NULL_CONNECTION(400, "OMRS-CONNECTOR-400-003",
+ "The connection passed to OMASConnectedAssetProperties for connector {0} is null.",
+ "The system is unable to populate the ConnectedAssetProperties object because it needs the connection to identify the asset.",
+ "Look for other error messages to identify what caused this error. When the issue is resolved, retry the request."),
+ NULL_OMRS_CONNECTION(400, "OMRS-CONNECTOR-400-004",
+ "The connection passed to the EnterpriseOMRSRepositoryConnector is null.",
+ "The system is unable to populate the EnterpriseOMRSRepositoryConnector object because it needs the connection to identify the repository.",
+ "Look for other error messages to identify what caused this error. When the issue is resolved, retry the request."),
+ INVALID_OMRS_CONNECTION(400, "OMRS-CONNECTOR-400-005",
+ "The connection {0} passed to the EnterpriseOMRSRepositoryConnector is invalid.",
+ "The system is unable to populate the EnterpriseOMRSRepositoryConnector object because it needs the connection to identify the repository.",
+ "Look for other error messages to identify what caused this error. When the issue is resolved, retry the request."),
+ NULL_TOPIC_CONNECTOR(400, "OMRS-TOPIC-CONNECTOR-400-001",
+ "Unable to send or receive events for source {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. "),
+ NULL_REGISTRY_STORE(400, "OMRS-COHORT-REGISTRY-404-001",
+ "The Open Metadata Repository Cohort Registry Store for cohort {0} is not available.",
+ "The system is unable to process registration requests from the open metadata repository cohort.",
+ "Correct the configuration for the registry store connection in the server configuration. " +
+ "Retry the request when the registry store configuration is correct."),
+ INVALID_LOCAL_METADATA_COLLECTION_ID(400, "OMRS-COHORT-REGISTRY-400-002",
+ "The Open Metadata Repository Cohort {0} is not available to server {1} because the local " +
+ "metadata collection id has been changed from {2} to {3} since this server registered with the cohort.",
+ "The system is unable to connect with other members of the cohort while this incompatibility exists.",
+ "If there is no reason for the change of local metadata collection id (this is the normal case) " +
+ "change the local metadata collection id back to its original valid in the server configuration. " +
+ "If the local metadata collection Id must be changed (due to a conflict for example) " +
+ "then shutdown the server, restart it with no local repository configured and shut it down " +
+ "normally once the server has successfully unregistered with the cohort. " +
+ "Then re-establish the local repository configuration." +
+ "Restart the server once the configuration is correct."),
+ NULL_AUDIT_LOG_STORE(400, "OMRS-AUDIT-LOG-400-001",
+ "The Audit Log Store for server {0} is not available.",
+ "The system is unable to process any open metadata registry services (OMRS) requests because " +
+ "the audit log for this server is unavailable.",
+ "Correct the configuration for the audit log store connection in the server configuration. " +
+ "Retry the request when the audit log store configuration is correct."),
+ NULL_ARCHIVE_STORE(400, "OMRS-ARCHIVE-MANAGER-400-001",
+ "An open metadata archive configured for server {0} is not accessible.",
+ "The system is unable to process the contents of this open metadata archive. " +
+ "Other services may fail if they were dependent on this open metadata archive.",
+ "Correct the configuration for the open metadata archive connection in the server configuration. " +
+ "Retry the request when the open metadata archive configuration is correct."),
+ NULL_EVENT_MAPPER(400, "OMRS-LOCAL-REPOSITORY-400-001",
+ "The repository event mapper configured for the local repository for server {0} is not accessible.",
+ "The system is unable to create the repository event mapper which means that events from the " +
+ "local repository will not be captured and processed. " +
+ "Other services may fail if they were dependent on this event notification.",
+ "Correct the configuration for the repository event mapper connection in the server configuration. " +
+ "Retry the request when the repository event mapper configuration is correct."),
+ DUPLICATE_COHORT_NAME(400, "OMRS-METADATA-HIGHWAY-404-001",
+ "There are more than one cohort configurations with the same name of {0}.",
+ "The system is unable to connect to more than one cohort with the same name.",
+ "Correct the configuration for the cohorts in the server configuration. " +
+ "Retry the request when the cohort configuration is correct."),
+ CONFLICTING_ENTERPRISE_TYPEDEFS(400, "OMRS-ENTERPRISE-REPOSITORY-400-001",
+ "Conflicting TypeDefs have been detected.",
+ "The system is unable to create a reliable list of TypeDefs for the enterprise.",
+ "Details of the conflicts and the steps necessary to repair the situation can be found in the audit log. " +
+ "Retry the request when the cohort configuration is correct."),
+ NO_TYPEDEFS_DEFINED(400, "OMRS-ENTERPRISE-REPOSITORY-400-002",
+ "No TypeDefs have been defined in any of the connected repositories.",
+ "The system is unable to create a list of TypeDefs for the enterprise.",
+ "Look for errors in the set up of the repositories in the audit log and verify that TypeDefs are configured. " +
+ "Retry the request when the cohort configuration is correct."),
+ REPOSITORY_NOT_AVAILABLE(404, "OMRS-REPOSITORY-CONNECTOR-404-001",
+ "The Open Metadata Repository Server is not available",
+ "The system is unable to retrieve any metadata properties from this repository.",
+ "Retry the request when the repository server is available."),
+ COHORT_NOT_CONNECTED(404, "OMRS-REPOSITORY-CONNECTOR-404-002",
+ "The Open Metadata Repository Servers in the cohort are not available",
+ "The system is unable to retrieve any metadata properties from this repository.",
+ "Retry the request when the repository server is available."),
+ INVALID_COHORT_CONFIG(404, "OMRS-REPOSITORY-CONNECTOR-404-003",
+ "The Open Metadata Repository Servers in the cohort are not configured correctly",
+ "The root cause of this error is recorded in previous exceptions.",
+ "Review the other error messages to determine the source of the error. When these are resolved, retry the request."),
+ LOCAL_REPOSITORY_CONFIGURATION_ERROR(404, "OMRS-REPOSITORY-CONNECTOR-404-004",
+ "The connection to the local Open Metadata Repository Server is not configured correctly",
+ "The root cause of this error is recorded in previous exceptions.",
+ "Review the other error messages to determine the source of the error. When these are resolved, retry the request."),
+ METADATA_HIGHWAY_NOT_AVAILABLE(404, "OMRS-METADATA-HIGHWAY-404-001",
+ "The local server's metadata highway communication components are failing to initialize",
+ "The root cause of this error is recorded in previous exceptions.",
+ "Review the other error messages to determine the source of the error. When these are resolved, retry the request."),
+ COHORT_DISCONNECT_FAILED(404, "OMRS-METADATA-HIGHWAY-404-002",
+ "The local server is unable to disconnect from an open metadata repository cohort {0}",
+ "The root cause of this error is recorded in previous exceptions.",
+ "Review the other error messages to determine the source of the error. When these are resolved, retry the request."),
+ TOPIC_CONNECTOR_NOT_AVAILABLE(404, "OMRS-TOPIC-CONNECTOR-404-001",
+ "The OMRS Topic Connector is not available.",
+ "The system is not able to process events sent between repositories in the open metadata cohort.",
+ "Correct the configuration for the OMRS Topic Connector (in the OMRS Configuration). Retry the request when the topic connector configuration is correct."),
+ ENTERPRISE_NOT_SUPPORTED(405, "OMRS-ENTERPRISE-REPOSITORY-CONNECTOR-405-001",
+ "The requested method {0} is not supported by the EnterpriseOMRSRepositoryConnector",
+ "The system is not able to process the requested method because it is not supported by the " +
+ "Open Metadata Repository Services (OMRS) Enterprise Repository Services.",
+ "Correct the application that called this method."),
+ INVALID_PRIMITIVE_CLASS_NAME(500, "OMRS-METADATA-COLLECTION-500-001",
+ "The Java class \'{0}\' for PrimitiveDefCategory {1} is not known.",
+ "There is an internal error in Java class PrimitiveDefCategory as it has been set up with an invalid class.",
+ "Raise a Jira to get this fixed."),
+ INVALID_PRIMITIVE_VALUE(500, "OMRS-METADATA-COLLECTION-500-002",
+ "The primitive value should be store in Java class \'{0}\' since it is of PrimitiveDefCategory {1}.",
+ "There is an internal error in the creation of a PrimitiveTypeValue.",
+ "Raise a Jira to get this fixed."),
+ NULL_HOME_METADATA_COLLECTION_ID(500, "OMRS-METADATA-COLLECTION-500-003",
+ "Null home metadata collection identifier found in metadata instance {0} from open metadata repository {1}",
+ "A request to retrieve a metadata instance (entity or relationship) has encountered a homeless metadata instance.",
+ "Locate the open metadata repository that supplied the instance and correct the logic in its OMRSRepositoryConnector."),
+ NULL_CONFIG(500, "OMRS-OPERATIONAL-SERVICES-500-001",
+ "No configuration has been passed to the Open Metadata Repository Services (OMRS) on initialization.",
+ "here is an internal error in the OMRS initialization.",
+ "Raise a Jira to get this fixed."),
+ NULL_METADATA_COLLECTION_ID(500, "OMRS-METADATA-COLLECTION-500-004",
+ "The local repository services have been initialized with a null metadata collection identifier.",
+ "There is an internal error in the OMRS initialization.",
+ "Raise a Jira to get this fixed."),
+ NULL_COHORT_NAME(500, "OMRS-COHORT-MANAGER-500-001",
+ "OMRSCohortManager has been initialized with a null cohort name",
+ "There is an internal error in the OMRS initialization.",
+ "Raise a Jira to get this fixed."),
+ NULL_LOCAL_METADATA_COLLECTION(500, "OMRS-LOCAL-REPOSITORY-500-001",
+ "The local repository services have been initialized with a null real metadata collection.",
+ "There is an internal error in the OMRS initialization.",
+ "Raise a Jira to get this fixed."),
+ NULL_ENTERPRISE_METADATA_COLLECTION(500, "OMRS-ENTERPRISE-REPOSITORY-500-001",
+ "The enterprise repository services has detected a repository connector with a null metadata collection.",
+ "There is an internal error in the Open Metadata Repository Services (OMRS) operation.",
+ "Raise a Jira to get this fixed."),
+ BAD_TYPEDEF(500, "OMRS-CONTENT-MANAGER-500-001",
+ "The repository content manager has detected an invalid TypeDef from {0}.",
+ "There is an internal error in the Open Metadata Repository Services (OMRS) operation.",
+ "Raise a Jira to get this fixed."),
+ BAD_TYPEDEF_ATTRIBUTE_NAME(500, "OMRS-CONTENT-MANAGER-500-002",
+ "The repository content manager has detected an invalid attribute name in a TypeDef from {0}.",
+ "There is an internal error in the Open Metadata Repository Services (OMRS) operation.",
+ "Raise a Jira to get this fixed."),
+ NULL_TYPEDEF_ATTRIBUTE(500, "OMRS-CONTENT-MANAGER-500-003",
+ "The repository content manager has detected a null attribute in a TypeDef from {0}.",
+ "There is an internal error in the Open Metadata Repository Services (OMRS) operation.",
+ "Raise a Jira to get this fixed."),
+ BAD_CATEGORY_FOR_TYPEDEF_ATTRIBUTE(500, "OMRS-CONTENT-MANAGER-500-004",
+ "Source {0} has requested type {1} with an incompatible category of {2} from repository content manager.",
+ "There is an error in the Open Metadata Repository Services (OMRS) operation - probably in the source component.",
+ "Raise a Jira to get this fixed."),
+ ARCHIVE_UNAVAILABLE(503, "OMRS-OPEN-METADATA-TYPES-500-001",
+ "The enterprise repository services are disconnected from the open metadata repositories.",
+ "There is an internal error in the OMRS initialization.",
+ "Raise a Jira to get this fixed."),
+ METHOD_NOT_IMPLEMENTED(501, "OMRS-METADATA-COLLECTION-501-001",
+ "OMRSMetadataCollection method {0} for OMRS Connector {1} to repository type {2} is not implemented.",
+ "A method in MetadataCollectionBase was called which means that the connector's OMRSMetadataCollection " +
+ "(a subclass of MetadataCollectionBase) does not have a complete implementation.",
+ "Raise a Jira to get this fixed."),
+ NO_REPOSITORIES(503, "OMRS-ENTERPRISE-REPOSITORY-503-001",
+ "There are no open metadata repositories available for this server.",
+ "The configuration for the server is set up so there is no local repository and no remote repositories " +
+ "connected through the open metadata repository cohorts. " +
+ "This may because of one or more configuration errors.",
+ "Retry the request once the configuration is changed."),
+ ENTERPRISE_DISCONNECTED(503, "OMRS-ENTERPRISE-REPOSITORY-503-002",
+ "The enterprise repository services are disconnected from the open metadata repositories.",
+ "The server has shutdown (or failed to set up) access to the open metadata repositories.",
+ "Retry the request once the open metadata repositories are connected."),
+ NULL_COHORT_METADATA_COLLECTION(503, "OMRS-ENTERPRISE-REPOSITORY-500-001",
+ "The enterprise repository services has detected a repository connector from cohort {0} for metadata collection identifier {1} that has a null metadata collection API object.",
+ "There is an internal error in the OMRS Repository Connector implementation.",
+ "Raise a Jira to get this fixed.")
+ ;
+
+ private int httpErrorCode;
+ private String errorMessageId;
+ private String errorMessage;
+ private String systemAction;
+ private String userAction;
+
+ private static final Logger log = LoggerFactory.getLogger(OMRSErrorCode.class);
+
+
+ /**
+ * The constructor for OMRSErrorCode expects to be passed one of the enumeration rows defined in
+ * OMRSErrorCode above. For example:
+ *
+ * OMRSErrorCode errorCode = OMRSErrorCode.SERVER_NOT_AVAILABLE;
+ *
+ * This will expand out to the 5 parameters shown below.
+ *
+ * @param newHTTPErrorCode - error code to use over REST calls
+ * @param newErrorMessageId - unique Id for the message
+ * @param newErrorMessage - text for the message
+ * @param newSystemAction - description of the action taken by the system when the error condition happened
+ * @param newUserAction - instructions for resolving the error
+ */
+ OMRSErrorCode(int newHTTPErrorCode, String newErrorMessageId, String newErrorMessage, String newSystemAction, String newUserAction)
+ {
+ this.httpErrorCode = newHTTPErrorCode;
+ this.errorMessageId = newErrorMessageId;
+ this.errorMessage = newErrorMessage;
+ this.systemAction = newSystemAction;
+ this.userAction = newUserAction;
+ }
+
+
+ public int getHTTPErrorCode()
+ {
+ return httpErrorCode;
+ }
+
+
+ /**
+ * Returns the unique identifier for the error message.
+ *
+ * @return errorMessageId
+ */
+ public String getErrorMessageId()
+ {
+ return errorMessageId;
+ }
+
+
+ /**
+ * Returns the error message with placeholders for specific details.
+ *
+ * @return errorMessage (unformatted)
+ */
+ public String getUnformattedErrorMessage()
+ {
+ return errorMessage;
+ }
+
+
+ /**
+ * Returns the error message with the placeholders filled out with the supplied parameters.
+ *
+ * @param params - strings that plug into the placeholders in the errorMessage
+ * @return errorMessage (formatted with supplied parameters)
+ */
+ public String getFormattedErrorMessage(String... params)
+ {
+ if (log.isDebugEnabled())
+ {
+ log.debug(String.format("<== OMRSErrorCode.getMessage(%s)", Arrays.toString(params)));
+ }
+
+ MessageFormat mf = new MessageFormat(errorMessage);
+ String result = mf.format(params);
+
+ if (log.isDebugEnabled())
+ {
+ log.debug(String.format("==> OMRSErrorCode.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
+ */
+ public String getSystemAction()
+ {
+ return systemAction;
+ }
+
+
+ /**
+ * Returns instructions of how to resolve the issue reported in this exception.
+ *
+ * @return userAction
+ */
+ public String getUserAction()
+ {
+ return userAction;
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/ffdc/README.md
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/ffdc/README.md b/omrs/src/main/java/org/apache/atlas/omrs/ffdc/README.md
new file mode 100644
index 0000000..c3bfabe
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/ffdc/README.md
@@ -0,0 +1,47 @@
+<!--
+ ~ 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
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ 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.
+ -->
+
+# Open Metadata Repository Services (OMRS) FFDC
+
+Package org.apache.atlas.omrs.ffdc provides the first failure data capture
+support for the OMRS module. This includes an error code enum,
+a runtime exception, a base class for checked exceptions plus
+implementation of each specific checked exception.
+
+The error code enum (OMRSErrorCode) has an entry for each unique situation
+where an exception is returned. Each entry defines:
+
+* A unique id for the error
+* An HTTP error code for rest calls
+* A unique message Id
+* Message text with place holders for specific values
+* A description of the cause of the error and system action as a result.
+* A description of how to correct the error (if known)
+
+Each exception (whether a checked or runtime exception) has two constructors.
+
+* The first constructor is used when a new error has been detected.
+
+* The second constructor is used when another exception has been caught.
+This caught exception is passed on the constructor so it is effectively
+embedded in the OMRS exception.
+
+Both constructors take the values from the OMRSErrorCode
+enum to define the cause and resolution. These values are passed
+as individual parameters so that subclasses implemented outside of
+the OMRS packages can define their own FFDC values.
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/ClassificationErrorException.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/ClassificationErrorException.java b/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/ClassificationErrorException.java
new file mode 100644
index 0000000..c6de62c
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/ClassificationErrorException.java
@@ -0,0 +1,57 @@
+/*
+ * 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.ffdc.exception;
+
+/**
+ * The ClassificationErrorException is thrown by an OMRS Connector when a classification for a specific entity
+ * instance is either not defined for this type of entity or is not currently attached to the requested entity.
+ */
+public class ClassificationErrorException extends OMRSCheckedExceptionBase
+{
+ /**
+ * This is the typical constructor used for creating a ClassificationErrorException.
+ *
+ * @param httpCode - http response code to use if this exception flows over a REST call
+ * @param className - name of class reporting error
+ * @param actionDescription - description of function it was performing when error detected
+ * @param errorMessage - description of error
+ * @param systemAction - actions of the system as a result of the error
+ * @param userAction - instructions for correcting the error
+ */
+ public ClassificationErrorException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction)
+ {
+ super(httpCode, className, actionDescription, errorMessage, systemAction, userAction);
+ }
+
+
+ /**
+ * This is the constructor used for creating a ClassificationErrorException that resulted from a previous error.
+ *
+ * @param httpCode - http response code to use if this exception flows over a REST call
+ * @param className - name of class reporting error
+ * @param actionDescription - description of function it was performing when error detected
+ * @param errorMessage - description of error
+ * @param systemAction - actions of the system as a result of the error
+ * @param userAction - instructions for correcting the error
+ * @param caughtError - the error that resulted in this exception.
+ * */
+ public ClassificationErrorException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction, Throwable caughtError)
+ {
+ super(httpCode, className, actionDescription, errorMessage, systemAction, userAction, caughtError);
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/EntityConflictException.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/EntityConflictException.java b/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/EntityConflictException.java
new file mode 100644
index 0000000..a8a3e20
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/EntityConflictException.java
@@ -0,0 +1,60 @@
+/*
+ * 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.ffdc.exception;
+
+/**
+ * EntityConflictException provides a checked exception for reporting that an entity can not be added because
+ * it conflicts with an entity already stored. The OMRSErrorCode adds specific details for the cause/effect of the error.
+ */
+public class EntityConflictException extends OMRSCheckedExceptionBase
+{
+ /**
+ * This is the typical constructor for creating an EntityConflictException. It captures the essential details
+ * about the error, where it occurred and how to fix it.
+ *
+ * @param httpCode code to use across a REST interface
+ * @param className name of class reporting error
+ * @param actionDescription description of function it was performing when error detected
+ * @param errorMessage description of error
+ * @param systemAction actions of the system as a result of the error
+ * @param userAction instructions for correcting the error
+ */
+ public EntityConflictException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction)
+ {
+ super(httpCode, className, actionDescription, errorMessage, systemAction, userAction);
+ }
+
+
+ /**
+ * This constructor is used when an unexpected exception has been caught that needs to be wrapped in an
+ * EntityConflictException in order to add the essential details about the error, where it occurred and
+ * how to fix it.
+ *
+ * @param httpCode code to use across a REST interface
+ * @param className name of class reporting error
+ * @param actionDescription description of function it was performing when error detected
+ * @param errorMessage description of error
+ * @param systemAction actions of the system as a result of the error
+ * @param userAction instructions for correcting the error
+ * @param caughtException the exception/error that caused this exception to be raised
+ */
+ public EntityConflictException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction, Throwable caughtException)
+ {
+ super(httpCode, className, actionDescription, errorMessage, systemAction, userAction, caughtException);
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/EntityNotDeletedException.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/EntityNotDeletedException.java b/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/EntityNotDeletedException.java
new file mode 100644
index 0000000..07f84aa
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/EntityNotDeletedException.java
@@ -0,0 +1,57 @@
+/*
+ * 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.ffdc.exception;
+
+/**
+ * EntityNotDeletedException is thrown by an OMRS Connector when a request is made to purge or restore a specific
+ * entity instance and the entity is not in DELETED status.
+ */
+public class EntityNotDeletedException extends OMRSCheckedExceptionBase
+{
+ /**
+ * This is the typical constructor used for creating a EntityNotDeletedException.
+ *
+ * @param httpCode - http response code to use if this exception flows over a REST call
+ * @param className - name of class reporting error
+ * @param actionDescription - description of function it was performing when error detected
+ * @param errorMessage - description of error
+ * @param systemAction - actions of the system as a result of the error
+ * @param userAction - instructions for correcting the error
+ */
+ public EntityNotDeletedException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction)
+ {
+ super(httpCode, className, actionDescription, errorMessage, systemAction, userAction);
+ }
+
+
+ /**
+ * This is the constructor used for creating a EntityNotDeletedException that resulted from a previous error.
+ *
+ * @param httpCode - http response code to use if this exception flows over a REST call
+ * @param className - name of class reporting error
+ * @param actionDescription - description of function it was performing when error detected
+ * @param errorMessage - description of error
+ * @param systemAction - actions of the system as a result of the error
+ * @param userAction - instructions for correcting the error
+ * @param caughtError - the error that resulted in this exception.
+ * */
+ public EntityNotDeletedException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction, Throwable caughtError)
+ {
+ super(httpCode, className, actionDescription, errorMessage, systemAction, userAction, caughtError);
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/EntityNotKnownException.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/EntityNotKnownException.java b/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/EntityNotKnownException.java
new file mode 100644
index 0000000..ea27b5b
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/EntityNotKnownException.java
@@ -0,0 +1,57 @@
+/*
+ * 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.ffdc.exception;
+
+/**
+ * The EntityNotKnownException is thrown by an OMRS Connector when a specific entity instance is requested but this
+ * entity is not known in the metadata collection.
+ */
+public class EntityNotKnownException extends OMRSCheckedExceptionBase
+{
+ /**
+ * This is the typical constructor used for creating an EntityNotKnownException.
+ *
+ * @param httpCode - http response code to use if this exception flows over a REST call
+ * @param className - name of class reporting error
+ * @param actionDescription - description of function it was performing when error detected
+ * @param errorMessage - description of error
+ * @param systemAction - actions of the system as a result of the error
+ * @param userAction - instructions for correcting the error
+ */
+ public EntityNotKnownException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction)
+ {
+ super(httpCode, className, actionDescription, errorMessage, systemAction, userAction);
+ }
+
+
+ /**
+ * This is the constructor used for creating an EntityNotKnownException that resulted from a previous error.
+ *
+ * @param httpCode - http response code to use if this exception flows over a REST call
+ * @param className - name of class reporting error
+ * @param actionDescription - description of function it was performing when error detected
+ * @param errorMessage - description of error
+ * @param systemAction - actions of the system as a result of the error
+ * @param userAction - instructions for correcting the error
+ * @param caughtError - the error that resulted in this exception.
+ * */
+ public EntityNotKnownException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction, Throwable caughtError)
+ {
+ super(httpCode, className, actionDescription, errorMessage, systemAction, userAction, caughtError);
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/HomeEntityException.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/HomeEntityException.java b/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/HomeEntityException.java
new file mode 100644
index 0000000..706e235
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/HomeEntityException.java
@@ -0,0 +1,57 @@
+/*
+ * 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.ffdc.exception;
+
+/**
+ * The HomeEntityException is thrown by an OMRS Connector when reference copy maintenance requests are issued on
+ * a home entity instance in the metadata collection.
+ */
+public class HomeEntityException extends OMRSCheckedExceptionBase
+{
+ /**
+ * This is the typical constructor used for creating a HomeEntityException.
+ *
+ * @param httpCode - http response code to use if this exception flows over a REST call
+ * @param className - name of class reporting error
+ * @param actionDescription - description of function it was performing when error detected
+ * @param errorMessage - description of error
+ * @param systemAction - actions of the system as a result of the error
+ * @param userAction - instructions for correcting the error
+ */
+ public HomeEntityException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction)
+ {
+ super(httpCode, className, actionDescription, errorMessage, systemAction, userAction);
+ }
+
+
+ /**
+ * This is the constructor used for creating an HomeEntityException that resulted from a previous error.
+ *
+ * @param httpCode - http response code to use if this exception flows over a REST call
+ * @param className - name of class reporting error
+ * @param actionDescription - description of function it was performing when error detected
+ * @param errorMessage - description of error
+ * @param systemAction - actions of the system as a result of the error
+ * @param userAction - instructions for correcting the error
+ * @param caughtError - the error that resulted in this exception.
+ * */
+ public HomeEntityException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction, Throwable caughtError)
+ {
+ super(httpCode, className, actionDescription, errorMessage, systemAction, userAction, caughtError);
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/HomeRelationshipException.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/HomeRelationshipException.java b/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/HomeRelationshipException.java
new file mode 100644
index 0000000..245ad91
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/HomeRelationshipException.java
@@ -0,0 +1,57 @@
+/*
+ * 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.ffdc.exception;
+
+/**
+ * The HomeRelationshipException is thrown by an OMRS Connector when reference copy maintenance requests are issued on
+ * a home relationship instance in the metadata collection.
+ */
+public class HomeRelationshipException extends OMRSCheckedExceptionBase
+{
+ /**
+ * This is the typical constructor used for creating an HomeRelationshipException.
+ *
+ * @param httpCode - http response code to use if this exception flows over a REST call
+ * @param className - name of class reporting error
+ * @param actionDescription - description of function it was performing when error detected
+ * @param errorMessage - description of error
+ * @param systemAction - actions of the system as a result of the error
+ * @param userAction - instructions for correcting the error
+ */
+ public HomeRelationshipException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction)
+ {
+ super(httpCode, className, actionDescription, errorMessage, systemAction, userAction);
+ }
+
+
+ /**
+ * This is the constructor used for creating an HomeRelationshipException that resulted from a previous error.
+ *
+ * @param httpCode - http response code to use if this exception flows over a REST call
+ * @param className - name of class reporting error
+ * @param actionDescription - description of function it was performing when error detected
+ * @param errorMessage - description of error
+ * @param systemAction - actions of the system as a result of the error
+ * @param userAction - instructions for correcting the error
+ * @param caughtError - the error that resulted in this exception.
+ * */
+ public HomeRelationshipException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction, Throwable caughtError)
+ {
+ super(httpCode, className, actionDescription, errorMessage, systemAction, userAction, caughtError);
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/InvalidEntityException.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/InvalidEntityException.java b/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/InvalidEntityException.java
new file mode 100644
index 0000000..8ce55af
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/InvalidEntityException.java
@@ -0,0 +1,60 @@
+/*
+ * 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.ffdc.exception;
+
+/**
+ * InvalidEntityException provides a checked exception for reporting that an entity can not be added because
+ * its content is invalid. The OMRSErrorCode adds specific details for the cause/effect of the error.
+ */
+public class InvalidEntityException extends OMRSCheckedExceptionBase
+{
+ /**
+ * This is the typical constructor for creating an InvalidEntityException. It captures the essential details
+ * about the error, where it occurred and how to fix it.
+ *
+ * @param httpCode code to use across a REST interface
+ * @param className name of class reporting error
+ * @param actionDescription description of function it was performing when error detected
+ * @param errorMessage description of error
+ * @param systemAction actions of the system as a result of the error
+ * @param userAction instructions for correcting the error
+ */
+ public InvalidEntityException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction)
+ {
+ super(httpCode, className, actionDescription, errorMessage, systemAction, userAction);
+ }
+
+
+ /**
+ * This constructor is used when an unexpected exception has been caught that needs to be wrapped in a
+ * InvalidEntityException in order to add the essential details about the error, where it occurred and
+ * how to fix it.
+ *
+ * @param httpCode code to use across a REST interface
+ * @param className name of class reporting error
+ * @param actionDescription description of function it was performing when error detected
+ * @param errorMessage description of error
+ * @param systemAction actions of the system as a result of the error
+ * @param userAction instructions for correcting the error
+ * @param caughtException the exception/error that caused this exception to be raised
+ */
+ public InvalidEntityException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction, Throwable caughtException)
+ {
+ super(httpCode, className, actionDescription, errorMessage, systemAction, userAction, caughtException);
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/InvalidParameterException.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/InvalidParameterException.java b/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/InvalidParameterException.java
new file mode 100644
index 0000000..56d0dd5
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/InvalidParameterException.java
@@ -0,0 +1,57 @@
+/*
+ * 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.ffdc.exception;
+
+/**
+ * The InvalidParameterException is thrown by an OMRS Connector when the parameters passed to a repository
+ * connector, or its accompanying metadata collection, are not valid.
+ */
+public class InvalidParameterException extends OMRSCheckedExceptionBase
+{
+ /**
+ * This is the typical constructor used for creating a InvalidParameterException.
+ *
+ * @param httpCode - http response code to use if this exception flows over a REST call
+ * @param className - name of class reporting error
+ * @param actionDescription - description of function it was performing when error detected
+ * @param errorMessage - description of error
+ * @param systemAction - actions of the system as a result of the error
+ * @param userAction - instructions for correcting the error
+ */
+ public InvalidParameterException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction)
+ {
+ super(httpCode, className, actionDescription, errorMessage, systemAction, userAction);
+ }
+
+
+ /**
+ * This is the constructor used for creating a InvalidParameterException that resulted from a previous error.
+ *
+ * @param httpCode - http response code to use if this exception flows over a REST call
+ * @param className - name of class reporting error
+ * @param actionDescription - description of function it was performing when error detected
+ * @param errorMessage - description of error
+ * @param systemAction - actions of the system as a result of the error
+ * @param userAction - instructions for correcting the error
+ * @param caughtError - the error that resulted in this exception.
+ * */
+ public InvalidParameterException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction, Throwable caughtError)
+ {
+ super(httpCode, className, actionDescription, errorMessage, systemAction, userAction, caughtError);
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/InvalidRelationshipException.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/InvalidRelationshipException.java b/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/InvalidRelationshipException.java
new file mode 100644
index 0000000..82879d1
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/InvalidRelationshipException.java
@@ -0,0 +1,60 @@
+/*
+ * 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.ffdc.exception;
+
+/**
+ * InvalidRelationshipException provides a checked exception for reporting that a relationship can not be added because
+ * its content is invalid. The OMRSErrorCode adds specific details for the cause/effect of the error.
+ */
+public class InvalidRelationshipException extends OMRSCheckedExceptionBase
+{
+ /**
+ * This is the typical constructor for creating an InvalidRelationshipException. It captures the essential details
+ * about the error, where it occurred and how to fix it.
+ *
+ * @param httpCode code to use across a REST interface
+ * @param className name of class reporting error
+ * @param actionDescription description of function it was performing when error detected
+ * @param errorMessage description of error
+ * @param systemAction actions of the system as a result of the error
+ * @param userAction instructions for correcting the error
+ */
+ public InvalidRelationshipException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction)
+ {
+ super(httpCode, className, actionDescription, errorMessage, systemAction, userAction);
+ }
+
+
+ /**
+ * This constructor is used when an unexpected exception has been caught that needs to be wrapped in a
+ * InvalidRelationshipException in order to add the essential details about the error, where it occurred and
+ * how to fix it.
+ *
+ * @param httpCode code to use across a REST interface
+ * @param className name of class reporting error
+ * @param actionDescription description of function it was performing when error detected
+ * @param errorMessage description of error
+ * @param systemAction actions of the system as a result of the error
+ * @param userAction instructions for correcting the error
+ * @param caughtException the exception/error that caused this exception to be raised
+ */
+ public InvalidRelationshipException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction, Throwable caughtException)
+ {
+ super(httpCode, className, actionDescription, errorMessage, systemAction, userAction, caughtException);
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/InvalidTypeDefException.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/InvalidTypeDefException.java b/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/InvalidTypeDefException.java
new file mode 100644
index 0000000..60ee27f
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/InvalidTypeDefException.java
@@ -0,0 +1,60 @@
+/*
+ * 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.ffdc.exception;
+
+/**
+ * InvalidTypeDefException provides a checked exception for reporting that a typedef can not be added because
+ * its content is invalid. The OMRSErrorCode adds specific details for the cause/effect of the error.
+ */
+public class InvalidTypeDefException extends OMRSCheckedExceptionBase
+{
+ /**
+ * This is the typical constructor for creating an InvalidTypeDefException. It captures the essential details
+ * about the error, where it occurred and how to fix it.
+ *
+ * @param httpCode code to use across a REST interface
+ * @param className name of class reporting error
+ * @param actionDescription description of function it was performing when error detected
+ * @param errorMessage description of error
+ * @param systemAction actions of the system as a result of the error
+ * @param userAction instructions for correcting the error
+ */
+ public InvalidTypeDefException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction)
+ {
+ super(httpCode, className, actionDescription, errorMessage, systemAction, userAction);
+ }
+
+
+ /**
+ * This constructor is used when an unexpected exception has been caught that needs to be wrapped in a
+ * InvalidTypeDefException in order to add the essential details about the error, where it occurred and
+ * how to fix it.
+ *
+ * @param httpCode code to use across a REST interface
+ * @param className name of class reporting error
+ * @param actionDescription description of function it was performing when error detected
+ * @param errorMessage description of error
+ * @param systemAction actions of the system as a result of the error
+ * @param userAction instructions for correcting the error
+ * @param caughtException the exception/error that caused this exception to be raised
+ */
+ public InvalidTypeDefException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction, Throwable caughtException)
+ {
+ super(httpCode, className, actionDescription, errorMessage, systemAction, userAction, caughtException);
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/NotImplementedRuntimeException.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/NotImplementedRuntimeException.java b/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/NotImplementedRuntimeException.java
new file mode 100644
index 0000000..e271055
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/NotImplementedRuntimeException.java
@@ -0,0 +1,32 @@
+/*
+ * 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.ffdc.exception;
+
+/**
+ * This exception is used to mark methods in the code that are not yet implemented. The JIRA where the implementation
+ * is being tracked is included in the message.
+ */
+public class NotImplementedRuntimeException extends RuntimeException
+{
+ public NotImplementedRuntimeException(String className,
+ String methodName,
+ String jiraName)
+ {
+ super("Method " + methodName + " in class " + className + " is not yet implemented. Refer to JIRA " + jiraName );
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/OMRSCheckedExceptionBase.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/OMRSCheckedExceptionBase.java b/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/OMRSCheckedExceptionBase.java
new file mode 100644
index 0000000..7409ead
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/OMRSCheckedExceptionBase.java
@@ -0,0 +1,161 @@
+/*
+ * 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.ffdc.exception;
+
+/**
+ * OMRSCheckedExceptionBase provides a checked exception for reporting errors found when using the OMRS.
+ * Typically these errors are either configuration or operational errors that can be fixed by an administrator
+ * or power user. However, there may be the odd bug that surfaces here. The OMRSErrorCode can be used with
+ * this exception to populate it with standard messages. Otherwise messages defined uniquely for a
+ * ConnectorProvider/Connector implementation can be used. The aim is to be able to uniquely identify the cause
+ * and remedy for the error.
+ */
+public class OMRSCheckedExceptionBase extends Exception
+{
+ /*
+ * These default values are only seen if this exception is initialized using one of its superclass constructors.
+ */
+ private int reportedHTTPCode = 500;
+ private String reportingClassName = "<Unknown>";
+ private String reportingActionDescription = "<Unknown>";
+ private String reportedErrorMessage = "<Unknown>";
+ private String reportedSystemAction = "<Unknown>";
+ private String reportedUserAction = "<Unknown>";
+ private Throwable reportedCaughtException = null;
+
+
+ /**
+ * This is the typical constructor used for creating a OMRSCheckedExceptionBase.
+ *
+ * @param httpCode - http response code to use if this exception flows over a REST call
+ * @param className - name of class reporting error
+ * @param actionDescription - description of function it was performing when error detected
+ * @param errorMessage - description of error
+ * @param systemAction - actions of the system as a result of the error
+ * @param userAction - instructions for correcting the error
+ */
+ public OMRSCheckedExceptionBase(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction)
+ {
+ super(errorMessage);
+ this.reportedHTTPCode = httpCode;
+ this.reportingClassName = className;
+ this.reportingActionDescription = actionDescription;
+ this.reportedErrorMessage = errorMessage;
+ this.reportedSystemAction = systemAction;
+ this.reportedUserAction = userAction;
+ }
+
+
+ /**
+ * This is the constructor used for creating a OMRSCheckedExceptionBase when an unexpected error has been caught.
+ *
+ * @param httpCode - http response code to use if this exception flows over a rest call
+ * @param className - name of class reporting error
+ * @param actionDescription - description of function it was performing when error detected
+ * @param errorMessage - description of error
+ * @param systemAction - actions of the system as a result of the error
+ * @param userAction - instructions for correcting the error
+ * @param caughtError - previous error causing this exception
+ */
+ public OMRSCheckedExceptionBase(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction, Throwable caughtError)
+ {
+ super(errorMessage, caughtError);
+ this.reportedHTTPCode = httpCode;
+ this.reportingClassName = className;
+ this.reportingActionDescription = actionDescription;
+ this.reportedErrorMessage = errorMessage;
+ this.reportedSystemAction = systemAction;
+ this.reportedUserAction = userAction;
+ this.reportedCaughtException = caughtError;
+ }
+
+
+ /**
+ * Return the HTTP response code to use with this exception.
+ *
+ * @return reportedHTTPCode
+ */
+ public int getReportedHTTPCode()
+ {
+ return reportedHTTPCode;
+ }
+
+ /**
+ * The class that created this exception.
+ *
+ * @return reportingClassName
+ */
+ public String getReportingClassName()
+ {
+ return reportingClassName;
+ }
+
+
+ /**
+ * The type of request that the class was performing when the condition occurred that resulted in this
+ * exception.
+ *
+ * @return reportingActionDescription
+ */
+ public String getReportingActionDescription()
+ {
+ return reportingActionDescription;
+ }
+
+
+ /**
+ * A formatted short description of the cause of the condition that resulted in this exception.
+ *
+ * @return reportedErrorMessage
+ */
+ public String getErrorMessage()
+ {
+ return reportedErrorMessage;
+ }
+
+
+ /**
+ * A description of the action that the system took as a result of the error condition.
+ *
+ * @return reportedSystemAction
+ */
+ public String getReportedSystemAction()
+ {
+ return reportedSystemAction;
+ }
+
+
+ /**
+ * A description of the action necessary to correct the error.
+ *
+ * @return reportedUserAction
+ */
+ public String getReportedUserAction()
+ {
+ return reportedUserAction;
+ }
+
+
+ /**
+ * An exception that was caught and wrapped by this exception. If a null is returned, then this exception is
+ * newly created and not the result of a previous exception.
+ *
+ * @return reportedCaughtException
+ */
+ public Throwable getReportedCaughtException() { return reportedCaughtException; }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/OMRSConfigErrorException.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/OMRSConfigErrorException.java b/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/OMRSConfigErrorException.java
new file mode 100644
index 0000000..1488a5f
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/ffdc/exception/OMRSConfigErrorException.java
@@ -0,0 +1,185 @@
+/*
+ * 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.ffdc.exception;
+
+/**
+ * OMRSConfigErrorException is used for all runtime exceptions generated by the Open Metadata Repository Services (OMRS)
+ * components that indicate a configuration error.
+ * It is used in conjunction with the OMRSErrorCode to provide first failure data capture for these errors.
+ */
+public class OMRSConfigErrorException extends OMRSRuntimeException
+{
+ /*
+ * These default values are only seen if this exception is initialized using one of its superclass constructors.
+ */
+ private int reportedHTTPCode = 500;
+ private String reportingClassName = "<Unknown>";
+ private String reportingActionDescription = "<Unknown>";
+ private String reportedErrorMessage = "<Unknown>";
+ private String reportedSystemAction = "<Unknown>";
+ private String reportedUserAction = "<Unknown>";
+ private Throwable [] reportedCaughtExceptions = null;
+
+
+ /**
+ * This is the typical constructor used for creating an OMRSConfigErrorException.
+ *
+ * @param httpCode - http response code to use if this exception flows over a REST call
+ * @param className - name of class reporting error
+ * @param actionDescription - description of function it was performing when error detected
+ * @param errorMessage - description of error
+ * @param systemAction - actions of the system as a result of the error
+ * @param userAction - instructions for correcting the error
+ */
+ public OMRSConfigErrorException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction)
+ {
+ super(httpCode, className, actionDescription, errorMessage, systemAction, userAction);
+
+ this.reportedHTTPCode = httpCode;
+ this.reportingClassName = className;
+ this.reportingActionDescription = actionDescription;
+ this.reportedErrorMessage = errorMessage;
+ this.reportedSystemAction = systemAction;
+ this.reportedUserAction = userAction;
+ }
+
+
+ /**
+ * This is the constructor used for creating a OMRSConfigErrorException when an unexpected exception has been caught.
+ *
+ * @param httpCode - http response code to use if this exception flows over a REST call
+ * @param className - name of class reporting error
+ * @param actionDescription - description of function it was performing when error detected
+ * @param errorMessage - description of error
+ * @param systemAction - actions of the system as a result of the error
+ * @param userAction - instructions for correcting the error
+ * @param caughtError - previous error causing this exception
+ */
+ public OMRSConfigErrorException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction, Throwable caughtError)
+ {
+ super(httpCode, className, actionDescription, errorMessage, systemAction, userAction, caughtError);
+
+ this.reportedHTTPCode = httpCode;
+ this.reportingClassName = className;
+ this.reportingActionDescription = actionDescription;
+ this.reportedErrorMessage = errorMessage;
+ this.reportedSystemAction = systemAction;
+ this.reportedUserAction = userAction;
+ this.reportedCaughtExceptions = new Throwable[1];
+ this.reportedCaughtExceptions[0] = caughtError;
+ }
+
+ /**
+ * This is the constructor used for creating a OMRSConfigErrorException when multiple unexpected errors
+ * have been caught.
+ *
+ * @param httpCode - http response code to use if this exception flows over a rest call
+ * @param className - name of class reporting error
+ * @param actionDescription - description of function it was performing when error detected
+ * @param errorMessage - description of error
+ * @param systemAction - actions of the system as a result of the error
+ * @param userAction - instructions for correcting the error
+ * @param caughtErrors - previous errors causing this exception
+ */
+ public OMRSConfigErrorException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction, Throwable[] caughtErrors)
+ {
+ super(httpCode, className, actionDescription, errorMessage, systemAction, userAction, caughtErrors);
+
+ this.reportedHTTPCode = httpCode;
+ this.reportingClassName = className;
+ this.reportingActionDescription = actionDescription;
+ this.reportedErrorMessage = errorMessage;
+ this.reportedSystemAction = systemAction;
+ this.reportedUserAction = userAction;
+ this.reportedCaughtExceptions = caughtErrors;
+ }
+
+ /**
+ * Return the HTTP response code to use with this exception.
+ *
+ * @return reportedHTTPCode
+ */
+ public int getReportedHTTPCode()
+ {
+ return reportedHTTPCode;
+ }
+
+ /**
+ * The class that created this exception.
+ *
+ * @return reportingClassName
+ */
+ public String getReportingClassName()
+ {
+ return reportingClassName;
+ }
+
+
+ /**
+ * The type of request that the class was performing when the condition occurred that resulted in this
+ * exception.
+ *
+ * @return reportingActionDescription
+ */
+ public String getReportingActionDescription()
+ {
+ return reportingActionDescription;
+ }
+
+
+ /**
+ * A formatted short description of the cause of the condition that resulted in this exception.
+ *
+ * @return reportedErrorMessage
+ */
+ public String getErrorMessage()
+ {
+ return reportedErrorMessage;
+ }
+
+
+ /**
+ * A description of the action that the system took as a result of the error condition.
+ *
+ * @return reportedSystemAction
+ */
+ public String getReportedSystemAction()
+ {
+ return reportedSystemAction;
+ }
+
+
+ /**
+ * A description of the action necessary to correct the error.
+ *
+ * @return reportedUserAction
+ */
+ public String getReportedUserAction()
+ {
+ return reportedUserAction;
+ }
+
+
+ /**
+ * An exception that was caught and wrapped by this exception. If a null is returned, then this exception is
+ * newly created and not the result of a previous exception.
+ *
+ * @return reportedCaughtException
+ */
+ public Throwable[] getReportedCaughtExceptions() { return reportedCaughtExceptions; }
+}
[16/30] atlas git commit: ATLAS-2246: OMRS Connector API plus REST
and IGC Connector skeleton - 15th February 2018
Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSTypeDefEvent.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSTypeDefEvent.java b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSTypeDefEvent.java
new file mode 100644
index 0000000..c12752a
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSTypeDefEvent.java
@@ -0,0 +1,453 @@
+/*
+ * 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.OMRSEventV1TypeDefSection;
+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 org.apache.atlas.omrs.metadatacollection.properties.typedefs.TypeDefSummary;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+public class OMRSTypeDefEvent extends OMRSEvent
+{
+ /*
+ * The type of the TypeDef event that defines how the rest of the values should be interpreted.
+ */
+ private OMRSTypeDefEventType typeDefEventType = OMRSTypeDefEventType.UNKNOWN_TYPEDEF_EVENT;
+
+ /*
+ * TypeDef specific properties.
+ */
+ private AttributeTypeDef attributeTypeDef = null;
+ private TypeDef typeDef = null;
+ private String typeDefGUID = null;
+ private String typeDefName = null;
+ private TypeDefPatch typeDefPatch = null;
+
+ /*
+ * TypeDef specific properties for events related to correcting conflicts in the open metadata repository
+ * cohort.
+ */
+ private TypeDefSummary originalTypeDefSummary = null;
+ private AttributeTypeDef originalAttributeTypeDef = null;
+
+ /*
+ * Specific variables only used in error reporting. It defines the subset of error codes from OMRSEvent
+ * that are specific to TypeDef events.
+ */
+ private OMRSTypeDefEventErrorCode errorCode = OMRSTypeDefEventErrorCode.NOT_IN_USE;
+
+
+ private static final Logger log = LoggerFactory.getLogger(OMRSTypeDefEvent.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.
+ */
+ public OMRSTypeDefEvent(OMRSEventV1 inboundEvent)
+ {
+ super(inboundEvent);
+
+ OMRSEventV1TypeDefSection typeDefSection = inboundEvent.getTypeDefEventSection();
+
+ if (typeDefSection != null)
+ {
+ this.typeDefEventType = typeDefSection.getTypeDefEventType();
+ this.attributeTypeDef = typeDefSection.getAttributeTypeDef();
+ this.typeDef = typeDefSection.getTypeDef();
+ this.typeDefGUID = typeDefSection.getTypeDefGUID();
+ this.typeDefName = typeDefSection.getTypeDefName();
+ this.typeDefPatch = typeDefSection.getTypeDefPatch();
+ this.originalTypeDefSummary = typeDefSection.getOriginalTypeDefSummary();
+ this.originalAttributeTypeDef = typeDefSection.getOriginalAttributeTypeDef();
+ }
+
+ if (super.genericErrorCode != null)
+ {
+ switch(genericErrorCode)
+ {
+ case CONFLICTING_TYPEDEFS:
+ errorCode = OMRSTypeDefEventErrorCode.CONFLICTING_TYPEDEFS;
+ break;
+
+ case CONFLICTING_ATTRIBUTE_TYPEDEFS:
+ errorCode = OMRSTypeDefEventErrorCode.CONFLICTING_ATTRIBUTE_TYPEDEFS;
+
+ case TYPEDEF_PATCH_MISMATCH:
+ errorCode = OMRSTypeDefEventErrorCode.TYPEDEF_PATCH_MISMATCH;
+ break;
+
+ default:
+ errorCode = OMRSTypeDefEventErrorCode.UNKNOWN_ERROR_CODE;
+ break;
+ }
+ }
+ }
+
+ /**
+ * Outbound event constructor for events such as newTypeDef.
+ *
+ * @param typeDefEventType - type of event
+ * @param typeDef - Complete details of the TypeDef that is the subject of the event.
+ */
+ public OMRSTypeDefEvent(OMRSTypeDefEventType typeDefEventType,
+ TypeDef typeDef)
+ {
+ super(OMRSEventCategory.TYPEDEF);
+
+ this.typeDefEventType = typeDefEventType;
+ this.typeDef = typeDef;
+ }
+
+
+ /**
+ * Outbound event constructor for events such as newAttributeTypeDef.
+ *
+ * @param typeDefEventType - type of event
+ * @param attributeTypeDef - Complete details of the AttributeTypeDef that is the subject of the event.
+ */
+ public OMRSTypeDefEvent(OMRSTypeDefEventType typeDefEventType,
+ AttributeTypeDef attributeTypeDef)
+ {
+ super(OMRSEventCategory.TYPEDEF);
+
+ this.typeDefEventType = typeDefEventType;
+ this.attributeTypeDef = attributeTypeDef;
+ }
+
+
+ /**
+ * Outbound event constructor for events such as updates.
+ *
+ * @param typeDefEventType - type of event
+ * @param typeDefPatch - Complete details of the TypeDef that is the subject of the event.
+ */
+ public OMRSTypeDefEvent(OMRSTypeDefEventType typeDefEventType,
+ TypeDefPatch typeDefPatch)
+ {
+ super(OMRSEventCategory.TYPEDEF);
+
+ this.typeDefEventType = typeDefEventType;
+ this.typeDefPatch = typeDefPatch;
+ }
+
+
+ /**
+ * Outbound event constructor for events such as deletes.
+ *
+ * @param typeDefEventType - type of event
+ * @param typeDefGUID - Unique identifier of the TypeDef that is the subject of the event.
+ * @param typeDefName - Unique name of the TypeDef that is the subject of the event.
+ */
+ public OMRSTypeDefEvent(OMRSTypeDefEventType typeDefEventType,
+ String typeDefGUID,
+ String typeDefName)
+ {
+ super(OMRSEventCategory.TYPEDEF);
+
+ this.typeDefEventType = typeDefEventType;
+ this.typeDefGUID = typeDefGUID;
+ this.typeDefName = typeDefName;
+ }
+
+
+ /**
+ * Outbound event constructor for changing the identifiers associated with TypeDefs.
+ *
+ * @param typeDefEventType - type of event
+ * @param originalTypeDefSummary - description of the original TypeDef that is the subject of the event.
+ * @param typeDef - updated TypeDef with new identifiers
+ */
+ public OMRSTypeDefEvent(OMRSTypeDefEventType typeDefEventType,
+ TypeDefSummary originalTypeDefSummary,
+ TypeDef typeDef)
+ {
+ super(OMRSEventCategory.TYPEDEF);
+
+ this.typeDefEventType = typeDefEventType;
+ this.originalTypeDefSummary = originalTypeDefSummary;
+ this.typeDef = typeDef;
+ }
+
+
+ /**
+ * Outbound event constructor for changing the identifiers associated with AttributeTypeDefs.
+ *
+ * @param typeDefEventType - type of event
+ * @param originalAttributeTypeDef - description of the original AttributeTypeDef that is the subject of the event.
+ * @param attributeTypeDef - updated AttributeTypeDef with new identifiers
+ */
+ public OMRSTypeDefEvent(OMRSTypeDefEventType typeDefEventType,
+ AttributeTypeDef originalAttributeTypeDef,
+ AttributeTypeDef attributeTypeDef)
+ {
+ super(OMRSEventCategory.TYPEDEF);
+
+ this.typeDefEventType = typeDefEventType;
+ this.originalAttributeTypeDef = originalAttributeTypeDef;
+ this.attributeTypeDef = attributeTypeDef;
+ }
+
+
+ /**
+ * Outbound event constructor for conflicting typedef errors.
+ *
+ * @param errorCode - code enum indicating the cause of the error.
+ * @param errorMessage - descriptive message about the error.
+ * @param targetMetadataCollectionId - identifier of the cohort member that issued the event in error.
+ * @param targetTypeDefSummary - details of the TypeDef in the remote repository.
+ * @param otherTypeDefSummary - details of the TypeDef in the local repository.
+ */
+ public OMRSTypeDefEvent(OMRSTypeDefEventErrorCode errorCode,
+ String errorMessage,
+ String targetMetadataCollectionId,
+ TypeDefSummary targetTypeDefSummary,
+ TypeDefSummary otherTypeDefSummary)
+ {
+ super(OMRSEventCategory.TYPEDEF,
+ errorCode.getErrorCodeEncoding(),
+ errorMessage,
+ targetMetadataCollectionId,
+ targetTypeDefSummary,
+ otherTypeDefSummary);
+
+ this.typeDefEventType = OMRSTypeDefEventType.TYPEDEF_ERROR_EVENT;
+ }
+
+
+ /**
+ * Outbound event constructor for conflicting attribute typedef errors.
+ *
+ * @param errorCode - code enum indicating the cause of the error.
+ * @param errorMessage - descriptive message about the error.
+ * @param targetMetadataCollectionId - identifier of the cohort member that issued the event in error.
+ * @param targetAttributeTypeDef - details of the TypeDef in the remote repository.
+ * @param otherAttributeTypeDef - details of the TypeDef in the local repository.
+ */
+ public OMRSTypeDefEvent(OMRSTypeDefEventErrorCode errorCode,
+ String errorMessage,
+ String targetMetadataCollectionId,
+ AttributeTypeDef targetAttributeTypeDef,
+ AttributeTypeDef otherAttributeTypeDef)
+ {
+ super(OMRSEventCategory.TYPEDEF,
+ errorCode.getErrorCodeEncoding(),
+ errorMessage,
+ targetMetadataCollectionId,
+ targetAttributeTypeDef,
+ targetAttributeTypeDef);
+
+ this.typeDefEventType = OMRSTypeDefEventType.TYPEDEF_ERROR_EVENT;
+ }
+
+
+
+ /**
+ * Outbound event constructor for typedef mismatch errors.
+ *
+ * @param errorCode - code enum indicating the cause of the error.
+ * @param errorMessage - descriptive message about the error.
+ * @param targetMetadataCollectionId - identifier of the cohort member that issued the event in error.
+ * @param targetTypeDefSummary - details of the TypeDef in the remote repository.
+ * @param otherTypeDef - details of the TypeDef in the local repository.
+ */
+ public OMRSTypeDefEvent(OMRSTypeDefEventErrorCode errorCode,
+ String errorMessage,
+ String targetMetadataCollectionId,
+ TypeDefSummary targetTypeDefSummary,
+ TypeDef otherTypeDef)
+ {
+ super(OMRSEventCategory.TYPEDEF,
+ errorCode.getErrorCodeEncoding(),
+ errorMessage,
+ targetMetadataCollectionId,
+ targetTypeDefSummary,
+ otherTypeDef);
+
+ this.typeDefEventType = OMRSTypeDefEventType.TYPEDEF_ERROR_EVENT;
+ }
+
+
+ /**
+ * Return the code for this event's type.
+ *
+ * @return OMRSTypeDefEventType enum
+ */
+ public OMRSTypeDefEventType getTypeDefEventType()
+ {
+ return typeDefEventType;
+ }
+
+
+ /**
+ * Return the complete TypeDef object.
+ *
+ * @return TypeDef object
+ */
+ public TypeDef getTypeDef()
+ {
+ return typeDef;
+ }
+
+
+ /**
+ * Return the complete AttributeTypeDef object.
+ *
+ * @return AttributeTypeDef object
+ */
+ public AttributeTypeDef getAttributeTypeDef()
+ {
+ return attributeTypeDef;
+ }
+
+ /**
+ * Return the unique id of the TypeDef.
+ *
+ * @return String guid
+ */
+ public String getTypeDefGUID()
+ {
+ return typeDefGUID;
+ }
+
+
+ /**
+ * Return the unique name of the TypeDef.
+ *
+ * @return String name
+ */
+ public String getTypeDefName()
+ {
+ return typeDefName;
+ }
+
+
+ /**
+ * Return a patch for the TypeDef.
+ *
+ * @return TypeDefPatch object
+ */
+ public TypeDefPatch getTypeDefPatch()
+ {
+ return typeDefPatch;
+ }
+
+
+ /**
+ * Return the details of the TypeDef before it was changed.
+ *
+ * @return TypeDefSummary containing identifiers, category and version
+ */
+ public TypeDefSummary getOriginalTypeDefSummary()
+ {
+ return originalTypeDefSummary;
+ }
+
+
+ /**
+ * Return the details of the AttributeTypeDef before it was changed.
+ *
+ * @return AttributeTypeDef object
+ */
+ public AttributeTypeDef getOriginalAttributeTypeDef()
+ {
+ return originalAttributeTypeDef;
+ }
+
+ /**
+ * Return the TypeDef error code for error events.
+ *
+ * @return OMRSTypeDefEventErrorCode enum
+ */
+ public OMRSTypeDefEventErrorCode getErrorCode()
+ {
+ return errorCode;
+ }
+
+
+ /**
+ * Returns an OMRSEvent populated with details from this TypeDefEvent
+ *
+ * @return OMRSEvent (Version 1) object
+ */
+ public OMRSEventV1 getOMRSEventV1()
+ {
+ OMRSEventV1 omrsEvent = super.getOMRSEventV1();
+
+ OMRSEventV1TypeDefSection typeDefSection = new OMRSEventV1TypeDefSection();
+
+ typeDefSection.setTypeDefEventType(this.typeDefEventType);
+ typeDefSection.setTypeDef(this.typeDef);
+ typeDefSection.setAttributeTypeDef(this.attributeTypeDef);
+ typeDefSection.setTypeDefPatch(this.typeDefPatch);
+ typeDefSection.setTypeDefGUID(this.typeDefGUID);
+ typeDefSection.setTypeDefName(this.typeDefName);
+ typeDefSection.setOriginalTypeDefSummary(this.originalTypeDefSummary);
+ typeDefSection.setOriginalAttributeTypeDef(this.originalAttributeTypeDef);
+
+ omrsEvent.setTypeDefEventSection(typeDefSection);
+
+ return omrsEvent;
+ }
+
+
+ /**
+ * Standard toString method.
+ *
+ * @return JSON style description of variables.
+ */
+ @Override
+ public String toString()
+ {
+ return "OMRSTypeDefEvent{" +
+ "typeDefEventType=" + typeDefEventType +
+ ", attributeTypeDef=" + attributeTypeDef +
+ ", typeDef=" + typeDef +
+ ", typeDefGUID='" + typeDefGUID + '\'' +
+ ", typeDefName='" + typeDefName + '\'' +
+ ", typeDefPatch=" + typeDefPatch +
+ ", originalTypeDefSummary=" + originalTypeDefSummary +
+ ", originalAttributeTypeDef=" + originalAttributeTypeDef +
+ ", 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/OMRSTypeDefEventErrorCode.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSTypeDefEventErrorCode.java b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSTypeDefEventErrorCode.java
new file mode 100644
index 0000000..fd36108
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSTypeDefEventErrorCode.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.eventmanagement.events;
+
+import org.apache.atlas.omrs.eventmanagement.events.OMRSEventErrorCode;
+
+/**
+ * OMRSTypeDefEventErrorCode defines the list of error codes that are used to record errors in the TypeDef
+ * synchronization 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 OMRSTypeDefEventErrorCode
+{
+ NOT_IN_USE (0, "No Error",
+ "There has been no error detected and so the error code is not in use.",
+ null),
+ CONFLICTING_TYPEDEFS (1, "ConflictingTypeDefs",
+ "There are conflicting type definitions (TypeDefs) detected between two " +
+ "repositories in the open metadata repository cohort.",
+ OMRSEventErrorCode.CONFLICTING_TYPEDEFS),
+ CONFLICTING_ATTRIBUTE_TYPEDEFS (2, "ConflictingAttributeTypeDefs",
+ "There are conflicting attribute type definitions (AttributeTypeDefs) detected between two " +
+ "repositories in the open metadata repository cohort.",
+ OMRSEventErrorCode.CONFLICTING_ATTRIBUTE_TYPEDEFS),
+ TYPEDEF_PATCH_MISMATCH (3, "TypeDefPatchMismatch",
+ "There are different versions of a TypeDef in use in the cohort",
+ OMRSEventErrorCode.TYPEDEF_PATCH_MISMATCH),
+ 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
+ */
+ OMRSTypeDefEventErrorCode(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
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSTypeDefEventProcessor.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSTypeDefEventProcessor.java b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSTypeDefEventProcessor.java
new file mode 100644
index 0000000..7cb2338
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSTypeDefEventProcessor.java
@@ -0,0 +1,262 @@
+/*
+ * 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.metadatacollection.properties.typedefs.AttributeTypeDef;
+import org.apache.atlas.omrs.metadatacollection.properties.typedefs.TypeDef;
+import org.apache.atlas.omrs.metadatacollection.properties.typedefs.TypeDefPatch;
+import org.apache.atlas.omrs.metadatacollection.properties.typedefs.TypeDefSummary;
+
+/**
+ * OMRSTypeDefEventProcessor is an interface implemented by a component that is able to process incoming
+ * TypeDef events for an Open Metadata Repository. TypeDef events are used to synchronize TypeDefs across
+ * an Open Metadata Repository Cohort.
+ */
+public interface OMRSTypeDefEventProcessor
+{
+ /**
+ * A new TypeDef has been defined in an open metadata repository.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param typeDef - details of the new TypeDef.
+ */
+ void processNewTypeDefEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ TypeDef typeDef);
+
+
+ /**
+ * A new AttributeTypeDef has been defined in an open metadata repository.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param attributeTypeDef - details of the new AttributeTypeDef.
+ */
+ void processNewAttributeTypeDefEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ AttributeTypeDef attributeTypeDef);
+
+
+ /**
+ * An existing TypeDef has been updated in an open metadata repository.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param typeDefPatch - details of the new version of the TypeDef
+ */
+ void processUpdatedTypeDefEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ TypeDefPatch typeDefPatch);
+
+
+ /**
+ * An existing TypeDef has been deleted in an open metadata repository. Both the name and the
+ * GUID are provided to ensure the right TypeDef is deleted in other cohort member repositories.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param typeDefGUID - unique identifier of the TypeDef
+ * @param typeDefName - unique name of the TypeDef
+ */
+ void processDeletedTypeDefEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ String typeDefGUID,
+ String typeDefName);
+
+
+ /**
+ * An existing AttributeTypeDef has been deleted in an open metadata repository. Both the name and the
+ * GUID are provided to ensure the right AttributeTypeDef is deleted in other cohort member repositories.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param attributeTypeDefGUID - unique identifier of the AttributeTypeDef
+ * @param attributeTypeDefName - unique name of the AttributeTypeDef
+ */
+ void processDeletedAttributeTypeDefEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ String attributeTypeDefGUID,
+ String attributeTypeDefName);
+
+
+ /**
+ * Process an event that changes either the name or guid of a TypeDef. It is resolving a Conflicting TypeDef Error.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param originalTypeDef - description of original TypeDef
+ * @param typeDef - updated TypeDef with new identifiers inside.
+ */
+ void processReIdentifiedTypeDefEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ TypeDefSummary originalTypeDef,
+ TypeDef typeDef);
+
+
+ /**
+ * Process an event that changes either the name or guid of an AttributeTypeDef.
+ * It is resolving a Conflicting AttributeTypeDef Error.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param originalAttributeTypeDef - description of original AttributeTypeDef
+ * @param attributeTypeDef - updated AttributeTypeDef with new identifiers inside.
+ */
+ void processReIdentifiedAttributeTypeDefEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ AttributeTypeDef originalAttributeTypeDef,
+ AttributeTypeDef attributeTypeDef);
+
+
+ /**
+ * Process a detected conflict in the type definitions (TypeDefs) used in the cohort.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param originatorTypeDef- description of the TypeDef in the event originator.
+ * @param otherMetadataCollectionId - the metadataCollection using the conflicting TypeDef.
+ * @param conflictingTypeDef - description of the TypeDef in the other metadata collection.
+ * @param errorMessage - details of the error that occurs when the connection is used.
+ */
+ void processTypeDefConflictEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ TypeDefSummary originatorTypeDef,
+ String otherMetadataCollectionId,
+ TypeDefSummary conflictingTypeDef,
+ String errorMessage);
+
+
+ /**
+ * Process a detected conflict in the attribute type definitions (AttributeTypeDefs) used in the cohort.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param originatorAttributeTypeDef- description of the AttributeTypeDef in the event originator.
+ * @param otherMetadataCollectionId - the metadataCollection using the conflicting AttributeTypeDef.
+ * @param conflictingAttributeTypeDef - description of the AttributeTypeDef in the other metadata collection.
+ * @param errorMessage - details of the error that occurs when the connection is used.
+ */
+ void processAttributeTypeDefConflictEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ AttributeTypeDef originatorAttributeTypeDef,
+ String otherMetadataCollectionId,
+ AttributeTypeDef conflictingAttributeTypeDef,
+ String errorMessage);
+
+
+ /**
+ * A TypeDef from another member in the cohort is at a different version than the local repository. This may
+ * create some inconsistencies in the different copies of instances of this type in different members of the
+ * cohort. The recommended action is to update all TypeDefs to the latest version.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param targetMetadataCollectionId - identifier of the metadata collection that is reporting a TypeDef at a
+ * different level to the reporting repository.
+ * @param targetTypeDef - details of the TypeDef in the target repository.
+ * @param otherTypeDef - details of the TypeDef in the other repository.
+ * @param errorMessage - details of the error that occurs when the connection is used.
+ */
+ void processTypeDefPatchMismatchEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ String targetMetadataCollectionId,
+ TypeDefSummary targetTypeDef,
+ TypeDef otherTypeDef,
+ String errorMessage);
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSTypeDefEventType.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSTypeDefEventType.java b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSTypeDefEventType.java
new file mode 100644
index 0000000..e1db23d
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/OMRSTypeDefEventType.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.eventmanagement.events;
+
+/**
+ * OMRSTypeDefEventType defines the different types of TypeDef events in the open metadata repository services
+ * protocol:
+ * <ul>
+ * <li>
+ * UNKNOWN_TYPEDEF_EVENT - the event is not recognized by this local server, probably because it is back-level
+ * from other servers in the cluster. It is logged in the audit log and then ignored. The metadata exchange
+ * protocol should evolve so that new message types can be ignored by back-level servers without damage
+ * to the cluster's integrity.
+ * </li>
+ * <li>
+ * NEW_TYPEDEF - A new TypeDef has been defined.
+ * </li>
+ * <li>
+ * UPDATED_TYPEDEF - An existing TypeDef has been updated.
+ * </li>
+ * <li>
+ * DELETED_TYPEDEF_EVENT - An existing TypeDef has been deleted.
+ * </li>
+ * <li>
+ * RE_IDENTIFIED_TYPEDEF_EVENT - the guid has been changed for a TypeDef.
+ * </li>
+ * </ul>
+ */
+public enum OMRSTypeDefEventType
+{
+ UNKNOWN_TYPEDEF_EVENT (0, "UnknownTypeDefEvent", "An TypeDef event that is not recognized by the local server."),
+ NEW_TYPEDEF_EVENT (1, "NewTypeDef", "A new TypeDef has been defined."),
+ NEW_ATTRIBUTE_TYPEDEF_EVENT (2, "NewAttributeTypeDef", "A new AttributeTypeDef has been defined."),
+ UPDATED_TYPEDEF_EVENT (3, "UpdatedTypeDef", "An existing TypeDef has been updated."),
+ DELETED_TYPEDEF_EVENT (4, "DeletedTypeDef", "An existing TypeDef has been deleted."),
+ DELETED_ATTRIBUTE_TYPEDEF_EVENT (5, "DeletedAttributeTypeDef", "An existing AttributeTypeDef has been deleted."),
+ RE_IDENTIFIED_TYPEDEF_EVENT (6, "ReIdentifiedTypeDef", "An existing TypeDef has changed either it guid or its name."),
+ RE_IDENTIFIED_ATTRIBUTE_TYPEDEF_EVENT (7, "ReIdentifiedAttributeTypeDef", "An existing AttributeTypeDef has changed either it guid or its name."),
+ TYPEDEF_ERROR_EVENT (99, "InstanceErrorEvent",
+ "An error has been detected in the exchange of TypeDefs between members of the cohort.");
+
+
+ private int eventTypeCode;
+ private String eventTypeName;
+ private String eventTypeDescription;
+
+
+ /**
+ * Default Constructor - sets up the specific values for this instance of the enum.
+ *
+ * @param eventTypeCode - int identifier used for indexing based on the enum.
+ * @param eventTypeName - string name used for messages that include the enum.
+ * @param eventTypeDescription - default description for the enum value - used when natural resource
+ * bundle is not available.
+ */
+ OMRSTypeDefEventType(int eventTypeCode, String eventTypeName, String eventTypeDescription)
+ {
+ this.eventTypeCode = eventTypeCode;
+ this.eventTypeName = eventTypeName;
+ this.eventTypeDescription = eventTypeDescription;
+ }
+
+
+ /**
+ * Return the int identifier used for indexing based on the enum.
+ *
+ * @return int identifier code
+ */
+ public int getTypeDefEventTypeCode()
+ {
+ return eventTypeCode;
+ }
+
+
+ /**
+ * Return the string name used for messages that include the enum.
+ *
+ * @return String name
+ */
+ public String getTypeDefEventTypeName()
+ {
+ return eventTypeName;
+ }
+
+
+ /**
+ * Return the default description for the enum value - used when natural resource
+ * bundle is not available.
+ *
+ * @return String default description
+ */
+ public String getTypeDefEventTypeDescription()
+ {
+ return eventTypeDescription;
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/v1/OMRSEventV1.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/v1/OMRSEventV1.java b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/v1/OMRSEventV1.java
new file mode 100644
index 0000000..8d20042
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/v1/OMRSEventV1.java
@@ -0,0 +1,132 @@
+/*
+ * 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.v1;
+
+import com.fasterxml.jackson.annotation.JsonAutoDetect;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+
+import org.apache.atlas.omrs.eventmanagement.events.OMRSEventCategory;
+import org.apache.atlas.omrs.eventmanagement.events.OMRSEventOriginator;
+
+
+import java.io.Serializable;
+import java.util.Date;
+
+import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY;
+import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE;
+
+
+/**
+ * OMRSEventV1 is the OMRSEvent payload for versionName 1 of the open metadata and governance message exchange.
+ */
+@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown=true)
+public class OMRSEventV1 implements Serializable
+{
+ private static final long serialVersionUID = 1L;
+
+ private final String protocolVersionId = "OMRS V1.0";
+ private Date timestamp = null;
+ private OMRSEventOriginator originator = null;
+ private OMRSEventCategory eventCategory = null;
+ private OMRSEventV1RegistrySection registryEventSection = null;
+ private OMRSEventV1TypeDefSection typeDefEventSection = null;
+ private OMRSEventV1InstanceSection instanceEventSection = null;
+ private OMRSEventV1ErrorSection errorSection = null;
+
+ public OMRSEventV1()
+ {
+ }
+
+ public String getProtocolVersionId()
+ {
+ return protocolVersionId;
+ }
+
+ public Date getTimestamp()
+ {
+ return timestamp;
+ }
+
+ public void setTimestamp(Date timestamp)
+ {
+ this.timestamp = timestamp;
+ }
+
+ public OMRSEventOriginator getOriginator()
+ {
+ return originator;
+ }
+
+ public void setOriginator(OMRSEventOriginator originator)
+ {
+ this.originator = originator;
+ }
+
+ public OMRSEventCategory getEventCategory()
+ {
+ return eventCategory;
+ }
+
+ public void setEventCategory(OMRSEventCategory eventCategory)
+ {
+ this.eventCategory = eventCategory;
+ }
+
+ public OMRSEventV1RegistrySection getRegistryEventSection()
+ {
+ return registryEventSection;
+ }
+
+ public void setRegistryEventSection(OMRSEventV1RegistrySection registryEventSection)
+ {
+ this.registryEventSection = registryEventSection;
+ }
+
+ public OMRSEventV1TypeDefSection getTypeDefEventSection()
+ {
+ return typeDefEventSection;
+ }
+
+ public void setTypeDefEventSection(OMRSEventV1TypeDefSection typeDefEventSection)
+ {
+ this.typeDefEventSection = typeDefEventSection;
+ }
+
+ public OMRSEventV1InstanceSection getInstanceEventSection()
+ {
+ return instanceEventSection;
+ }
+
+ public void setInstanceEventSection(OMRSEventV1InstanceSection instanceEventSection)
+ {
+ this.instanceEventSection = instanceEventSection;
+ }
+
+ public OMRSEventV1ErrorSection getErrorSection()
+ {
+ return errorSection;
+ }
+
+ public void setErrorSection(OMRSEventV1ErrorSection errorSection)
+ {
+ this.errorSection = errorSection;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/v1/OMRSEventV1ErrorSection.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/v1/OMRSEventV1ErrorSection.java b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/v1/OMRSEventV1ErrorSection.java
new file mode 100644
index 0000000..8926491
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/v1/OMRSEventV1ErrorSection.java
@@ -0,0 +1,182 @@
+/*
+ * 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.v1;
+
+import org.apache.atlas.ocf.properties.Connection;
+import org.apache.atlas.omrs.eventmanagement.events.OMRSEventErrorCode;
+import org.apache.atlas.omrs.metadatacollection.properties.instances.InstanceProvenanceType;
+import org.apache.atlas.omrs.metadatacollection.properties.typedefs.AttributeTypeDef;
+import org.apache.atlas.omrs.metadatacollection.properties.typedefs.TypeDef;
+import org.apache.atlas.omrs.metadatacollection.properties.typedefs.TypeDefCategory;
+import org.apache.atlas.omrs.metadatacollection.properties.typedefs.TypeDefSummary;
+
+import java.io.Serializable;
+
+/**
+ * OMRSEventV1ErrorSection describes the properties used to record errors detected by one of the members of the
+ * open metadata repository cohort.
+ */
+public class OMRSEventV1ErrorSection implements Serializable
+{
+ private static final long serialVersionUID = 1L;
+
+ private OMRSEventErrorCode errorCode = null;
+ private String errorMessage = null;
+ private String targetMetadataCollectionId = null;
+ private Connection targetRemoteConnection = null;
+ private TypeDefSummary targetTypeDefSummary = null;
+ private AttributeTypeDef targetAttributeTypeDef = null;
+ private String targetInstanceGUID = null;
+ private InstanceProvenanceType otherOrigin = null;
+ private String otherMetadataCollectionId = null;
+ private TypeDefSummary otherTypeDefSummary = null;
+ private TypeDef otherTypeDef = null;
+ private AttributeTypeDef otherAttributeTypeDef = null;
+ private String otherInstanceGUID = null;
+
+ public OMRSEventV1ErrorSection()
+ {
+ }
+
+ public OMRSEventErrorCode getErrorCode()
+ {
+ return errorCode;
+ }
+
+ public void setErrorCode(OMRSEventErrorCode errorCode)
+ {
+ this.errorCode = errorCode;
+ }
+
+ public String getErrorMessage()
+ {
+ return errorMessage;
+ }
+
+ public void setErrorMessage(String errorMessage)
+ {
+ this.errorMessage = errorMessage;
+ }
+
+ public String getTargetMetadataCollectionId()
+ {
+ return targetMetadataCollectionId;
+ }
+
+ public void setTargetMetadataCollectionId(String targetMetadataCollectionId)
+ {
+ this.targetMetadataCollectionId = targetMetadataCollectionId;
+ }
+
+ public Connection getTargetRemoteConnection()
+ {
+ return targetRemoteConnection;
+ }
+
+ public void setTargetRemoteConnection(Connection targetRemoteConnection)
+ {
+ this.targetRemoteConnection = targetRemoteConnection;
+ }
+
+ public TypeDefSummary getTargetTypeDefSummary()
+ {
+ return targetTypeDefSummary;
+ }
+
+ public void setTargetTypeDefSummary(TypeDefSummary targetTypeDefSummary)
+ {
+ this.targetTypeDefSummary = targetTypeDefSummary;
+ }
+
+ public AttributeTypeDef getTargetAttributeTypeDef()
+ {
+ return targetAttributeTypeDef;
+ }
+
+ public void setTargetAttributeTypeDef(AttributeTypeDef targetAttributeTypeDef)
+ {
+ this.targetAttributeTypeDef = targetAttributeTypeDef;
+ }
+
+ public String getTargetInstanceGUID()
+ {
+ return targetInstanceGUID;
+ }
+
+ public void setTargetInstanceGUID(String targetInstanceGUID)
+ {
+ this.targetInstanceGUID = targetInstanceGUID;
+ }
+
+ public InstanceProvenanceType getOtherOrigin()
+ {
+ return otherOrigin;
+ }
+
+ public void setOtherOrigin(InstanceProvenanceType otherOrigin)
+ {
+ this.otherOrigin = otherOrigin;
+ }
+
+ public String getOtherMetadataCollectionId()
+ {
+ return otherMetadataCollectionId;
+ }
+
+ public void setOtherMetadataCollectionId(String otherMetadataCollectionId)
+ {
+ this.otherMetadataCollectionId = otherMetadataCollectionId;
+ }
+
+ public TypeDefSummary getOtherTypeDefSummary() { return otherTypeDefSummary; }
+
+ public void setOtherTypeDefSummary(TypeDefSummary otherTypeDefSummary)
+ {
+ this.otherTypeDefSummary = otherTypeDefSummary;
+ }
+
+ public TypeDef getOtherTypeDef()
+ {
+ return otherTypeDef;
+ }
+
+ public void setOtherTypeDef(TypeDef otherTypeDef)
+ {
+ this.otherTypeDef = otherTypeDef;
+ }
+
+ public AttributeTypeDef getOtherAttributeTypeDef()
+ {
+ return otherAttributeTypeDef;
+ }
+
+ public void setOtherAttributeTypeDef(AttributeTypeDef otherAttributeTypeDef)
+ {
+ this.otherAttributeTypeDef = otherAttributeTypeDef;
+ }
+
+ public String getOtherInstanceGUID()
+ {
+ return otherInstanceGUID;
+ }
+
+ public void setOtherInstanceGUID(String otherInstanceGUID)
+ {
+ this.otherInstanceGUID = otherInstanceGUID;
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/v1/OMRSEventV1InstanceSection.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/v1/OMRSEventV1InstanceSection.java b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/v1/OMRSEventV1InstanceSection.java
new file mode 100644
index 0000000..f5d55fa
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/v1/OMRSEventV1InstanceSection.java
@@ -0,0 +1,149 @@
+/*
+ * 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.v1;
+
+import org.apache.atlas.omrs.eventmanagement.events.OMRSInstanceEventType;
+import org.apache.atlas.omrs.metadatacollection.properties.instances.EntityDetail;
+import org.apache.atlas.omrs.metadatacollection.properties.instances.Relationship;
+import org.apache.atlas.omrs.metadatacollection.properties.typedefs.TypeDefSummary;
+
+import java.io.Serializable;
+
+/**
+ * OMRSEventV1InstanceSection describes the properties specific to instance events
+ */
+public class OMRSEventV1InstanceSection implements Serializable
+{
+ private static final long serialVersionUID = 1L;
+
+ private OMRSInstanceEventType eventType = null;
+
+ private String typeDefGUID = null;
+ private String typeDefName = null;
+ private String instanceGUID = null;
+ private EntityDetail entity = null;
+ private Relationship relationship = null;
+ private String homeMetadataCollectionId = null;
+ private String originalHomeMetadataCollectionId = null;
+ private TypeDefSummary originalTypeDefSummary = null;
+ private String originalInstanceGUID = null;
+
+ public OMRSEventV1InstanceSection()
+ {
+ }
+
+ public OMRSInstanceEventType getEventType()
+ {
+ return eventType;
+ }
+
+ public void setEventType(OMRSInstanceEventType eventType)
+ {
+ this.eventType = eventType;
+ }
+
+ public String getTypeDefGUID()
+ {
+ return typeDefGUID;
+ }
+
+ public void setTypeDefGUID(String typeDefGUID)
+ {
+ this.typeDefGUID = typeDefGUID;
+ }
+
+ public String getTypeDefName()
+ {
+ return typeDefName;
+ }
+
+ public void setTypeDefName(String typeDefName)
+ {
+ this.typeDefName = typeDefName;
+ }
+
+ public String getInstanceGUID()
+ {
+ return instanceGUID;
+ }
+
+ public void setInstanceGUID(String instanceGUID)
+ {
+ this.instanceGUID = instanceGUID;
+ }
+
+ public EntityDetail getEntity()
+ {
+ return entity;
+ }
+
+ public void setEntity(EntityDetail entity)
+ {
+ this.entity = entity;
+ }
+
+ public Relationship getRelationship()
+ {
+ return relationship;
+ }
+
+ public void setRelationship(Relationship relationship)
+ {
+ this.relationship = relationship;
+ }
+
+ public String getHomeMetadataCollectionId()
+ {
+ return homeMetadataCollectionId;
+ }
+
+ public void setHomeMetadataCollectionId(String homeMetadataCollectionId)
+ {
+ this.homeMetadataCollectionId = homeMetadataCollectionId;
+ }
+
+ public String getOriginalHomeMetadataCollectionId()
+ {
+ return originalHomeMetadataCollectionId;
+ }
+
+ public void setOriginalHomeMetadataCollectionId(String originalHomeMetadataCollectionId)
+ {
+ this.originalHomeMetadataCollectionId = originalHomeMetadataCollectionId;
+ }
+
+ public TypeDefSummary getOriginalTypeDefSummary()
+ {
+ return originalTypeDefSummary;
+ }
+
+ public void setOriginalTypeDefSummary(TypeDefSummary originalTypeDefSummary)
+ {
+ this.originalTypeDefSummary = originalTypeDefSummary;
+ }
+
+ public String getOriginalInstanceGUID()
+ {
+ return originalInstanceGUID;
+ }
+
+ public void setOriginalInstanceGUID(String originalInstanceGUID)
+ {
+ this.originalInstanceGUID = originalInstanceGUID;
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/v1/OMRSEventV1RegistrySection.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/v1/OMRSEventV1RegistrySection.java b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/v1/OMRSEventV1RegistrySection.java
new file mode 100644
index 0000000..0fb5f6c
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/v1/OMRSEventV1RegistrySection.java
@@ -0,0 +1,83 @@
+/*
+ * 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.v1;
+
+import org.apache.atlas.ocf.properties.Connection;
+import org.apache.atlas.omrs.eventmanagement.events.OMRSRegistryEventType;
+import org.apache.atlas.omrs.metadatacollection.properties.typedefs.TypeDefSummary;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Date;
+
+/**
+ * OMRSEventV1RegistrySection describes properties that are used exclusively for registry events.
+ */
+public class OMRSEventV1RegistrySection implements Serializable
+{
+ private static final long serialVersionUID = 1L;
+
+ private OMRSRegistryEventType registryEventType = null;
+ private Date registrationTimestamp = null;
+ private Connection remoteConnection = null;
+ private ArrayList<TypeDefSummary> TypeDefList = null;
+
+ public OMRSEventV1RegistrySection()
+ {
+ }
+
+ public OMRSRegistryEventType getRegistryEventType()
+ {
+ return registryEventType;
+ }
+
+ public void setRegistryEventType(OMRSRegistryEventType registryEventType)
+ {
+ this.registryEventType = registryEventType;
+ }
+
+ public Date getRegistrationTimestamp()
+ {
+ return registrationTimestamp;
+ }
+
+ public void setRegistrationTimestamp(Date registrationTimestamp)
+ {
+ this.registrationTimestamp = registrationTimestamp;
+ }
+
+ public Connection getRemoteConnection()
+ {
+ return remoteConnection;
+ }
+
+ public void setRemoteConnection(Connection remoteConnection)
+ {
+ this.remoteConnection = remoteConnection;
+ }
+
+ public ArrayList<TypeDefSummary> getTypeDefList()
+ {
+ return TypeDefList;
+ }
+
+ public void setTypeDefList(ArrayList<TypeDefSummary> typeDefList)
+ {
+ TypeDefList = typeDefList;
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/v1/OMRSEventV1TypeDefSection.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/v1/OMRSEventV1TypeDefSection.java b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/v1/OMRSEventV1TypeDefSection.java
new file mode 100644
index 0000000..fc75df5
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/events/v1/OMRSEventV1TypeDefSection.java
@@ -0,0 +1,127 @@
+/*
+ * 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.v1;
+
+import org.apache.atlas.omrs.eventmanagement.events.OMRSTypeDefEventType;
+import org.apache.atlas.omrs.metadatacollection.properties.typedefs.AttributeTypeDef;
+import org.apache.atlas.omrs.metadatacollection.properties.typedefs.TypeDef;
+import org.apache.atlas.omrs.metadatacollection.properties.typedefs.TypeDefPatch;
+import org.apache.atlas.omrs.metadatacollection.properties.typedefs.TypeDefSummary;
+
+import java.io.Serializable;
+
+/**
+ * OMRSEventV1TypeDefSection describes the properties specific to TypeDef related events
+ */
+public class OMRSEventV1TypeDefSection implements Serializable
+{
+ private static final long serialVersionUID = 1L;
+
+ private OMRSTypeDefEventType typeDefEventType = null;
+ private String typeDefGUID = null;
+ private String typeDefName = null;
+ private AttributeTypeDef attributeTypeDef = null;
+ private TypeDef typeDef = null;
+ private TypeDefPatch typeDefPatch = null;
+ private TypeDefSummary originalTypeDefSummary = null;
+ private AttributeTypeDef originalAttributeTypeDef = null;
+
+ public OMRSEventV1TypeDefSection()
+ {
+ }
+
+ public OMRSTypeDefEventType getTypeDefEventType()
+ {
+ return typeDefEventType;
+ }
+
+ public void setTypeDefEventType(OMRSTypeDefEventType typeDefEventType)
+ {
+ this.typeDefEventType = typeDefEventType;
+ }
+
+ public String getTypeDefGUID()
+ {
+ return typeDefGUID;
+ }
+
+ public void setTypeDefGUID(String typeDefGUID)
+ {
+ this.typeDefGUID = typeDefGUID;
+ }
+
+ public String getTypeDefName()
+ {
+ return typeDefName;
+ }
+
+ public void setTypeDefName(String typeDefName)
+ {
+ this.typeDefName = typeDefName;
+ }
+
+ public AttributeTypeDef getAttributeTypeDef()
+ {
+ return attributeTypeDef;
+ }
+
+ public void setAttributeTypeDef(AttributeTypeDef attributeTypeDef)
+ {
+ this.attributeTypeDef = attributeTypeDef;
+ }
+
+ public TypeDef getTypeDef()
+ {
+ return typeDef;
+ }
+
+ public void setTypeDef(TypeDef typeDef)
+ {
+ this.typeDef = typeDef;
+ }
+
+ public TypeDefPatch getTypeDefPatch()
+ {
+ return typeDefPatch;
+ }
+
+ public void setTypeDefPatch(TypeDefPatch typeDefPatch)
+ {
+ this.typeDefPatch = typeDefPatch;
+ }
+
+ public TypeDefSummary getOriginalTypeDefSummary()
+ {
+ return originalTypeDefSummary;
+ }
+
+ public void setOriginalTypeDefSummary(TypeDefSummary originalTypeDefSummary)
+ {
+ this.originalTypeDefSummary = originalTypeDefSummary;
+ }
+
+ public AttributeTypeDef getOriginalAttributeTypeDef()
+ {
+ return originalAttributeTypeDef;
+ }
+
+ public void setOriginalAttributeTypeDef(AttributeTypeDef originalAttributeTypeDef)
+ {
+ this.originalAttributeTypeDef = originalAttributeTypeDef;
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/repositoryeventmapper/OMRSRepositoryEventMapper.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/repositoryeventmapper/OMRSRepositoryEventMapper.java b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/repositoryeventmapper/OMRSRepositoryEventMapper.java
new file mode 100644
index 0000000..99a8569
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/repositoryeventmapper/OMRSRepositoryEventMapper.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.atlas.omrs.eventmanagement.repositoryeventmapper;
+
+import org.apache.atlas.omrs.eventmanagement.OMRSRepositoryEventProcessor;
+import org.apache.atlas.omrs.localrepository.repositorycontentmanager.OMRSRepositoryHelper;
+import org.apache.atlas.omrs.metadatacollection.repositoryconnector.OMRSRepositoryConnector;
+
+/**
+ * OMRSRepositoryEventMapper is the interface to a connector that is converting events received from
+ * a non-native local metadata repository into OMRS compliant repository events. It is used when the Open Metadata
+ * and Governance Server is being used as a RepositoryProxy, or if the local metadata repository has
+ * additional APIs that mean metadata can be changed without going through the OMRS Repository Connectors.
+ */
+public interface OMRSRepositoryEventMapper
+{
+ /**
+ * Pass additional information to the connector needed to process events.
+ *
+ * @param repositoryEventMapperName - repository event mapper name used for the source of the OMRS events.
+ * @param repositoryConnector - this is the connector to the local repository that the event mapper is processing
+ * events from. The repository connector is used to retrieve additional information
+ * necessary to fill out the OMRS Events.
+ * @param repositoryHelper - provides helper methods for building TypeDefs and metadata instances such as
+ * entities and relationships.
+ * @param localMetadataCollectionId - unique identifier for the local repository's metadata collection.
+ * @param localServerName - name of the local server.
+ * @param localServerType - type of local repository/server.
+ * @param localOrganizationName - name of the organization that owns the local metadata repository.
+ */
+ void initialize(String repositoryEventMapperName,
+ OMRSRepositoryConnector repositoryConnector,
+ OMRSRepositoryHelper repositoryHelper,
+ String localMetadataCollectionId,
+ String localServerName,
+ String localServerType,
+ String localOrganizationName);
+
+
+ /**
+ * Set up the repository event processor for this connector to use. The connector should pass
+ * each typeDef or instance metadata change reported by its metadata repository's metadata on to the
+ * repository event processor.
+ *
+ * @param repositoryEventProcessor - listener responsible for distributing notifications of local
+ * changes to metadata types and instances to the rest of the
+ * open metadata repository cohort.
+ */
+ void setRepositoryEventProcessor(OMRSRepositoryEventProcessor repositoryEventProcessor);
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/repositoryeventmapper/OMRSRepositoryEventMapperBase.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/repositoryeventmapper/OMRSRepositoryEventMapperBase.java b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/repositoryeventmapper/OMRSRepositoryEventMapperBase.java
new file mode 100644
index 0000000..4d9db96
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/repositoryeventmapper/OMRSRepositoryEventMapperBase.java
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.atlas.omrs.eventmanagement.repositoryeventmapper;
+
+import org.apache.atlas.ocf.ConnectorBase;
+import org.apache.atlas.omrs.eventmanagement.OMRSRepositoryEventProcessor;
+import org.apache.atlas.omrs.localrepository.repositorycontentmanager.OMRSRepositoryHelper;
+import org.apache.atlas.omrs.metadatacollection.repositoryconnector.OMRSRepositoryConnector;
+
+/**
+ * OMRSRepositoryEventMapperBase provides a base class for implementors of OMRSRepositoryEventMapper.
+ */
+public abstract class OMRSRepositoryEventMapperBase extends ConnectorBase implements OMRSRepositoryEventMapper
+{
+ protected OMRSRepositoryEventProcessor repositoryEventProcessor = null;
+ protected String repositoryEventMapperName = null;
+ protected OMRSRepositoryConnector repositoryConnector = null;
+ protected OMRSRepositoryHelper repositoryHelper = null;
+ protected String localMetadataCollectionId = null;
+ protected String localServerName = null;
+ protected String localServerType = null;
+ protected String localOrganizationName = null;
+
+ /**
+ * Default constructor for OCF ConnectorBase.
+ */
+ public OMRSRepositoryEventMapperBase()
+ {
+ super();
+ }
+
+
+ /**
+ * Set up the repository event listener for this connector to use. The connector should pass
+ * each type or instance metadata change reported by its metadata repository's metadata on to the
+ * repository event listener.
+ *
+ * @param repositoryEventProcessor - listener responsible for distributing notifications of local
+ * changes to metadata types and instances to the rest of the
+ * open metadata repository cluster.
+ */
+ public void setRepositoryEventProcessor(OMRSRepositoryEventProcessor repositoryEventProcessor)
+ {
+ this.repositoryEventProcessor = repositoryEventProcessor;
+ }
+
+
+ /**
+ * Pass additional information to the connector needed to process events.
+ *
+ * @param repositoryEventMapperName - repository event mapper name used for the source of the OMRS events.
+ * @param repositoryConnector - ths is the connector to the local repository that the event mapper is processing
+ * events from. The repository connector is used to retrieve additional information
+ * necessary to fill out the OMRS Events.
+ * @param repositoryHelper - the TypeDef helper is used to create metadata instances that are
+ * @param localMetadataCollectionId - unique identifier for the local repository's metadata collection.
+ * @param localServerName - name of the local server.
+ * @param localServerType - type of local repository/server.
+ * @param localOrganizationName - name of the organization that owns the local metadata repository.
+ */
+ public void initialize(String repositoryEventMapperName,
+ OMRSRepositoryConnector repositoryConnector,
+ OMRSRepositoryHelper repositoryHelper,
+ String localMetadataCollectionId,
+ String localServerName,
+ String localServerType,
+ String localOrganizationName)
+ {
+ this.repositoryEventMapperName = repositoryEventMapperName;
+ this.repositoryConnector = repositoryConnector;
+ this.repositoryHelper = repositoryHelper;
+ this.localMetadataCollectionId = localMetadataCollectionId;
+ this.localServerName = localServerName;
+ this.localServerType = localServerType;
+ this.localOrganizationName = localOrganizationName;
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/repositoryeventmapper/OMRSRepositoryEventMapperProviderBase.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/repositoryeventmapper/OMRSRepositoryEventMapperProviderBase.java b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/repositoryeventmapper/OMRSRepositoryEventMapperProviderBase.java
new file mode 100644
index 0000000..b4895b1
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/repositoryeventmapper/OMRSRepositoryEventMapperProviderBase.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.eventmanagement.repositoryeventmapper;
+
+import org.apache.atlas.ocf.ConnectorProviderBase;
+
+/**
+ * OMRSRepositoryEventMapperProviderBase provides a base class for the connector provider supporting
+ * OMRSRepositoryEventMapper connectors. It extends ConnectorProviderBase which does the creation of connector instances.
+ *
+ * The subclasses of OMRSRepositoryEventMapperProviderBase must initialize ConnectorProviderBase with the Java class
+ * name of the OMRS Connector implementation (by calling super.setConnectorClassName(className)).
+ * Then the connector provider will work.
+ */
+public abstract class OMRSRepositoryEventMapperProviderBase extends ConnectorProviderBase
+{
+ /**
+ * Default Constructor
+ */
+ public OMRSRepositoryEventMapperProviderBase()
+ {
+ /*
+ * Nothing to do
+ */
+ }
+}
[27/30] atlas git commit: ATLAS-2246: OMRS Connector API plus REST
and IGC Connector skeleton - 15th February 2018
Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/opentypes/OpenMetadataTypesArchive.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/opentypes/OpenMetadataTypesArchive.java b/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/opentypes/OpenMetadataTypesArchive.java
new file mode 100644
index 0000000..b8aa172
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/opentypes/OpenMetadataTypesArchive.java
@@ -0,0 +1,5657 @@
+/*
+ * 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.opentypes;
+
+
+import org.apache.atlas.omrs.archivemanager.OMRSArchiveBuilder;
+import org.apache.atlas.omrs.archivemanager.properties.OpenMetadataArchive;
+import org.apache.atlas.omrs.archivemanager.properties.OpenMetadataArchiveType;
+import org.apache.atlas.omrs.ffdc.OMRSErrorCode;
+import org.apache.atlas.omrs.ffdc.exception.OMRSLogicErrorException;
+import org.apache.atlas.omrs.metadatacollection.properties.instances.InstanceStatus;
+import org.apache.atlas.omrs.metadatacollection.properties.typedefs.*;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.Map;
+
+/**
+ * OpenMetadataTypesArchive builds an open metadata archive containing all of the standard open metadata types.
+ * These types have hardcoded dates and guids so that however many times this archive is rebuilt, it will
+ * produce the same content.
+ * <p>
+ * Details of the open metadata types are documented on the wiki:
+ * <a href="https://cwiki.apache.org/confluence/display/ATLAS/Building+out+the+Open+Metadata+Typesystem">Building out the Open Metadata Typesystem</a>
+ * </p>
+ * <p>
+ * There are 8 areas, each covering a different topic area of metadata. The module breaks down the process of creating
+ * the models into the areas and then the individual models to simplify the maintenance of this class
+ * </p>
+ */
+public class OpenMetadataTypesArchive
+{
+ /*
+ * This is the header information for the archive.
+ */
+ private static final String archiveGUID = "bce3b0a0-662a-4f87-b8dc-844078a11a6e";
+ private static final String archiveName = "Open Metadata Types";
+ private static final String archiveDescription = "Standard types for open metadata repositories.";
+ private static final OpenMetadataArchiveType archiveType = OpenMetadataArchiveType.CONTENT_PACK;
+ private static final String originatorName = "Apache Atlas (OMRS)";
+ private static final Date creationDate = new Date(1516313040008L);
+
+ /*
+ * Specific values for initializing TypeDefs
+ */
+ private static final long versionNumber = 1L;
+ private static final String versionName = "1.0";
+
+
+
+ private OMRSArchiveBuilder archiveBuilder;
+
+
+ /**
+ * Default constructor sets up the archive builder. This in turn sets up the header for the archive.
+ */
+ public OpenMetadataTypesArchive()
+ {
+ OMRSArchiveBuilder newArchiveBuilder = new OMRSArchiveBuilder(archiveGUID,
+ archiveName,
+ archiveDescription,
+ archiveType,
+ originatorName,
+ creationDate,
+ null);
+ this.archiveBuilder = newArchiveBuilder;
+ }
+
+
+ /**
+ * Return the unique identifier for this archive.
+ *
+ * @return String guid
+ */
+ public String getArchiveGUID()
+ {
+ return archiveGUID;
+ }
+
+ /**
+ * Returns the open metadata type archive containing all of the standard open metadata types.
+ *
+ * @return populated open metadata archive object
+ */
+ public OpenMetadataArchive getOpenMetadataArchive()
+ {
+ final String methodName = "getOpenMetadataArchive()";
+
+ if (this.archiveBuilder != null)
+ {
+ /*
+ * Call each of the methods to systematically add the contents of the archive.
+ */
+ this.addStandardPrimitiveDefs();
+ this.addArea0Types();
+ this.addArea1Types();
+ this.addArea2Types();
+ this.addArea3Types();
+ this.addArea4Types();
+ this.addArea5Types();
+ this.addArea6Types();
+ this.addArea7Types();
+
+ /*
+ * The completed archive is ready to be packaged up and returned
+ */
+ return this.archiveBuilder.getOpenMetadataArchive();
+ }
+ else
+ {
+ /*
+ * This is a logic error since it means the creation of the archive builder threw an exception
+ * in the constructor and so this object should not be used.
+ */
+ OMRSErrorCode errorCode = OMRSErrorCode.ARCHIVE_UNAVAILABLE;
+ String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage();
+
+ throw new OMRSLogicErrorException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ methodName,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+ }
+
+
+ /*
+ * ========================================
+ * Attribute types
+ */
+
+
+ /**
+ * Add the standard primitive types to the archive builder.
+ */
+ private void addStandardPrimitiveDefs()
+ {
+ this.archiveBuilder.addPrimitiveDef(getPrimitiveDef(PrimitiveDefCategory.OM_PRIMITIVE_TYPE_BOOLEAN));
+ this.archiveBuilder.addPrimitiveDef(getPrimitiveDef(PrimitiveDefCategory.OM_PRIMITIVE_TYPE_BYTE));
+ this.archiveBuilder.addPrimitiveDef(getPrimitiveDef(PrimitiveDefCategory.OM_PRIMITIVE_TYPE_CHAR));
+ this.archiveBuilder.addPrimitiveDef(getPrimitiveDef(PrimitiveDefCategory.OM_PRIMITIVE_TYPE_SHORT));
+ this.archiveBuilder.addPrimitiveDef(getPrimitiveDef(PrimitiveDefCategory.OM_PRIMITIVE_TYPE_INT));
+ this.archiveBuilder.addPrimitiveDef(getPrimitiveDef(PrimitiveDefCategory.OM_PRIMITIVE_TYPE_LONG));
+ this.archiveBuilder.addPrimitiveDef(getPrimitiveDef(PrimitiveDefCategory.OM_PRIMITIVE_TYPE_FLOAT));
+ this.archiveBuilder.addPrimitiveDef(getPrimitiveDef(PrimitiveDefCategory.OM_PRIMITIVE_TYPE_DOUBLE));
+ this.archiveBuilder.addPrimitiveDef(getPrimitiveDef(PrimitiveDefCategory.OM_PRIMITIVE_TYPE_BIGINTEGER));
+ this.archiveBuilder.addPrimitiveDef(getPrimitiveDef(PrimitiveDefCategory.OM_PRIMITIVE_TYPE_BIGDECIMAL));
+ this.archiveBuilder.addPrimitiveDef(getPrimitiveDef(PrimitiveDefCategory.OM_PRIMITIVE_TYPE_STRING));
+ this.archiveBuilder.addPrimitiveDef(getPrimitiveDef(PrimitiveDefCategory.OM_PRIMITIVE_TYPE_DATE));
+ }
+
+
+ /**
+ * Set up an individual primitive definition
+ *
+ * @param primitiveDefCategory - category of the primitive def defines the unique
+ * information about this primitive type.
+ * @return initialized PrimitiveDef object ready for the archive
+ */
+ private PrimitiveDef getPrimitiveDef(PrimitiveDefCategory primitiveDefCategory)
+ {
+ PrimitiveDef primitiveDef = new PrimitiveDef(primitiveDefCategory);
+
+ primitiveDef.setGUID(primitiveDefCategory.getGUID());
+ primitiveDef.setName(primitiveDefCategory.getName());
+
+ return primitiveDef;
+ }
+
+
+ /**
+ * Create a CollectionDef. A new CollectionDef is required for each combination of primitive types
+ * used to initialize the collection. Each CollectionDef has its own unique identifier (guid) and
+ * its name is a combination of the collection type and the primitives use to initialize it.
+ *
+ * @param guid - unique identifier for the CollectionDef
+ * @param name - unique name for the CollectionDef
+ * @param collectionDefCategory - category of the collection.
+ * @return Filled out CollectionDef
+ */
+ private CollectionDef getCollectionDef(String guid,
+ String name,
+ CollectionDefCategory collectionDefCategory)
+ {
+ CollectionDef collectionDef = new CollectionDef(collectionDefCategory);
+
+ collectionDef.setGUID(guid);
+ collectionDef.setName(name);
+
+ return collectionDef;
+ }
+
+
+ /**
+ * Create an EnumDef that has no valid values defined. These are added by the caller.
+ *
+ * @param guid - unique identifier for the CollectionDef
+ * @param name - unique name for the CollectionDef
+ * @param description - short default description of the enum type
+ * @param descriptionGUID - guid of the glossary term describing this enum type
+ * @return basic EnumDef without valid values
+ */
+ private EnumDef getEmptyEnumDef(String guid,
+ String name,
+ String description,
+ String descriptionGUID)
+ {
+ EnumDef enumDef = new EnumDef();
+
+ enumDef.setGUID(guid);
+ enumDef.setName(name);
+ enumDef.setDescription(description);
+ enumDef.setDescriptionGUID(descriptionGUID);
+ enumDef.setDefaultValue(null);
+
+ return enumDef;
+ }
+
+
+ /**
+ * Create an EnumElementDef that carries one of the valid values for an Enum.
+ *
+ * @param ordinal - code number
+ * @param value - name
+ * @param description - short description
+ * @param descriptionGUID - guid of the glossary term describing this enum element
+ * @return Fully filled out EnumElementDef
+ */
+ private EnumElementDef getEnumElementDef(int ordinal,
+ String value,
+ String description,
+ String descriptionGUID)
+ {
+ EnumElementDef enumElementDef = new EnumElementDef();
+
+ enumElementDef.setOrdinal(ordinal);
+ enumElementDef.setValue(value);
+ enumElementDef.setDescription(description);
+ enumElementDef.setDescriptionGUID(descriptionGUID);
+
+ return enumElementDef;
+ }
+
+
+ /**
+ * Sets up a default EntityDef. Calling methods can override the default values. This EntityDef
+ * has no attribute defined.
+ *
+ * @param guid - unique identifier for the entity
+ * @param name - name of the entity
+ * @param superType - Super type for this entity (null for top-level)
+ * @param description - short description of the entity
+ * @param descriptionGUID - guid of the glossary term describing this entity type
+ * @return Initialized EntityDef
+ */
+ EntityDef getDefaultEntityDef(String guid,
+ String name,
+ TypeDefLink superType,
+ String description,
+ String descriptionGUID)
+ {
+ EntityDef entityDef = new EntityDef();
+
+ /*
+ * Set up the parameters supplied by the caller.
+ */
+ entityDef.setGUID(guid);
+ entityDef.setName(name);
+ entityDef.setSuperType(superType);
+ entityDef.setDescription(description);
+ entityDef.setDescriptionGUID(descriptionGUID);
+
+ /*
+ * Set up the defaults
+ */
+ entityDef.setOrigin(archiveGUID);
+ entityDef.setCreatedBy(originatorName);
+ entityDef.setCreateTime(creationDate);
+ entityDef.setVersion(versionNumber);
+ entityDef.setVersionName(versionName);
+
+ /*
+ * Set default valid instance statuses
+ */
+ ArrayList<InstanceStatus> validInstanceStatusList = new ArrayList<>();
+ validInstanceStatusList.add(InstanceStatus.ACTIVE);
+ validInstanceStatusList.add(InstanceStatus.DELETED);
+ entityDef.setValidInstanceStatusList(validInstanceStatusList);
+
+ return entityDef;
+ }
+
+
+ /**
+ * Return an attribute with the supplied name and description that is of type String. It is set up to be optional,
+ * indexable (useful for searches) but the value does not need to be unique.
+ * These are the typical values used for most open metadata attribute.
+ * They can be changed by the caller once the TypeDefAttribute is returned.
+ *
+ * @param attributeName - name of the attribute
+ * @param attributeDescription - short description for the attribute
+ * @param attributeDescriptionGUID - guid of the glossary term that describes this attribute.
+ * @return Optional TypeDefAttribute of type string
+ */
+ TypeDefAttribute getStringTypeDefAttribute(String attributeName,
+ String attributeDescription,
+ String attributeDescriptionGUID)
+ {
+ TypeDefAttribute attribute = new TypeDefAttribute();
+
+ attribute.setAttributeName(attributeName);
+ attribute.setAttributeDescription(attributeDescription);
+ attribute.setAttributeDescriptionGUID(attributeDescriptionGUID);
+ attribute.setAttributeType(getPrimitiveDef(PrimitiveDefCategory.OM_PRIMITIVE_TYPE_STRING));
+ attribute.setAttributeCardinality(AttributeCardinality.AT_MOST_ONE);
+ attribute.setValuesMinCount(0);
+ attribute.setValuesMaxCount(1);
+ attribute.setIndexable(true);
+ attribute.setUnique(false);
+ attribute.setDefaultValue(null);
+ attribute.setExternalStandardMappings(null);
+
+ return attribute;
+ }
+
+
+ /**
+ * Returns a basic RelationshipDef without any attributes or ends set up.
+ * The caller is responsible for adding the attributes and ends definition.
+ *
+ * @param guid - unique identifier for the relationship
+ * @param name - name of the relationship
+ * @param superType - Super type for this relationship (null for top-level)
+ * @param description - short default description of the relationship
+ * @param descriptionGUID - guid of the glossary term that describes this relationship
+ * @param relationshipCategory - is this an association, aggregation or composition?
+ * @param propagationRule - should classifications propagate over this relationship?
+ * @return RelationshipDef with no ends defined.
+ */
+ private RelationshipDef getBasicRelationshipDef(String guid,
+ String name,
+ TypeDefLink superType,
+ String description,
+ String descriptionGUID,
+ RelationshipCategory relationshipCategory,
+ ClassificationPropagationRule propagationRule)
+ {
+ RelationshipDef relationshipDef = new RelationshipDef();
+
+ /*
+ * Set up the parameters supplied by the caller.
+ */
+ relationshipDef.setGUID(guid);
+ relationshipDef.setName(name);
+ relationshipDef.setSuperType(superType);
+ relationshipDef.setDescription(description);
+ relationshipDef.setDescriptionGUID(descriptionGUID);
+
+ /*
+ * Set up the defaults
+ */
+ relationshipDef.setOrigin(archiveGUID);
+ relationshipDef.setCreatedBy(originatorName);
+ relationshipDef.setCreateTime(creationDate);
+ relationshipDef.setVersion(versionNumber);
+ relationshipDef.setVersionName(versionName);
+
+ /*
+ * Set default valid instance statuses
+ */
+ ArrayList<InstanceStatus> validInstanceStatusList = new ArrayList<>();
+ validInstanceStatusList.add(InstanceStatus.ACTIVE);
+ validInstanceStatusList.add(InstanceStatus.DELETED);
+ relationshipDef.setValidInstanceStatusList(validInstanceStatusList);
+
+ /*
+ * Set up the category of relationship
+ */
+ relationshipDef.setRelationshipCategory(relationshipCategory);
+
+ if ((relationshipCategory == RelationshipCategory.AGGREGATION) ||
+ (relationshipCategory == RelationshipCategory.COMPOSITION))
+ {
+ /*
+ * By convention, end 1 is the container end in the open metadata model.
+ */
+ relationshipDef.setRelationshipContainerEnd(RelationshipContainerEnd.END1);
+ }
+ else
+ {
+ relationshipDef.setRelationshipContainerEnd(RelationshipContainerEnd.NOT_APPLICABLE);
+ }
+
+ /*
+ * Use the supplied propagation rule.
+ */
+ relationshipDef.setPropagationRule(propagationRule);
+
+ return relationshipDef;
+ }
+
+
+ /**
+ * Returns a RelationshipEndDef object that sets up details of an entity at one end of a relationship.
+ *
+ * @param entityType - details of the type of entity connected to this end.
+ * @param attributeName - name of the attribute that the entity at the other end uses to refer to this entity.
+ * @param attributeDescription - description of this attribute
+ * @param attributeDescriptionGUID - unique identifier of the glossary term describing this attribute.
+ * @param attributeCardinality - cardinality of this end of the relationship.
+ * @return the definition of one end of a Relationship.
+ */
+ private RelationshipEndDef getRelationshipEndDef(TypeDefLink entityType,
+ String attributeName,
+ String attributeDescription,
+ String attributeDescriptionGUID,
+ AttributeCardinality attributeCardinality)
+ {
+ RelationshipEndDef relationshipEndDef = new RelationshipEndDef();
+
+ relationshipEndDef.setEntityType(entityType);
+ relationshipEndDef.setAttributeName(attributeName);
+ relationshipEndDef.setAttributeDescription(attributeDescription);
+ relationshipEndDef.setAttributeDescriptionGUID(attributeDescriptionGUID);
+ relationshipEndDef.setAttributeCardinality(attributeCardinality);
+
+ return relationshipEndDef;
+ }
+
+
+ /**
+ * Returns a basic ClassificationDef without any attributes. The caller is responsible for adding the
+ * attribute definitions.
+ *
+ * @param guid - unique identifier for the classification
+ * @param name - name of the classification
+ * @param superType - Super type for this classification (null for top-level)
+ * @param description - short description of the classification
+ * @param descriptionGUID - unique identifier of the glossary term that describes this classification.
+ * @param validEntityDefs - which entities can this classification be linked to.
+ * @param propagatable - can the classification propagate over relationships?
+ * @return ClassificationDef with no attributes defined.
+ */
+ private ClassificationDef getClassificationDef(String guid,
+ String name,
+ TypeDefLink superType,
+ String description,
+ String descriptionGUID,
+ ArrayList<TypeDefLink> validEntityDefs,
+ boolean propagatable)
+ {
+ ClassificationDef classificationDef = new ClassificationDef();
+
+ /*
+ * Set up the parameters supplied by the caller.
+ */
+ classificationDef.setGUID(guid);
+ classificationDef.setName(name);
+ classificationDef.setSuperType(superType);
+ classificationDef.setDescription(description);
+ classificationDef.setDescriptionGUID(descriptionGUID);
+
+ /*
+ * Set up the defaults
+ */
+ classificationDef.setOrigin(archiveGUID);
+ classificationDef.setCreatedBy(originatorName);
+ classificationDef.setCreateTime(creationDate);
+ classificationDef.setVersion(versionNumber);
+ classificationDef.setVersionName(versionName);
+
+ /*
+ * Set default valid instance statuses
+ */
+ ArrayList<InstanceStatus> validInstanceStatusList = new ArrayList<>();
+ validInstanceStatusList.add(InstanceStatus.ACTIVE);
+ validInstanceStatusList.add(InstanceStatus.DELETED);
+ classificationDef.setValidInstanceStatusList(validInstanceStatusList);
+
+ /*
+ * Set up the supplied validEntityTypes and propagatable flag.
+ */
+ classificationDef.setValidEntityDefs(validEntityDefs);
+ classificationDef.setPropagatable(propagatable);
+
+ return classificationDef;
+ }
+
+
+ /*
+ * ========================================
+ * AREA 0 - common types and infrastructure
+ */
+
+ /**
+ * Add the list of area 0 types
+ */
+ private void addArea0Types()
+ {
+ this.add0010BaseModel();
+ this.add0015LinkedMediaTypes();
+ this.add0017ExternalIdentifiers();
+ this.add0020PropertyFacets();
+ this.add0025Locations();
+ this.add0030HostsAndPlatforms();
+ this.add0035ComplexHosts();
+ this.add0040SoftwareServers();
+ this.add0045ServersAndAssets();
+ this.add0070NetworksAndGateways();
+ this.add0090CloudPlatformsAndServices();
+ }
+
+ /*
+ * -------------------------------------------------------------------------------------------------------
+ */
+
+ /**
+ * 0010 Base Model defines the core entities that have been inherited from the original Apache Atlas model.
+ * It defines an initial set of asset types that need to be governed (more assets are defined in Area 2).
+ */
+ private void add0010BaseModel()
+ {
+ this.archiveBuilder.addEntityDef(getReferenceableEntity());
+ this.archiveBuilder.addEntityDef(getAssetEntity());
+ this.archiveBuilder.addEntityDef(getInfrastructureEntity());
+ this.archiveBuilder.addEntityDef(getProcessEntity());
+ this.archiveBuilder.addEntityDef(getDataSetEntity());
+
+ this.archiveBuilder.addRelationshipDef(getProcessInputRelationship());
+ this.archiveBuilder.addRelationshipDef(getProcessOutputRelationship());
+ }
+
+
+ /**
+ * The Referenceable entity is the superclass of all of the governed open metadata entities. It specifies that
+ * these entities have a unique identifier called "qualifiedName".
+ *
+ * @return Referenceable EntityDef
+ */
+ private EntityDef getReferenceableEntity()
+ {
+ /*
+ * Build the Entity
+ */
+ final String guid = "005c7c14-ac84-4136-beed-959401b041f8";
+ final String name = "Referenceable";
+ final String description = "An open metadata entity that has a unique identifier.";
+ final String descriptionGUID = null;
+
+ EntityDef entityDef = getDefaultEntityDef(guid,
+ name,
+ null,
+ description,
+ descriptionGUID);
+
+ /*
+ * Build the attributes
+ */
+ ArrayList<TypeDefAttribute> properties = new ArrayList<>();
+ TypeDefAttribute property;
+
+ final String attributeName = "qualifiedName";
+ final String attributeDescription = "Unique identifier for the entity.";
+ final String attributeDescriptionGUID = null;
+
+
+ property = getStringTypeDefAttribute(attributeName, attributeDescription, attributeDescriptionGUID);
+ property.setUnique(true);
+ properties.add(property);
+
+ entityDef.setPropertiesDefinition(properties);
+
+ return entityDef;
+ }
+
+
+ /**
+ * The Asset entity is the root entity for the assets that open metadata and governance is governing.
+ *
+ * @return Asset EntityDef
+ */
+ private EntityDef getAssetEntity()
+ {
+ /*
+ * Build the Entity
+ */
+ final String guid = "896d14c2-7522-4f6c-8519-757711943fe6";
+ final String name = "Asset";
+ final String description = "The description of an asset that needs to be catalogued and governed.";
+ final String descriptionGUID = null;
+ final String superTypeName = "Referenceable";
+
+ EntityDef entityDef = getDefaultEntityDef(guid,
+ name,
+ this.archiveBuilder.getEntityDef(superTypeName),
+ description,
+ descriptionGUID);
+
+ /*
+ * Build the attributes
+ */
+ ArrayList<TypeDefAttribute> properties = new ArrayList<>();
+ TypeDefAttribute property;
+
+ final String attribute1Name = "name";
+ final String attribute1Description = "Display name for the asset.";
+ final String attribute1DescriptionGUID = null;
+ final String attribute2Name = "description";
+ final String attribute2Description = "Description of the asset.";
+ final String attribute2DescriptionGUID = null;
+ final String attribute3Name = "owner";
+ final String attribute3Description = "User name of the person or process that owns the asset.";
+ final String attribute3DescriptionGUID = null;
+
+
+ property = getStringTypeDefAttribute(attribute1Name, attribute1Description, attribute1DescriptionGUID);
+ properties.add(property);
+ property = getStringTypeDefAttribute(attribute2Name, attribute2Description, attribute2DescriptionGUID);
+ properties.add(property);
+ property = getStringTypeDefAttribute(attribute3Name, attribute3Description, attribute3DescriptionGUID);
+ properties.add(property);
+
+ entityDef.setPropertiesDefinition(properties);
+
+ return entityDef;
+ }
+
+
+ /**
+ * The Infrastructure entity describes an asset that is physical infrastructure or part of the software
+ * platform that supports the data and process assets.
+ *
+ * @return Infrastructure EntityDef
+ */
+ private EntityDef getInfrastructureEntity()
+ {
+ /*
+ * Build the Entity
+ */
+ final String guid = "c19746ac-b3ec-49ce-af4b-83348fc55e07";
+ final String name = "Infrastructure";
+ final String description = "Physical infrastructure or software platform.";
+ final String descriptionGUID = null;
+ final String superTypeName = "Asset";
+
+ EntityDef entityDef = getDefaultEntityDef(guid,
+ name,
+ this.archiveBuilder.getEntityDef(superTypeName),
+ description,
+ descriptionGUID);
+
+ return entityDef;
+ }
+
+
+ /**
+ * The Process entity describes a well-defined sequence of activities performed by people or software components.
+ *
+ * @return Process EntityDef
+ */
+ private EntityDef getProcessEntity()
+ {
+ /*
+ * Build the Entity
+ */
+ final String guid = "d8f33bd7-afa9-4a11-a8c7-07dcec83c050";
+ final String name = "Process";
+ final String description = "Well-defined sequence of activities performed by people or software components.";
+ final String descriptionGUID = null;
+ final String superTypeName = "Asset";
+
+ EntityDef entityDef = getDefaultEntityDef(guid,
+ name,
+ this.archiveBuilder.getEntityDef(superTypeName),
+ description,
+ descriptionGUID);
+
+ return entityDef;
+ }
+
+
+ /**
+ * The DataSet entity describes a collection of related data.
+ *
+ * @return DataSet EntityDef
+ */
+ private EntityDef getDataSetEntity()
+ {
+ /*
+ * Build the Entity
+ */
+ final String guid = "1449911c-4f44-4c22-abc0-7540154feefb";
+ final String name = "DataSet";
+ final String description = "Collection of related data.";
+ final String descriptionGUID = null;
+ final String superTypeName = "Asset";
+
+ EntityDef entityDef = getDefaultEntityDef(guid,
+ name,
+ this.archiveBuilder.getEntityDef(superTypeName),
+ description,
+ descriptionGUID);
+
+ return entityDef;
+ }
+
+
+ /**
+ * The ProcessInput relationship describes the data set(s) that are passed into a process.
+ *
+ * @return ProcessInput RelationshipDef
+ */
+ private RelationshipDef getProcessInputRelationship()
+ {
+ /*
+ * Build the relationship
+ */
+ final String guid = "9a6583c4-7419-4d5a-a6e5-26b0033fa349";
+ final String name = "ProcessInput";
+ final String description = "The DataSets passed into a Process.";
+ final String descriptionGUID = null;
+ final RelationshipCategory relationshipCategory = RelationshipCategory.AGGREGATION;
+ final ClassificationPropagationRule classificationPropagationRule = ClassificationPropagationRule.NONE;
+
+ RelationshipDef relationshipDef = getBasicRelationshipDef(guid,
+ name,
+ null,
+ description,
+ descriptionGUID,
+ relationshipCategory,
+ classificationPropagationRule);
+
+ RelationshipEndDef relationshipEndDef;
+
+ /*
+ * Set up end 1.
+ */
+ final String end1EntityType = "Process";
+ final String end1AttributeName = "consumedByProcess";
+ final String end1AttributeDescription = "Processes that consume this DataSet";
+ final String end1AttributeDescriptionGUID = null;
+ final AttributeCardinality end1Cardinality = AttributeCardinality.ANY_NUMBER_UNORDERED;
+
+ relationshipEndDef = getRelationshipEndDef(this.archiveBuilder.getEntityDef(end1EntityType),
+ end1AttributeName,
+ end1AttributeDescription,
+ end1AttributeDescriptionGUID,
+ end1Cardinality);
+ relationshipDef.setEndDef1(relationshipEndDef);
+
+
+ /*
+ * Set up end 2.
+ */
+ final String end2EntityType = "DataSet";
+ final String end2AttributeName = "processInputData";
+ final String end2AttributeDescription = "DataSets consumed by this Process";
+ final String end2AttributeDescriptionGUID = null;
+ final AttributeCardinality end2Cardinality = AttributeCardinality.ANY_NUMBER_UNORDERED;
+
+ relationshipEndDef = getRelationshipEndDef(this.archiveBuilder.getEntityDef(end2EntityType),
+ end2AttributeName,
+ end2AttributeDescription,
+ end2AttributeDescriptionGUID,
+ end2Cardinality);
+ relationshipDef.setEndDef2(relationshipEndDef);
+
+
+ return relationshipDef;
+ }
+
+
+ /**
+ * The ProcessOutput relationship describes the data set(s) that are produced by a process.
+ *
+ * @return ProcessOutput RelationshipDef
+ */
+ private RelationshipDef getProcessOutputRelationship()
+ {
+ /*
+ * Build the relationship
+ */
+ final String guid = "8920eada-9b05-4368-b511-b8506a4bef4b";
+ final String name = "ProcessOutput";
+ final String description = "The DataSets produced by a Process.";
+ final String descriptionGUID = null;
+ final RelationshipCategory relationshipCategory = RelationshipCategory.AGGREGATION;
+ final ClassificationPropagationRule classificationPropagationRule = ClassificationPropagationRule.NONE;
+
+ RelationshipDef relationshipDef = getBasicRelationshipDef(guid,
+ name,
+ null,
+ description,
+ descriptionGUID,
+ relationshipCategory,
+ classificationPropagationRule);
+
+ RelationshipEndDef relationshipEndDef;
+
+ /*
+ * Set up end 1.
+ */
+ final String end1EntityType = "Process";
+ final String end1AttributeName = "producedByProcess";
+ final String end1AttributeDescription = "Processes that produce this DataSet";
+ final String end1AttributeDescriptionGUID = null;
+ final AttributeCardinality end1Cardinality = AttributeCardinality.ANY_NUMBER_UNORDERED;
+
+ relationshipEndDef = getRelationshipEndDef(this.archiveBuilder.getEntityDef(end1EntityType),
+ end1AttributeName,
+ end1AttributeDescription,
+ end1AttributeDescriptionGUID,
+ end1Cardinality);
+ relationshipDef.setEndDef1(relationshipEndDef);
+
+
+ /*
+ * Set up end 2.
+ */
+ final String end2EntityType = "DataSet";
+ final String end2AttributeName = "processOutputData";
+ final String end2AttributeDescription = "DataSets produced by this Process";
+ final String end2AttributeDescriptionGUID = null;
+ final AttributeCardinality end2Cardinality = AttributeCardinality.ANY_NUMBER_UNORDERED;
+
+ relationshipEndDef = getRelationshipEndDef(this.archiveBuilder.getEntityDef(end2EntityType),
+ end2AttributeName,
+ end2AttributeDescription,
+ end2AttributeDescriptionGUID,
+ end2Cardinality);
+ relationshipDef.setEndDef2(relationshipEndDef);
+
+
+ return relationshipDef;
+ }
+
+
+ /*
+ * -------------------------------------------------------------------------------------------------------
+ */
+
+
+ /**
+ * 0015 Linked Media Types describe different media (like images and documents) that enhance the description
+ * of an entity. Media entities can be added to any Referenceable entities.
+ */
+ private void add0015LinkedMediaTypes()
+ {
+ this.archiveBuilder.addEnumDef(getMediaUsageEnum());
+
+ this.archiveBuilder.addEntityDef(getExternalReferenceEntity());
+ this.archiveBuilder.addEntityDef(getRelatedMediaEntity());
+
+ this.archiveBuilder.addRelationshipDef(getExternalReferenceLinkRelationship());
+ this.archiveBuilder.addRelationshipDef(getMediaReferenceRelationship());
+ }
+
+ private EnumDef getMediaUsageEnum()
+ {
+ final String guid = "c6861a72-7485-48c9-8040-876f6c342b61";
+ final String name = "MediaUsage";
+ final String description = "Defines how a related media reference should be used.";
+ final String descriptionGUID = null;
+
+ EnumDef enumDef = getEmptyEnumDef(guid, name, description, descriptionGUID);
+
+ ArrayList<EnumElementDef> elementDefs = new ArrayList();
+ EnumElementDef elementDef;
+
+ final int element1Ordinal = 0;
+ final String element1Value = "Icon";
+ final String element1Description = "Provides a small image to represent the asset in tree views and graphs.";
+ final String element1DescriptionGUID = null;
+
+ elementDef = getEnumElementDef(element1Ordinal, element1Value, element1Description, element1DescriptionGUID);
+ elementDefs.add(elementDef);
+
+ final int element2Ordinal = 1;
+ final String element2Value = "Thumbnail";
+ final String element2Description = "Provides a small image about the asset that can be used in lists.";
+ final String element2DescriptionGUID = null;
+
+ elementDef = getEnumElementDef(element2Ordinal, element2Value, element2Description, element2DescriptionGUID);
+ elementDefs.add(elementDef);
+
+ final int element3Ordinal = 2;
+ final String element3Value = "Illustration";
+ final String element3Description = "Illustrates how the asset works or what it contains. It is complementary to the asset's description.";
+ final String element3DescriptionGUID = null;
+
+ elementDef = getEnumElementDef(element3Ordinal, element3Value, element3Description, element3DescriptionGUID);
+ elementDefs.add(elementDef);
+
+ final int element4Ordinal = 3;
+ final String element4Value = "Usage Guidance";
+ final String element4Description = "Provides guidance to a person on how to use the asset.";
+ final String element4DescriptionGUID = null;
+
+ elementDef = getEnumElementDef(element4Ordinal, element4Value, element4Description, element4DescriptionGUID);
+ elementDefs.add(elementDef);
+
+ final int element5Ordinal = 99;
+ final String element5Value = "Other";
+ final String element5Description = "Another usage.";
+ final String element5DescriptionGUID = null;
+
+ elementDef = getEnumElementDef(element5Ordinal, element5Value, element5Description, element5DescriptionGUID);
+ elementDefs.add(elementDef);
+
+ enumDef.setElementDefs(elementDefs);
+
+ return enumDef;
+ }
+
+ private EntityDef getExternalReferenceEntity()
+ {
+ final String guid = "af536f20-062b-48ef-9c31-1ddd05b04c56";
+ final String name = "ExternalReference";
+ final String description = "A link to more information.";
+ final String descriptionGUID = null;
+
+ // TODO
+ return null;
+ }
+
+ private EntityDef getRelatedMediaEntity()
+ {
+ final String guid = "747f8b86-fe7c-4c9b-ba75-979e093cc307";
+ final String name = "RelatedMedia";
+ final String description = "Images, video or sound media.";
+ final String descriptionGUID = null;
+
+ // TODO
+ return null;
+ }
+
+ private RelationshipDef getExternalReferenceLinkRelationship()
+ {
+ final String guid = "7d818a67-ab45-481c-bc28-f6b1caf12f06";
+ final String name = "ExternalReferenceLink";
+ final String description = "Link to more information.";
+ final String descriptionGUID = null;
+
+ // TODO
+ return null;
+ }
+
+ private RelationshipDef getMediaReferenceRelationship()
+ {
+ final String guid = "1353400f-b0ab-4ab9-ab09-3045dd8a7140";
+ final String name = "MediaReference";
+ final String description = "Link to related media such as images, videos and audio.";
+ final String descriptionGUID = null;
+
+ // TODO
+ return null;
+ }
+
+ /*
+ * -------------------------------------------------------------------------------------------------------
+ */
+
+
+ /**
+ * 0017 External Identifiers define identifiers used to identify this entity in other systems.
+ */
+ private void add0017ExternalIdentifiers()
+ {
+ this.archiveBuilder.addEnumDef(getKeyPatternEnum());
+
+ this.archiveBuilder.addEntityDef(getExternalIdEntity());
+
+ this.archiveBuilder.addRelationshipDef(getExternalIdScopeRelationship());
+ this.archiveBuilder.addRelationshipDef(getExternalIdLinkRelationship());
+ }
+
+ private EnumDef getKeyPatternEnum()
+ {
+ final String guid = "8904df8f-1aca-4de8-9abd-1ef2aadba300";
+ final String name = "KeyPattern";
+ final String description = "Defines the type of identifier used for an asset.";
+ final String descriptionGUID = null;
+
+ EnumDef enumDef = getEmptyEnumDef(guid, name, description, descriptionGUID);
+
+ ArrayList<EnumElementDef> elementDefs = new ArrayList();
+ EnumElementDef elementDef;
+
+ final int element1Ordinal = 0;
+ final String element1Value = "Local Key";
+ final String element1Description = "Unique key allocated and used within the scope of a single system.";
+ final String element1DescriptionGUID = null;
+
+ elementDef = getEnumElementDef(element1Ordinal, element1Value, element1Description, element1DescriptionGUID);
+ elementDefs.add(elementDef);
+
+ final int element2Ordinal = 1;
+ final String element2Value = "Recycled Key";
+ final String element2Description = "Key allocated and used within the scope of a single system that is periodically reused for different records.";
+ final String element2DescriptionGUID = null;
+
+ elementDef = getEnumElementDef(element2Ordinal, element2Value, element2Description, element2DescriptionGUID);
+ elementDefs.add(elementDef);
+
+ final int element3Ordinal = 2;
+ final String element3Value = "Natural Key";
+ final String element3Description = "Key derived from an attribute of the entity, such as email address, passport number.";
+ final String element3DescriptionGUID = null;
+
+ elementDef = getEnumElementDef(element3Ordinal, element3Value, element3Description, element3DescriptionGUID);
+ elementDefs.add(elementDef);
+
+ final int element4Ordinal = 3;
+ final String element4Value = "Mirror Key";
+ final String element4Description = "Key value copied from another system.";
+ final String element4DescriptionGUID = null;
+
+ elementDef = getEnumElementDef(element4Ordinal, element4Value, element4Description, element4DescriptionGUID);
+ elementDefs.add(elementDef);
+
+ final int element5Ordinal = 4;
+ final String element5Value = "Aggregate Key";
+ final String element5Description = "Key formed by combining keys from multiple systems.";
+ final String element5DescriptionGUID = null;
+
+ elementDef = getEnumElementDef(element5Ordinal, element5Value, element5Description, element5DescriptionGUID);
+ elementDefs.add(elementDef);
+
+ final int element6Ordinal = 5;
+ final String element6Value = "Caller's Key";
+ final String element6Description = "Key from another system can bey used if system name provided.";
+ final String element6DescriptionGUID = null;
+
+ elementDef = getEnumElementDef(element6Ordinal, element6Value, element6Description, element6DescriptionGUID);
+ elementDefs.add(elementDef);
+
+ final int element7Ordinal = 6;
+ final String element7Value = "Stable Key";
+ final String element7Description = "Key value will remain active even if records are merged.";
+ final String element7DescriptionGUID = null;
+
+ elementDef = getEnumElementDef(element7Ordinal, element7Value, element7Description, element7DescriptionGUID);
+ elementDefs.add(elementDef);
+
+ final int element8Ordinal = 99;
+ final String element8Value = "Other";
+ final String element8Description = "Another key pattern.";
+ final String element8DescriptionGUID = null;
+
+ elementDef = getEnumElementDef(element8Ordinal, element8Value, element8Description, element8DescriptionGUID);
+ elementDefs.add(elementDef);
+
+ return enumDef;
+ }
+
+ private EntityDef getExternalIdEntity()
+ {
+ final String guid = "7c8f8c2c-cc48-429e-8a21-a1f1851ccdb0";
+ final String name = "ExternalId";
+ final String description = "Alternative identifier used in another system.";
+ final String descriptionGUID = null;
+
+ // TODO
+ return null;
+ }
+
+ private RelationshipDef getExternalIdScopeRelationship()
+ {
+ final String guid = "8c5b1415-2d1f-4190-ba6c-1fdd47f03269";
+ final String name = "ExternalIdScope";
+ final String description = "Places where an external identifier is recognized.";
+ final String descriptionGUID = null;
+
+ // TODO
+ return null;
+ }
+
+ private RelationshipDef getExternalIdLinkRelationship()
+ {
+ final String guid = "28ab0381-c662-4b6d-b787-5d77208de126";
+ final String name = "ExternalIdLink";
+ final String description = "Link between an external identifier and an asset.";
+ final String descriptionGUID = null;
+
+ // TODO
+ return null;
+ }
+
+ /*
+ * -------------------------------------------------------------------------------------------------------
+ */
+
+
+ /**
+ * 0020 Property Facets define blocks of properties that are unique to a particular vendor or service.
+ */
+ private void add0020PropertyFacets()
+ {
+ this.archiveBuilder.addEntityDef(getPropertyFacetEntity());
+
+ this.archiveBuilder.addRelationshipDef(getReferenceableFacetRelationship());
+ }
+
+ private EntityDef getPropertyFacetEntity()
+ {
+ final String guid = "6403a704-aad6-41c2-8e08-b9525c006f85";
+ final String name = "PropertyFacet";
+ final String description = "Additional properties that support a particular vendor or service.";
+ final String descriptionGUID = null;
+
+ // TODO
+ return null;
+ }
+
+ private RelationshipDef getReferenceableFacetRelationship()
+ {
+ final String guid = "58c87647-ada9-4c90-a3c3-a40ace46b1f7";
+ final String name = "ReferenceableFacet";
+ final String description = "Link between a property facet and the element it relates to.";
+ final String descriptionGUID = null;
+
+ // TODO
+ return null;
+ }
+
+ /*
+ * -------------------------------------------------------------------------------------------------------
+ */
+
+
+ /**
+ * 0025 Locations define entities that describe physical, logical and cyber locations for Assets.
+ */
+ private void add0025Locations()
+ {
+ this.archiveBuilder.addEntityDef(getLocationEntity());
+
+ this.archiveBuilder.addRelationshipDef(getNestedLocationRelationship());
+ this.archiveBuilder.addRelationshipDef(getAdjacentLocationRelationship());
+ this.archiveBuilder.addRelationshipDef(getAssetLocationRelationship());
+
+ this.archiveBuilder.addClassificationDef(getMobileAssetClassification());
+ this.archiveBuilder.addClassificationDef(getFixedLocationClassification());
+ this.archiveBuilder.addClassificationDef(getSecureLocationClassification());
+ this.archiveBuilder.addClassificationDef(getCyberLocationClassification());
+ }
+
+ private EntityDef getLocationEntity()
+ {
+ final String guid = "3e09cb2b-5f15-4fd2-b004-fe0146ad8628";
+ final String name = "Location";
+ final String description = "A physical place, digital location or area.";
+ final String descriptionGUID = null;
+
+ // TODO
+ return null;
+ }
+
+ private RelationshipDef getNestedLocationRelationship()
+ {
+ final String guid = "f82a96c2-95a3-4223-88c0-9cbf2882b772";
+ final String name = "NestedLocation";
+ final String description = "Link between two locations to show one is nested inside another.";
+ final String descriptionGUID = null;
+
+ // TODO
+ return null;
+ }
+
+ private RelationshipDef getAdjacentLocationRelationship()
+ {
+ final String guid = "017d0518-fc25-4e5e-985e-491d91e61e17";
+ final String name = "AdjacentLocation";
+ final String description = "Link between two locations that are next to one another.";
+ final String descriptionGUID = null;
+
+ // TODO
+ return null;
+ }
+
+ private RelationshipDef getAssetLocationRelationship()
+ {
+ final String guid = "bc236b62-d0e6-4c5c-93a1-3a35c3dba7b1";
+ final String name = "AssetLocation";
+ final String description = "Location of an Asset.";
+ final String descriptionGUID = null;
+
+ // TODO
+ return null;
+ }
+
+ private ClassificationDef getMobileAssetClassification()
+ {
+ final String guid = "b25fb90d-8fa2-4aa9-b884-ff0a6351a697";
+ final String name = "MobileAsset";
+ final String description = "An asset not restricted to a single physical location.";
+ final String descriptionGUID = null;
+
+ // TODO
+ return null;
+ }
+
+ private ClassificationDef getFixedLocationClassification()
+ {
+ final String guid = "bc111963-80c7-444f-9715-946c03142dd2";
+ final String name = "FixedLocation";
+ final String description = "A location linked to a physical place.";
+ final String descriptionGUID = null;
+
+ // TODO
+ return null;
+ }
+
+ private ClassificationDef getSecureLocationClassification()
+ {
+ final String guid = "e7b563c0-fcdd-4ba7-a046-eecf5c4638b8";
+ final String name = "SecureLocation";
+ final String description = "A location that protects the assets in its care.";
+ final String descriptionGUID = null;
+
+ // TODO
+ return null;
+ }
+
+ private ClassificationDef getCyberLocationClassification()
+ {
+ final String guid = "f9ec3633-8ac8-480b-aa6d-5e674b9e1b17";
+ final String name = "CyberLocation";
+ final String description = "A digital location.";
+ final String descriptionGUID = null;
+
+ // TODO
+ return null;
+ }
+
+
+ /*
+ * -------------------------------------------------------------------------------------------------------
+ */
+
+
+ /**
+ * 0030 Hosts and Platforms describe the Software and Hardware platforms hosting Assets.
+ */
+ private void add0030HostsAndPlatforms()
+ {
+ this.archiveBuilder.addEnumDef(getEndiannessEnum());
+
+ this.archiveBuilder.addEntityDef(getITInfrastructureEntity());
+ this.archiveBuilder.addEntityDef(getHostEntity());
+ this.archiveBuilder.addEntityDef(getOperatingPlatformEntity());
+
+ this.archiveBuilder.addRelationshipDef(getHostLocationRelationship());
+ this.archiveBuilder.addRelationshipDef(getHostOperatingPlatformRelationship());
+ }
+
+ private EnumDef getEndiannessEnum()
+ {
+ final String guid = "e5612c3a-49bd-4148-8f67-cfdf145d5fd8";
+ final String name = "Endianness";
+ final String description = "Defines the sequential order in which bytes are arranged into larger numerical values when stored in memory or when transmitted over digital links.";
+ final String descriptionGUID = null;
+
+ EnumDef enumDef = getEmptyEnumDef(guid, name, description, descriptionGUID);
+
+ ArrayList<EnumElementDef> elementDefs = new ArrayList();
+ EnumElementDef elementDef;
+
+ final int element1Ordinal = 0;
+ final String element1Value = "Big Endian";
+ final String element1Description = "Bits or bytes order from the big end.";
+ final String element1DescriptionGUID = null;
+
+ elementDef = getEnumElementDef(element1Ordinal, element1Value, element1Description, element1DescriptionGUID);
+ elementDefs.add(elementDef);
+
+ final int element2Ordinal = 1;
+ final String element2Value = "Little Endian";
+ final String element2Description = "Bits or bytes ordered from the little end.";
+ final String element2DescriptionGUID = null;
+
+ elementDef = getEnumElementDef(element2Ordinal, element2Value, element2Description, element2DescriptionGUID);
+ elementDefs.add(elementDef);
+
+ return enumDef;
+ }
+
+ private EntityDef getITInfrastructureEntity()
+ {
+ final String guid = "151e6dd1-54a0-4b7f-a072-85caa09d1dda";
+ final String name = "ITInfrastructure";
+ final String description = "Hardware and base software that supports an IT system.";
+ final String descriptionGUID = null;
+
+ // TODO
+ return null;
+ }
+
+ private EntityDef getHostEntity()
+ {
+ final String guid = "1abd16db-5b8a-4fd9-aee5-205db3febe99";
+ final String name = "Host";
+ final String description = "Named IT infrastructure system that supports multiple software servers.";
+ final String descriptionGUID = null;
+
+ // TODO
+ return null;
+ }
+
+ private EntityDef getOperatingPlatformEntity()
+ {
+ final String guid = "bd96a997-8d78-42f6-adf7-8239bc98501c";
+ final String name = "OperatingPlatform";
+ final String description = "Characteristics of the operating system in use within a host.";
+ final String descriptionGUID = null;
+
+ // TODO
+ return null;
+ }
+
+ private RelationshipDef getHostLocationRelationship()
+ {
+ final String guid = "f3066075-9611-4886-9244-32cc6eb07ea9";
+ final String name = "HostLocation";
+ final String description = "Defines the location of a host.";
+ final String descriptionGUID = null;
+
+ // TODO
+ return null;
+ }
+
+ private RelationshipDef getHostOperatingPlatformRelationship()
+ {
+ final String guid = "b9179df5-6e23-4581-a8b0-2919e6322b12";
+ final String name = "HostOperatingPlatform";
+ final String description = "Identifies the operating platform for a host.";
+ final String descriptionGUID = null;
+
+ // TODO
+ return null;
+ }
+
+ /*
+ * -------------------------------------------------------------------------------------------------------
+ */
+
+
+ /**
+ * 0035 Complex Hosts describe virtualization and clustering options for Hosts.
+ */
+ private void add0035ComplexHosts()
+ {
+ this.archiveBuilder.addEntityDef(getHostClusterEntity());
+ this.archiveBuilder.addEntityDef(getVirtualContainerEntity());
+
+ this.archiveBuilder.addRelationshipDef(getHostClusterMemberRelationship());
+ this.archiveBuilder.addRelationshipDef(getDeployedVirtualContainerRelationship());
+ }
+
+ private EntityDef getHostClusterEntity()
+ {
+ final String guid = "9794f42f-4c9f-4fe6-be84-261f0a7de890";
+ final String name = "HostCluster";
+ final String description = "A group of hosts operating together to provide a scalable platform.";
+ final String descriptionGUID = null;
+ // TODO
+ return null;
+ }
+
+ private EntityDef getVirtualContainerEntity()
+ {
+ final String guid = "e2393236-100f-4ac0-a5e6-ce4e96c521e7";
+ final String name = "VirtualContainer";
+ final String description = "Container-based virtual host.";
+ final String descriptionGUID = null;
+
+ // TODO
+ return null;
+ }
+
+ private RelationshipDef getHostClusterMemberRelationship()
+ {
+ final String guid = "1a1c3933-a583-4b0c-9e42-c3691296a8e0";
+ final String name = "HostClusterMember";
+ final String description = "Identifies a host as a member of a host cluster.";
+ final String descriptionGUID = null;
+
+ // TODO
+ return null;
+ }
+
+ private RelationshipDef getDeployedVirtualContainerRelationship()
+ {
+ final String guid = "4b981d89-e356-4d9b-8f17-b3a8d5a86676";
+ final String name = "DeployedVirtualContainer";
+ final String description = "Identifies the real host where a virtual container is deployed to.";
+ final String descriptionGUID = null;
+
+ // TODO
+ return null;
+ }
+
+ /*
+ * -------------------------------------------------------------------------------------------------------
+ */
+
+
+ /**
+ * 0040 Software Servers describe the structure of a software server and its capabilities.
+ */
+ private void add0040SoftwareServers()
+ {
+ this.archiveBuilder.addEnumDef(getOperationalStatusEnum());
+
+ this.archiveBuilder.addEntityDef(getSoftwareServerEntity());
+ this.archiveBuilder.addEntityDef(getEndpointEntity());
+ this.archiveBuilder.addEntityDef(getSoftwareServerCapabilityEntity());
+
+ this.archiveBuilder.addRelationshipDef(getServerDeploymentRelationship());
+ this.archiveBuilder.addRelationshipDef(getServerSupportedCapabilityRelationship());
+ this.archiveBuilder.addRelationshipDef(getServerEndpointRelationship());
+ }
+
+
+ private EnumDef getOperationalStatusEnum()
+ {
+ final String guid = "24e1e33e-9250-4a6c-8b07-05c7adec3a1d";
+ final String name = "OperationalStatus";
+ final String description = "Defines whether a component is operational.";
+ final String descriptionGUID = null;
+
+ EnumDef enumDef = getEmptyEnumDef(guid, name, description, descriptionGUID);
+
+ ArrayList<EnumElementDef> elementDefs = new ArrayList();
+ EnumElementDef elementDef;
+
+ final int element1Ordinal = 0;
+ final String element1Value = "Disabled";
+ final String element1Description = "The component is not operational.";
+ final String element1DescriptionGUID = null;
+
+ elementDef = getEnumElementDef(element1Ordinal, element1Value, element1Description, element1DescriptionGUID);
+ elementDefs.add(elementDef);
+
+ final int element2Ordinal = 1;
+ final String element2Value = "Enabled";
+ final String element2Description = "The component is operational.";
+ final String element2DescriptionGUID = null;
+
+ elementDef = getEnumElementDef(element2Ordinal, element2Value, element2Description, element2DescriptionGUID);
+ elementDefs.add(elementDef);
+
+ return enumDef;
+ }
+
+
+ private EntityDef getSoftwareServerEntity()
+ {
+ final String guid = "aa7c7884-32ce-4991-9c41-9778f1fec6aa";
+ final String name = "SoftwareServer";
+ final String description = "Software services to support a runtime environment for applications and data stores.";
+ final String descriptionGUID = null;
+
+ // TODO
+ return null;
+ }
+
+
+ private EntityDef getEndpointEntity()
+ {
+ final String guid = "dbc20663-d705-4ff0-8424-80c262c6b8e7";
+ final String name = "Endpoint";
+ final String description = "Description of the network address and related information needed to call a software service.";
+ final String descriptionGUID = null;
+
+ // TODO
+ return null;
+ }
+
+
+ private EntityDef getSoftwareServerCapabilityEntity()
+ {
+ final String guid = "fe30a033-8f86-4d17-8986-e6166fa24177";
+ final String name = "SoftwareServerCapability";
+ final String description = "A software capability such as an application, that is deployed to a software server.";
+ final String descriptionGUID = null;
+
+ // TODO
+ return null;
+ }
+
+
+ private RelationshipDef getServerDeploymentRelationship()
+ {
+ final String guid = "d909eb3b-5205-4180-9f63-122a65b30738";
+ final String name = "ServerDeployment";
+ final String description = "Defines the host that a software server is deployed to.";
+ final String descriptionGUID = null;
+
+ // TODO
+ return null;
+ }
+
+ private RelationshipDef getServerSupportedCapabilityRelationship()
+ {
+ final String guid = "8b7d7da5-0668-4174-a43b-8f8c6c068dd0";
+ final String name = "ServerSupportedCapability";
+ final String description = "Identifies a software capability that is deployed to a software server.";
+ final String descriptionGUID = null;
+
+ // TODO
+ return null;
+ }
+
+ private RelationshipDef getServerEndpointRelationship()
+ {
+ final String guid = "2b8bfab4-8023-4611-9833-82a0dc95f187";
+ final String name = "ServerEndpoint";
+ final String description = "Defines an endpoint associated with a server.";
+ final String descriptionGUID = null;
+
+ // TODO
+ return null;
+ }
+
+ /*
+ * -------------------------------------------------------------------------------------------------------
+ */
+
+
+ /**
+ * 0045 Servers and Assets defines the relationships between SoftwareServers and Assets.
+ */
+ private void add0045ServersAndAssets()
+ {
+ this.archiveBuilder.addEnumDef(getServerAssetUseTypeEnum());
+
+ this.archiveBuilder.addRelationshipDef(getServerAssetUseRelationship());
+ }
+
+
+ private EnumDef getServerAssetUseTypeEnum()
+ {
+ final String guid = "09439481-9489-467c-9ae5-178a6e0b6b5a";
+ final String name = "ServerAssetUse";
+ final String description = "Defines how a server capability may use an asset.";
+ final String descriptionGUID = null;
+
+ // TODO
+ return null;
+ }
+
+ private RelationshipDef getServerAssetUseRelationship()
+ {
+ final String guid = "92b75926-8e9a-46c7-9d98-89009f622397";
+ final String name = "AssetServerUse";
+ final String description = "Defines that a server capability is using an asset.";
+ final String descriptionGUID = null;
+
+ // TODO
+ return null;
+ }
+
+ /*
+ * -------------------------------------------------------------------------------------------------------
+ */
+
+
+ /**
+ * 0070 Networks and Gateways provide a very simple network model.
+ */
+ private void add0070NetworksAndGateways()
+ {
+ this.archiveBuilder.addEntityDef(getNetworkEntity());
+ this.archiveBuilder.addEntityDef(getNetworkGatewayEntity());
+
+ this.archiveBuilder.addRelationshipDef(getHostNetworkRelationship());
+ this.archiveBuilder.addRelationshipDef(getNetworkGatewayLinkRelationship());
+ }
+
+ private EntityDef getNetworkEntity()
+ {
+ final String guid = "e0430f59-f021-411a-9d81-883e1ff3f6f6";
+ final String name = "ITInfrastructure";
+ final String description = "Hardware and base software that supports an IT system.";
+ final String descriptionGUID = null;
+
+ // TODO
+ return null;
+ }
+
+ private EntityDef getNetworkGatewayEntity()
+ {
+ final String guid = "9bbae94d-e109-4c96-b072-4f97123f04fd";
+
+ // TODO
+ return null;
+ }
+
+ private RelationshipDef getHostNetworkRelationship()
+ {
+ final String guid = "f2bd7401-c064-41ac-862c-e5bcdc98fa1e";
+
+ // TODO
+ return null;
+ }
+
+
+ private RelationshipDef getNetworkGatewayLinkRelationship()
+ {
+ final String guid = "5bece460-1fa6-41fb-a29f-fdaf65ec8ce3";
+
+ // TODO
+ return null;
+ }
+
+ /*
+ * -------------------------------------------------------------------------------------------------------
+ */
+
+ /**
+ * 0090 Cloud Platforms and Services provides classifications for infrastructure to allow cloud platforms
+ * and services to be identified.
+ */
+ private void add0090CloudPlatformsAndServices()
+ {
+ this.archiveBuilder.addClassificationDef(getCloudProviderClassification());
+ this.archiveBuilder.addClassificationDef(getCloudPlatformClassification());
+ this.archiveBuilder.addClassificationDef(getCloudServiceClassification());
+ }
+
+ private ClassificationDef getCloudProviderClassification()
+ {
+ final String guid = "a2bfdd08-d0a8-49db-bc97-7f2406281046";
+
+ // TODO
+ return null;
+ }
+
+ private ClassificationDef getCloudPlatformClassification()
+ {
+ final String guid = "1b8f8511-e606-4f65-86d3-84891706ad12";
+
+ // TODO
+ return null;
+ }
+
+ private ClassificationDef getCloudServiceClassification()
+ {
+ final String guid = "337e7b1a-ad4b-4818-aa3e-0ff3307b2fbe";
+
+ // TODO
+ return null;
+ }
+
+ /*
+ * ========================================
+ * AREA 1 - collaboration
+ */
+
+ private void addArea1Types()
+ {
+ this.add0110Actors();
+ this.add0120Collections();
+ this.add0130Projects();
+ this.add0135Meetings();
+ this.add0140Communities();
+ this.add0150Feedback();
+ this.add0160Notes();
+ }
+
+
+ /*
+ * -------------------------------------------------------------------------------------------------------
+ */
+
+ /**
+ * 0110 Actors describe the people and their relationships who are using the Assets.
+ */
+ private void add0110Actors()
+ {
+ this.archiveBuilder.addEnumDef(getCrowdSourcingRoleEnum());
+ this.archiveBuilder.addEnumDef(getContactMethodTypeEnum());
+
+ this.archiveBuilder.addEntityDef(getActorProfileEntity());
+ this.archiveBuilder.addEntityDef(getTeamEntity());
+ this.archiveBuilder.addEntityDef(getPersonEntity());
+ this.archiveBuilder.addEntityDef(getUserIdentityEntity());
+ this.archiveBuilder.addEntityDef(getContactDetailsEntity());
+
+ this.archiveBuilder.addRelationshipDef(getContactThroughRelationship());
+ this.archiveBuilder.addRelationshipDef(getLeadershipRelationship());
+ this.archiveBuilder.addRelationshipDef(getPeerRelationship());
+ this.archiveBuilder.addRelationshipDef(getProfileIdentityRelationship());
+ this.archiveBuilder.addRelationshipDef(getContributorRelationship());
+ }
+
+ private EnumDef getCrowdSourcingRoleEnum()
+ {
+ final String guid = "0ded50c2-17cc-4ecf-915e-908e66dbb27f";
+
+ // TODO
+ return null;
+ }
+
+ private EnumDef getContactMethodTypeEnum()
+ {
+ final String guid = "30e7d8cd-df01-46e8-9247-a24c5650910d";
+
+ // TODO
+ return null;
+ }
+
+ private EntityDef getActorProfileEntity()
+ {
+ final String guid = "5a2f38dc-d69d-4a6f-ad26-ac86f118fa35";
+
+ // TODO
+ return null;
+ }
+
+ private EntityDef getTeamEntity()
+ {
+ final String guid = "36db26d5-aba2-439b-bc15-d62d373c5db6";
+
+ // TODO
+ return null;
+ }
+
+ private EntityDef getPersonEntity()
+ {
+ final String guid = "ac406bf8-e53e-49f1-9088-2af28bbbd285";
+
+ // TODO
+ return null;
+ }
+
+ private EntityDef getUserIdentityEntity()
+ {
+ final String guid = "fbe95779-1f3c-4ac6-aa9d-24963ff16282";
+
+ // TODO
+ return null;
+ }
+
+ private EntityDef getContactDetailsEntity()
+ {
+ final String guid = "79296df8-645a-4ef7-a011-912d1cdcf75a";
+
+ // TODO
+ return null;
+ }
+
+ private RelationshipDef getContactThroughRelationship()
+ {
+ final String guid = "6cb9af43-184e-4dfa-854a-1572bcf0fe75";
+
+ // TODO
+ return null;
+ }
+
+ private RelationshipDef getLeadershipRelationship()
+ {
+ final String guid = "5ebc4fb2-b62a-4269-8f18-e9237a2119ca";
+
+ // TODO
+ return null;
+ }
+
+ private RelationshipDef getPeerRelationship()
+ {
+ final String guid = "4a316abe-bccd-4d11-ad5a-4bfb4079b80b";
+
+ // TODO
+ return null;
+ }
+
+ private RelationshipDef getProfileIdentityRelationship()
+ {
+ final String guid = "01664609-e777-4079-b543-6baffe910ff1";
+
+ // TODO
+ return null;
+ }
+
+ private RelationshipDef getContributorRelationship()
+ {
+ final String guid = "4db83564-b200-4956-94a4-c95a5c30e65a";
+
+ // TODO
+ return null;
+ }
+
+ /*
+ * -------------------------------------------------------------------------------------------------------
+ */
+
+
+ /**
+ * 0120 Collections defines how to group related Referenceables together
+ */
+ private void add0120Collections()
+ {
+ this.archiveBuilder.addEnumDef(getOrderByEnum());
+
+ this.archiveBuilder.addEntityDef(getCollectionEntity());
+
+ this.archiveBuilder.addRelationshipDef(getCollectionMembershipRelationship());
+ this.archiveBuilder.addRelationshipDef(getActorCollectionRelationship());
+
+ this.archiveBuilder.addClassificationDef(getFolderClassification());
+ this.archiveBuilder.addClassificationDef(getSetClassification());
+ }
+
+
+ private EnumDef getOrderByEnum()
+ {
+ final String guid = "1d412439-4272-4a7e-a940-1065f889fc56";
+
+ // TODO
+ return null;
+ }
+
+ private EntityDef getCollectionEntity()
+ {
+ final String guid = "347005ba-2b35-4670-b5a7-12c9ebed0cf7";
+
+ // TODO
+ return null;
+ }
+
+ private RelationshipDef getCollectionMembershipRelationship()
+ {
+ final String guid = "5cabb76a-e25b-4bb5-8b93-768bbac005af";
+
+ // TODO
+ return null;
+ }
+
+ private RelationshipDef getActorCollectionRelationship()
+ {
+ final String guid = "73cf5658-6a73-4ebc-8f4d-44fdfac0b437";
+
+ // TODO
+ return null;
+ }
+
+ private ClassificationDef getFolderClassification()
+ {
+ final String guid = "3c0fa687-8a63-4c8e-8bda-ede9c78be6c7";
+
+ // TODO
+ return null;
+ }
+
+ private ClassificationDef getSetClassification()
+ {
+ final String guid = "3947f08d-7412-4022-81fc-344a20dfbb26";
+
+ // TODO
+ return null;
+ }
+
+ /*
+ * -------------------------------------------------------------------------------------------------------
+ */
+
+
+ /**
+ * 0130 Projects describes the structure of a project and related collections.
+ */
+ private void add0130Projects()
+ {
+ this.archiveBuilder.addEntityDef(getProjectEntity());
+
+ this.archiveBuilder.addRelationshipDef(getProjectHierarchyRelationship());
+ this.archiveBuilder.addRelationshipDef(getProjectDependencyRelationship());
+ this.archiveBuilder.addRelationshipDef(getProjectTeamRelationship());
+ this.archiveBuilder.addRelationshipDef(getProjectResourcesRelationship());
+ this.archiveBuilder.addRelationshipDef(getProjectScopeRelationship());
+
+ this.archiveBuilder.addClassificationDef(getTaskClassification());
+ this.archiveBuilder.addClassificationDef(getCampaignClassification());
+ }
+
+ private EntityDef getProjectEntity()
+ {
+ final String guid = "0799569f-0c16-4a1f-86d9-e2e89568f7fd";
+
+ // TODO
+ return null;
+ }
+
+ private RelationshipDef getProjectHierarchyRelationship()
+ {
+ final String guid = "8f1134f6-b9fe-4971-bc57-6e1b8b302b55";
+
+ // TODO
+ return null;
+ }
+
+ private RelationshipDef getProjectDependencyRelationship()
+ {
+ final String guid = "5b6a56f1-68e2-4e10-85f0-fda47a4263fd";
+
+ // TODO
+ return null;
+ }
+
+ private RelationshipDef getProjectTeamRelationship()
+ {
+ final String guid = "746875af-2e41-4d1f-864b-35265df1d5dc";
+
+ // TODO
+ return null;
+ }
+
+ private RelationshipDef getProjectResourcesRelationship()
+ {
+ final String guid = "03d25e7b-1c5b-4352-a472-33aa0ddcad4d";
+
+ // TODO
+ return null;
+ }
+
+ private RelationshipDef getProjectScopeRelationship()
+ {
+ final String guid = "bc63ac45-b4d0-4fba-b583-92859de77dd8";
+
+ // TODO
+ return null;
+ }
+
+ private ClassificationDef getTaskClassification()
+ {
+ final String guid = "2312b668-3670-4845-a140-ef88d5a6db0c";
+
+ // TODO
+ return null;
+ }
+
+ private ClassificationDef getCampaignClassification()
+ {
+ final String guid = "41437629-8609-49ef-8930-8c435c912572";
+
+ // TODO
+ return null;
+ }
+
+ /*
+ * -------------------------------------------------------------------------------------------------------
+ */
+
+
+ /**
+ * 0135 Meetings defines how to record meetings and todos.
+ */
+ private void add0135Meetings()
+ {
+ this.archiveBuilder.addEnumDef(getToDoEnum());
+
+ this.archiveBuilder.addEntityDef(getMeetingEntity());
+ this.archiveBuilder.addEntityDef(getToDoEntity());
+
+ this.archiveBuilder.addRelationshipDef(getMeetingOnReferenceableRelationship());
+ this.archiveBuilder.addRelationshipDef(getTodoOnReferenceableRelationship());
+ this.archiveBuilder.addRelationshipDef(getProjectMeetingRelationship());
+ }
+
+
+ private EnumDef getToDoEnum()
+ {
+ final String guid = "7197ea39-334d-403f-a70b-d40231092df7";
+
+ // TODO
+ return null;
+ }
+
+ private EntityDef getMeetingEntity()
+ {
+ final String guid = "6bf90c79-32f4-47ad-959c-8fff723fe744";
+
+ // TODO
+ return null;
+ }
+
+ private EntityDef getToDoEntity()
+ {
+ final String guid = "93dbc58d-c826-4bc2-b36f-195148d46f86";
+
+ // TODO
+ return null;
+ }
+
+ private RelationshipDef getMeetingOnReferenceableRelationship()
+ {
+ final String guid = "a05f918e-e7e2-419d-8016-5b37406df63a";
+
+ // TODO
+ return null;
+ }
+
+ private RelationshipDef getTodoOnReferenceableRelationship()
+ {
+ final String guid = "aca1277b-bf1c-42f5-9b3b-fbc2c9047325";
+
+ // TODO
+ return null;
+ }
+
+ private RelationshipDef getProjectMeetingRelationship()
+ {
+ final String guid = "af2b5fab-8f83-4a2b-b749-1e6219f61f79";
+
+ // TODO
+ return null;
+ }
+
+ /*
+ * -------------------------------------------------------------------------------------------------------
+ */
+
+
+ /**
+ * 0140 Communities describe communities of people who have similar interests.
+ */
+ private void add0140Communities()
+ {
+ this.archiveBuilder.addEnumDef(getCommunityMembershipTypeEnum());
+
+ this.archiveBuilder.addEntityDef(getCommunityEntity());
+
+ this.archiveBuilder.addRelationshipDef(getCommunityMembershipRelationship());
+ this.archiveBuilder.addRelationshipDef(getCommunityResourcesRelationship());
+ }
+
+
+ private EnumDef getCommunityMembershipTypeEnum()
+ {
+ final String guid = "b0ef45bf-d12b-4b6f-add6-59c14648d750";
+
+ // TODO
+ return null;
+ }
+
+ private EntityDef getCommunityEntity()
+ {
+ final String guid = "fbd42379-f6c3-4f08-b6f7-378565cda993";
+
+ // TODO
+ return null;
+ }
+
+ private RelationshipDef getCommunityMembershipRelationship()
+ {
+ final String guid = "7c7da1a3-01b3-473e-972e-606eff0cb112";
+
+ // TODO
+ return null;
+ }
+
+ private RelationshipDef getCommunityResourcesRelationship()
+ {
+ final String guid = "484d4fb9-4927-4926-8e6d-03e6c9885254";
+
+ // TODO
+ return null;
+ }
+
+ /*
+ * -------------------------------------------------------------------------------------------------------
+ */
+
+
+ /**
+ * 0150 Feedback provides all of the collaborative feedback and attachments that can be made by the user
+ * community of the Assets.
+ */
+ private void add0150Feedback()
+ {
+ this.archiveBuilder.addEnumDef(getStarRatingEnum());
+ this.archiveBuilder.addEnumDef(getCommentTypeEnum());
+
+ this.archiveBuilder.addEntityDef(getRatingEntity());
+ this.archiveBuilder.addEntityDef(getCommentEntity());
+ this.archiveBuilder.addEntityDef(getLikeEntity());
+ this.archiveBuilder.addEntityDef(getInformalTagEntity());
+ this.archiveBuilder.addEntityDef(getPrivateTagEntity());
+
+ this.archiveBuilder.addRelationshipDef(getAttachRatingRelationship());
+ this.archiveBuilder.addRelationshipDef(getAttachedCommentRelationship());
+ this.archiveBuilder.addRelationshipDef(getAttachedLikeRelationship());
+ this.archiveBuilder.addRelationshipDef(getAcceptedAnswerRelationship());
+ this.archiveBuilder.addRelationshipDef(getAttachedTagRelationship());
+ }
+
+
+ private EnumDef getStarRatingEnum()
+ {
+ final String guid = "77fea3ef-6ec1-4223-8408-38567e9d3c93";
+
+ // TODO
+ return null;
+ }
+
+ private EnumDef getCommentTypeEnum()
+ {
+ final String guid = "06d5032e-192a-4f77-ade1-a4b97926e867";
+
+ // TODO
+ return null;
+ }
+
+ private EntityDef getRatingEntity()
+ {
+ final String guid = "7299d721-d17f-4562-8286-bcd451814478";
+
+ // TODO
+ return null;
+ }
+
+ private EntityDef getCommentEntity()
+ {
+ final String guid = "1a226073-9c84-40e4-a422-fbddb9b84278";
+
+ // TODO
+ return null;
+ }
+
+ private EntityDef getLikeEntity()
+ {
+ final String guid = "deaa5ca0-47a0-483d-b943-d91c76744e01";
+
+ // TODO
+ return null;
+ }
+
+ private EntityDef getInformalTagEntity()
+ {
+ final String guid = "ba846a7b-2955-40bf-952b-2793ceca090a";
+
+ // TODO
+ return null;
+ }
+
+ private EntityDef getPrivateTagEntity()
+ {
+ final String guid = "9b3f5443-2475-4522-bfda-8f1f17e9a6c3";
+
+ // TODO
+ return null;
+ }
+
+ private RelationshipDef getAttachRatingRelationship()
+ {
+ final String guid = "0aaad9e9-9cc5-4ad8-bc2e-c1099bab6344";
+
+ // TODO
+ return null;
+ }
+
+ private RelationshipDef getAttachedCommentRelationship()
+ {
+ final String guid = "0d90501b-bf29-4621-a207-0c8c953bdac9";
+
+ // TODO
+ return null;
+ }
+
+ private RelationshipDef getAttachedLikeRelationship()
+ {
+ final String guid = "e2509715-a606-415d-a995-61d00503dad4";
+
+ // TODO
+ return null;
+ }
+
+ private RelationshipDef getAcceptedAnswerRelationship()
+ {
+ final String guid = "ecf1a3ca-adc5-4747-82cf-10ec590c5c69";
+
+ // TODO
+ return null;
+ }
+
+ private RelationshipDef getAttachedTagRelationship()
+ {
+ final String guid = "4b1641c4-3d1a-4213-86b2-d6968b6c65ab";
+
+ // TODO
+ return null;
+ }
+
+
+
+ /*
+ * -------------------------------------------------------------------------------------------------------
+ */
+
+
+ /**
+ * 0160 Notes describes notelogs and notes within them. Notes are kept but the owners/stewards working on the
+ * Assets.
+ */
+ private void add0160Notes()
+ {
+ this.archiveBuilder.addEntityDef(getNoteEntryEntity());
+ this.archiveBuilder.addEntityDef(getNoteLogEntity());
+
+ this.archiveBuilder.addRelationshipDef(getAttachedNoteLogRelationship());
+ this.archiveBuilder.addRelationshipDef(getAttachedNoteLogEntryRelationship());
+ }
+
+ private EntityDef getNoteEntryEntity()
+ {
+ final String guid = "2a84d94c-ac6f-4be1-a72a-07dcec7b1fe3";
+
+ // TODO
+ return null;
+ }
+
+ private EntityDef getNoteLogEntity()
+ {
+ final String guid = "646727c7-9ad4-46fa-b660-265489ad96c6";
+
+ // TODO
+ return null;
+ }
+
+ private RelationshipDef getAttachedNoteLogRelationship()
+ {
+ final String guid = "4f798c0c-6769-4a2d-b489-d2714d89e0a4";
+
+ // TODO
+ return null;
+ }
+
+ private RelationshipDef getAttachedNoteLogEntryRelationship()
+ {
+ final String guid = "38edecc6-f385-4574-8144-524a44e3e712";
+
+ // TODO
+ return null;
+ }
+
+ /*
+ * ========================================
+ * AREA 2 - connectors and assets
+ */
+
+ /**
+ * Area 2 covers the different types of Assets and the Connection information used by the Open Connector Framework
+ * (OCF).
+ */
+ private void addArea2Types()
+ {
+ this.add0201ConnectorsAndConnections();
+ this.add0205ConnectionLinkage();
+ this.add0210DataStores();
+ this.add0211DataSets();
+ this.add0212DeployedAPIs();
+ this.add0215SoftwareComponents();
+ this.add0217AutomatedProcesses();
+ this.add0220FilesAndFolders();
+ this.add0221DocumentStores();
+ this.add0222GraphStores();
+ this.add0223EventsAndLogs();
+ this.add0224Databases();
+ this.add0225MetadataRepositories();
+ this.add0227Keystores();
+ this.add0230CodeTables();
+ this.add0235InfomationView();
+ this.add0237InformationSet();
+ this.add0239Reports();
+ this.add0240ApplicationsAndProcesses();
+ this.add0250DataProcessingEngines();
+ this.add0260Transformations();
+ this.add0265AnalyticsAssets();
+ this.add0270IoTAssets();
+ this.add0280ModelAssets();
+ }
+
+ /*
+ * -------------------------------------------------------------------------------------------------------
+ */
+
+ /**
+ * 0201 Connectors and Connections defines the details of the Connection that describes the connector type
+ * and endpoint for a specific connector instance.
+ */
+ void add0201ConnectorsAndConnections()
+ {
+ this.archiveBuilder.addEntityDef(getConnectionEntity());
+ this.archiveBuilder.addEntityDef(getConnectorTypeEntity());
+
+ this.archiveBuilder.addRelationshipDef(getConnectionEndpointRelationship());
+ this.archiveBuilder.addRelationshipDef(getConnectionConnectorTypeRelationship());
+ }
+
+ private EntityDef getConnectionEntity()
+ {
+ final String guid = "114e9f8f-5ff3-4c32-bd37-a7eb42712253";
+
+ // TODO
+ return null;
+ }
+
+ private EntityDef getConnectorTypeEntity()
+ {
+ final String guid = "954421eb-33a6-462d-a8ca-b5709a1bd0d4";
+
+ // TODO
+ return null;
+ }
+
+ private RelationshipDef getConnectionEndpointRelationship()
+ {
+ final String guid = "887a7132-d6bc-4b92-a483-e80b60c86fb2";
+
+ // TODO
+ return null;
+ }
+
+ private RelationshipDef getConnectionConnectorTypeRelationship()
+ {
+ final String guid = "e542cfc1-0b4b-42b9-9921-f0a5a88aaf96";
+
+ // TODO
+ return null;
+ }
+
+
+ /*
+ * -------------------------------------------------------------------------------------------------------
+ */
+
+ /**
+ * 0205 Connection Links defines the relationship between the connection and an Asset, plus the nesting
+ * of connections for information virtualization support.
+ */
+ void add0205ConnectionLinkage()
+ {
+ this.archiveBuilder.addEntityDef(getVirtualConnectionEntity());
+
+ this.archiveBuilder.addRelationshipDef(getEmbeddedConnectionRelationship());
+ this.archiveBuilder.addRelationshipDef(getConnectionsToAssetRelationship());
+ }
+
+ private EntityDef getVirtualConnectionEntity()
+ {
+ final String guid = "82f9c664-e59d-484c-a8f3-17088c23a2f3";
+
+ // TODO
+ return null;
+ }
+
+ private RelationshipDef getEmbeddedConnectionRelationship()
+ {
+ final String guid = "eb6dfdd2-8c6f-4f0d-a17d-f6ce4799f64f";
+
+ // TODO
+ return null;
+ }
+
+ private RelationshipDef getConnectionsToAssetRelationship()
+ {
+ final String guid = "e777d660-8dbe-453e-8b83-903771f054c0";
+
+ // TODO
+ return null;
+ }
+
+ /*
+ * -------------------------------------------------------------------------------------------------------
+ *
<TRUNCATED>
[23/30] atlas git commit: ATLAS-2246: OMRS Connector API plus REST
and IGC Connector skeleton - 15th February 2018
Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/enterprise/repositoryconnector/EnterpriseOMRSMetadataCollection.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/enterprise/repositoryconnector/EnterpriseOMRSMetadataCollection.java b/omrs/src/main/java/org/apache/atlas/omrs/enterprise/repositoryconnector/EnterpriseOMRSMetadataCollection.java
new file mode 100644
index 0000000..12a6ea5
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/enterprise/repositoryconnector/EnterpriseOMRSMetadataCollection.java
@@ -0,0 +1,3995 @@
+/*
+ * 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.enterprise.repositoryconnector;
+
+import org.apache.atlas.omrs.ffdc.OMRSErrorCode;
+import org.apache.atlas.omrs.ffdc.exception.*;
+import org.apache.atlas.omrs.localrepository.repositorycontentmanager.OMRSRepositoryValidator;
+import org.apache.atlas.omrs.metadatacollection.OMRSMetadataCollection;
+import org.apache.atlas.omrs.metadatacollection.properties.MatchCriteria;
+import org.apache.atlas.omrs.metadatacollection.properties.SequencingOrder;
+import org.apache.atlas.omrs.metadatacollection.properties.instances.*;
+import org.apache.atlas.omrs.metadatacollection.properties.typedefs.*;
+
+import java.util.ArrayList;
+import java.util.Date;
+
+
+/**
+ * EnterpriseOMRSMetadataCollection executes the calls to the open metadata repositories registered
+ * with the OMRSEnterpriseConnectorManager. The effect is a federated view over these open metadata
+ * repositories.
+ * <p>
+ * EnterpriseOMRSMetadataCollection is part of an EnterpriseOMRSRepositoryConnector. The EnterpriseOMRSRepositoryConnector
+ * holds the list of OMRS Connectors, one for each of the metadata repositories. This list may change
+ * over time as metadata repositories register and deregister with the connected cohorts.
+ * The EnterpriseOMRSRepositoryConnector is responsible for keeping the list of connectors up-to-date through
+ * contact with the OMRSEnterpriseConnectorManager.
+ * </p>
+ * <p>
+ * When a request is made to the EnterpriseOMRSMetadataCollection, it calls the EnterpriseOMRSRepositoryConnector
+ * to request the appropriate list of metadata collection for the request. Then the EnterpriseOMRSConnector
+ * calls the appropriate remote connectors.
+ * </p>
+ * <p>
+ * The first OMRS Connector in the list is the OMRS Repository Connector for the "local" repository.
+ * The local repository is favoured when new metadata is to be created, unless the type of metadata
+ * is not supported by the local repository. In which case, the EnterpriseOMRSMetadataCollection searches its
+ * list looking for the first metadata repository that supports the metadata type and stores it there.
+ * </p>
+ * <p>
+ * Updates and deletes are routed to the owning (home) repository. Searches are made to each repository in turn
+ * and the duplicates are removed. Queries are directed to the local repository and then the remote repositories
+ * until all of the requested metadata is assembled.
+ * </p>
+ */
+public class EnterpriseOMRSMetadataCollection extends OMRSMetadataCollection
+{
+
+ /*
+ * Private variables for a metadata collection instance
+ */
+ private EnterpriseOMRSRepositoryConnector parentConnector;
+ private String enterpriseMetadataCollectionId;
+ private String enterpriseMetadataCollectionName;
+
+
+ private final OMRSRepositoryValidator repositoryValidator = new OMRSRepositoryValidator();
+
+
+ /**
+ * Default constructor.
+ *
+ * @param parentConnector - connector that this metadata collection supports. The connector has the information
+ * to call the metadata repository.
+ * @param enterpriseMetadataCollectionId - unique identifier for the metadata collection.
+ * @param enterpriseMetadataCollectionName - name of the metadata collection - used for messages.
+ */
+ public EnterpriseOMRSMetadataCollection(EnterpriseOMRSRepositoryConnector parentConnector,
+ String enterpriseMetadataCollectionId,
+ String enterpriseMetadataCollectionName)
+ {
+ /*
+ * The metadata collection Id is the unique Id for the metadata collection. It is managed by the super class.
+ */
+ super(enterpriseMetadataCollectionId);
+ this.enterpriseMetadataCollectionId = enterpriseMetadataCollectionId;
+ this.enterpriseMetadataCollectionName = enterpriseMetadataCollectionName;
+
+ /*
+ * Save parentConnector since this has the connection information and access to the metadata about the
+ * metadata cohort.
+ */
+ this.parentConnector = parentConnector;
+ }
+
+
+ /* ==============================
+ * Group 2: Working with typedefs
+ */
+
+ /**
+ * Returns the list of different types of metadata organized into two groups. The first are the
+ * attribute type definitions (AttributeTypeDefs). These provide types for properties in full
+ * type definitions. Full type definitions (TypeDefs) describe types for entities, relationships
+ * and classifications.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @return TypeDefs - List of different categories of TypeDefs.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public TypeDefGallery getAllTypes(String userId) throws RepositoryErrorException,
+ UserNotAuthorizedException
+ {
+ final String methodName = "getTypeDefs()";
+
+ /*
+ * The list of metadata collections are retrieved for each request to ensure that any changes in
+ * the shape of the cohort are reflected immediately.
+ */
+ ArrayList<OMRSMetadataCollection> metadataCollections = parentConnector.getMetadataCollections();
+
+ if (metadataCollections == null)
+ {
+ /*
+ * No repositories available
+ */
+ OMRSErrorCode errorCode = OMRSErrorCode.NO_REPOSITORIES;
+ String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage();
+
+ throw new RepositoryErrorException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ methodName,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+
+ /*
+ * Ready to process the request. Search results need to come from all members of the cohort.
+ * They need to be combined and then duplicates removed to create the final list of results.
+ * Some repositories may produce exceptions. These exceptions are saved and may be returned if
+ * there are no results from any repository.
+ */
+ ArrayList<TypeDef> combinedTypeDefResults = new ArrayList<>();
+ ArrayList<AttributeTypeDef> combinedAttributeTypeDefResults = new ArrayList<>();
+ UserNotAuthorizedException userNotAuthorizedException = null;
+ RepositoryErrorException repositoryErrorException = null;
+ RuntimeException anotherException = null;
+
+ /*
+ * Loop through the metadata collections extracting the typedefs from each repository.
+ */
+ for (OMRSMetadataCollection metadataCollection : metadataCollections)
+ {
+ if (metadataCollection == null)
+ {
+ /*
+ * A problem in the set up of the metadata collection list. Repository connectors implemented
+ * with no metadata collection are tested for in the OMRSEnterpriseConnectorManager so something
+ * else has gone wrong.
+ */
+ OMRSErrorCode errorCode = OMRSErrorCode.NULL_ENTERPRISE_METADATA_COLLECTION;
+ String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage();
+
+ throw new RepositoryErrorException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ methodName,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+
+ /*
+ * Process the retrieved metadata collection
+ */
+ try
+ {
+ TypeDefGallery results = metadataCollection.getAllTypes(userId);
+
+ /*
+ * Step through the list of returned TypeDefs and consolidate.
+ */
+ if (results != null)
+ {
+ ArrayList<TypeDef> typeDefResults = results.getTypeDefs();
+ ArrayList<AttributeTypeDef> attributeResults = results.getAttributeTypeDefs();
+
+ if (typeDefResults != null)
+ {
+ combinedTypeDefResults.addAll(typeDefResults);
+ }
+
+ if (attributeResults != null)
+ {
+ combinedAttributeTypeDefResults.addAll(attributeResults);
+ }
+ }
+ }
+ catch (RepositoryErrorException error)
+ {
+ repositoryErrorException = error;
+ }
+ catch (UserNotAuthorizedException error)
+ {
+ userNotAuthorizedException = error;
+ }
+ catch (RuntimeException error)
+ {
+ anotherException = error;
+ }
+ }
+
+ int resultCount = (combinedTypeDefResults.size() + combinedAttributeTypeDefResults.size());
+
+ /*
+ * Return any results, or exception if nothing is found.
+ */
+ if (resultCount > 0)
+ {
+ TypeDefGallery combinedResults = new TypeDefGallery();
+
+ combinedResults.setAttributeTypeDefs(combinedAttributeTypeDefResults);
+ combinedResults.setTypeDefs(combinedTypeDefResults);
+
+ if (repositoryValidator.validateEnterpriseTypeDefs(enterpriseMetadataCollectionName,
+ combinedTypeDefResults))
+ {
+ return combinedResults;
+ }
+ else
+ {
+ OMRSErrorCode errorCode = OMRSErrorCode.CONFLICTING_ENTERPRISE_TYPEDEFS;
+ String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage();
+
+ throw new RepositoryErrorException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ methodName,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+ }
+ else
+ {
+ /*
+ * A system with no defined TypeDefs is unbelievable. Certainly not very useful :)
+ * This probably means that exceptions were thrown. Re-throw any cached exceptions
+ * or, if no exceptions occurred then throw repository error because something is wrong.
+ */
+ if (userNotAuthorizedException != null)
+ {
+ throw userNotAuthorizedException;
+ }
+ else if (repositoryErrorException != null)
+ {
+ throw repositoryErrorException;
+ }
+ else if (anotherException != null)
+ {
+ throw anotherException;
+ }
+ else
+ {
+ OMRSErrorCode errorCode = OMRSErrorCode.NO_TYPEDEFS_DEFINED;
+ String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage();
+
+ throw new RepositoryErrorException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ methodName,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+ }
+ }
+
+
+ /**
+ * Returns a list of type definitions that have the specified name. Type names should be unique. This
+ * method allows wildcard character to be included in the name. These are * (asterisk) for an
+ * arbitrary string of characters and ampersand for an arbitrary character.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param name - name of the TypeDefs to return (including wildcard characters).
+ * @return TypeDefs list.
+ * @throws InvalidParameterException - the name of the TypeDef is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public TypeDefGallery findTypesByName(String userId,
+ String name) throws InvalidParameterException,
+ RepositoryErrorException,
+ UserNotAuthorizedException
+ {
+ final String methodName = "findTypeDefsByName()";
+
+ /*
+ * Validate that there is a name supplied.
+ */
+ if (name == null)
+ {
+ /*
+ * No Name supplied so can not perform the search
+ */
+ OMRSErrorCode errorCode = OMRSErrorCode.NO_TYPEDEF_NAME;
+ String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage();
+
+ throw new InvalidParameterException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ methodName,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+
+ /*
+ * The list of metadata collections are retrieved for each request to ensure that any changes in
+ * the shape of the cohort are reflected immediately.
+ */
+ ArrayList<OMRSMetadataCollection> metadataCollections = parentConnector.getMetadataCollections();
+
+ if (metadataCollections == null)
+ {
+ /*
+ * No repositories available
+ */
+ OMRSErrorCode errorCode = OMRSErrorCode.NO_REPOSITORIES;
+ String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage();
+
+ throw new RepositoryErrorException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ methodName,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+
+ /*
+ * Ready to process the request. Search results need to come from all members of the cohort.
+ * They need to be combined and then duplicates removed to create the final list of results.
+ * Some repositories may produce exceptions. These exceptions are saved and may be returned if
+ * there are no results from any repository.
+ */
+ ArrayList<TypeDef> combinedTypeDefResults = new ArrayList<>();
+ ArrayList<AttributeTypeDef> combinedAttributeTypeDefResults = new ArrayList<>();
+ InvalidParameterException invalidParameterException = null;
+ UserNotAuthorizedException userNotAuthorizedException = null;
+ RepositoryErrorException repositoryErrorException = null;
+ RuntimeException anotherException = null;
+
+ /*
+ * Loop through the metadata collections extracting the typedefs from each repository.
+ */
+ for (OMRSMetadataCollection metadataCollection : metadataCollections)
+ {
+ if (metadataCollection == null)
+ {
+ /*
+ * A problem in the set up of the metadata collection list. Repository connectors implemented
+ * with no metadata collection are tested for in the OMRSEnterpriseConnectorManager so something
+ * else has gone wrong.
+ */
+ OMRSErrorCode errorCode = OMRSErrorCode.NULL_ENTERPRISE_METADATA_COLLECTION;
+ String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage();
+
+ throw new RepositoryErrorException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ methodName,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+
+ /*
+ * Process the retrieved metadata collection
+ */
+ try
+ {
+ TypeDefGallery results = metadataCollection.findTypesByName(userId, name);
+ String metadataCollectionId = metadataCollection.getMetadataCollectionId();
+
+ /*
+ * Combine the results from the metadata collection with those elements previously retrieved.
+ */
+ if (results != null)
+ {
+ ArrayList<TypeDef> typeDefResults = results.getTypeDefs();
+ ArrayList<AttributeTypeDef> attributeResults = results.getAttributeTypeDefs();
+
+ if (typeDefResults != null)
+ {
+ combinedTypeDefResults.addAll(typeDefResults);
+ }
+
+ if (attributeResults != null)
+ {
+ combinedAttributeTypeDefResults.addAll(attributeResults);
+ }
+ }
+ }
+ catch (InvalidParameterException error)
+ {
+ invalidParameterException = error;
+ }
+ catch (RepositoryErrorException error)
+ {
+ repositoryErrorException = error;
+ }
+ catch (UserNotAuthorizedException error)
+ {
+ userNotAuthorizedException = error;
+ }
+ catch (RuntimeException error)
+ {
+ anotherException = error;
+ }
+ }
+
+ int resultCount = (combinedTypeDefResults.size() + combinedAttributeTypeDefResults.size());
+
+ /*
+ * Return any results, or exception if nothing is found.
+ */
+ if (resultCount > 0)
+ {
+ TypeDefGallery combinedResults = new TypeDefGallery();
+
+ combinedResults.setAttributeTypeDefs(combinedAttributeTypeDefResults);
+ combinedResults.setTypeDefs(combinedTypeDefResults);
+
+ if (repositoryValidator.validateEnterpriseTypeDefs(enterpriseMetadataCollectionName,
+ combinedTypeDefResults))
+ {
+ return combinedResults;
+ }
+ else
+ {
+ OMRSErrorCode errorCode = OMRSErrorCode.CONFLICTING_ENTERPRISE_TYPEDEFS;
+ String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage();
+
+ throw new RepositoryErrorException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ methodName,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+ }
+ else
+ {
+ if (userNotAuthorizedException != null)
+ {
+ throw userNotAuthorizedException;
+ }
+ else if (repositoryErrorException != null)
+ {
+ throw repositoryErrorException;
+ }
+ else if (invalidParameterException != null)
+ {
+ throw invalidParameterException;
+ }
+ else if (anotherException != null)
+ {
+ throw anotherException;
+ }
+ else
+ {
+ return null;
+ }
+ }
+ }
+
+
+ /**
+ * Returns all of the TypeDefs for a specific category.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param typeDefCategory - enum value for the category of TypeDef to return.
+ * @return TypeDefs list.
+ * @throws InvalidParameterException - the TypeDefCategory is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public ArrayList<TypeDef> findTypeDefsByCategory(String userId,
+ TypeDefCategory typeDefCategory) throws InvalidParameterException,
+ RepositoryErrorException,
+ UserNotAuthorizedException
+ {
+ final String methodName = "findTypeDefsByCategory()";
+
+ if (typeDefCategory == null)
+ {
+ /*
+ * No category supplied so can not perform the search
+ */
+ OMRSErrorCode errorCode = OMRSErrorCode.NO_TYPEDEF_CATEGORY;
+ String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage();
+
+ throw new InvalidParameterException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ methodName,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+
+ /*
+ * The list of metadata collections are retrieved for each request to ensure that any changes in
+ * the shape of the cohort are reflected immediately.
+ */
+ ArrayList<OMRSMetadataCollection> metadataCollections = parentConnector.getMetadataCollections();
+
+ if (metadataCollections == null)
+ {
+ /*
+ * No repositories available
+ */
+ OMRSErrorCode errorCode = OMRSErrorCode.NO_REPOSITORIES;
+ String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage();
+
+ throw new RepositoryErrorException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ methodName,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+
+ /*
+ * Ready to process the request. Search results need to come from all members of the cohort.
+ * They need to be combined and then duplicates removed to create the final list of results.
+ * Some repositories may produce exceptions. These exceptions are saved and may be returned if
+ * there are no results from any repository.
+ */
+ ArrayList<TypeDef> combinedResults = new ArrayList<>();
+ InvalidParameterException invalidParameterException = null;
+ UserNotAuthorizedException userNotAuthorizedException = null;
+ RepositoryErrorException repositoryErrorException = null;
+ RuntimeException anotherException = null;
+
+ /*
+ * Loop through the metadata collections extracting the typedefs from each repository.
+ */
+ for (OMRSMetadataCollection metadataCollection : metadataCollections)
+ {
+ if (metadataCollection == null)
+ {
+ /*
+ * A problem in the set up of the metadata collection list. Repository connectors implemented
+ * with no metadata collection are tested for in the OMRSEnterpriseConnectorManager so something
+ * else has gone wrong.
+ */
+ OMRSErrorCode errorCode = OMRSErrorCode.NULL_ENTERPRISE_METADATA_COLLECTION;
+ String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage();
+
+ throw new RepositoryErrorException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ methodName,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+
+ /*
+ * Process the retrieved metadata collection
+ */
+ try
+ {
+ ArrayList<TypeDef> results = metadataCollection.findTypeDefsByCategory(userId, typeDefCategory);
+ String metadataCollectionId = metadataCollection.getMetadataCollectionId();
+
+ /*
+ * Step through the list of returned TypeDefs and remove duplicates.
+ */
+ if (results != null)
+ {
+ for (TypeDef returnedTypeDef : results)
+ {
+ combinedResults = this.addUniqueTypeDef(combinedResults,
+ returnedTypeDef,
+ metadataCollectionId);
+ }
+ }
+ }
+ catch (InvalidParameterException error)
+ {
+ invalidParameterException = error;
+ }
+ catch (RepositoryErrorException error)
+ {
+ repositoryErrorException = error;
+ }
+ catch (UserNotAuthorizedException error)
+ {
+ userNotAuthorizedException = error;
+ }
+ catch (RuntimeException error)
+ {
+ anotherException = error;
+ }
+ }
+
+ /*
+ * Return any results, or null if nothing is found.
+ */
+ if (combinedResults.size() > 0)
+ {
+ if (repositoryValidator.validateEnterpriseTypeDefs(enterpriseMetadataCollectionName, combinedResults))
+ {
+ return combinedResults;
+ }
+ else
+ {
+ OMRSErrorCode errorCode = OMRSErrorCode.CONFLICTING_ENTERPRISE_TYPEDEFS;
+ String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage();
+
+ throw new RepositoryErrorException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ methodName,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+ }
+ else
+ {
+ if (userNotAuthorizedException != null)
+ {
+ throw userNotAuthorizedException;
+ }
+ else if (repositoryErrorException != null)
+ {
+ throw repositoryErrorException;
+ }
+ else if (invalidParameterException != null)
+ {
+ throw invalidParameterException;
+ }
+ else if (anotherException != null)
+ {
+ throw anotherException;
+ }
+ else
+ {
+ return null;
+ }
+ }
+ }
+
+
+ /**
+ * Returns all of the AttributeTypeDefs for a specific category.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param category - enum value for the category of an AttributeTypeDef to return.
+ * @return TypeDefs list.
+ * @throws InvalidParameterException - the TypeDefCategory is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public ArrayList<AttributeTypeDef> findAttributeTypeDefsByCategory(String userId,
+ AttributeTypeDefCategory category) throws InvalidParameterException,
+ RepositoryErrorException,
+ UserNotAuthorizedException
+ {
+ return null;
+ }
+
+
+ /**
+ * Return the TypeDefs that have the properties matching the supplied match criteria.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param matchCriteria - TypeDefProperties - a list of property names and values.
+ * @return TypeDefs list.
+ * @throws InvalidParameterException - the matchCriteria is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public ArrayList<TypeDef> findTypeDefsByProperty(String userId,
+ TypeDefProperties matchCriteria) throws InvalidParameterException,
+ RepositoryErrorException,
+ UserNotAuthorizedException
+ {
+ final String methodName = "findTypeDefsByProperty()";
+
+ if (matchCriteria == null)
+ {
+ /*
+ * No match criteria supplied so can not perform the search
+ */
+ OMRSErrorCode errorCode = OMRSErrorCode.NO_MATCH_CRITERIA;
+ String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage();
+
+ throw new InvalidParameterException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ methodName,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+
+ /*
+ * The list of metadata collections are retrieved for each request to ensure that any changes in
+ * the shape of the cohort are reflected immediately.
+ */
+ ArrayList<OMRSMetadataCollection> metadataCollections = parentConnector.getMetadataCollections();
+
+ if (metadataCollections == null)
+ {
+ /*
+ * No repositories available
+ */
+ OMRSErrorCode errorCode = OMRSErrorCode.NO_REPOSITORIES;
+ String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage();
+
+ throw new RepositoryErrorException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ methodName,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+
+ /*
+ * Ready to process the request. Search results need to come from all members of the cohort.
+ * They need to be combined and then duplicates removed to create the final list of results.
+ * Some repositories may produce exceptions. These exceptions are saved and may be returned if
+ * there are no results from any repository.
+ */
+ ArrayList<TypeDef> combinedResults = new ArrayList<>();
+ InvalidParameterException invalidParameterException = null;
+ UserNotAuthorizedException userNotAuthorizedException = null;
+ RepositoryErrorException repositoryErrorException = null;
+ RuntimeException anotherException = null;
+
+ /*
+ * Loop through the metadata collections extracting the typedefs from each repository.
+ */
+ for (OMRSMetadataCollection metadataCollection : metadataCollections)
+ {
+ if (metadataCollection == null)
+ {
+ /*
+ * A problem in the set up of the metadata collection list. Repository connectors implemented
+ * with no metadata collection are tested for in the OMRSEnterpriseConnectorManager so something
+ * else has gone wrong.
+ */
+ OMRSErrorCode errorCode = OMRSErrorCode.NULL_ENTERPRISE_METADATA_COLLECTION;
+ String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage();
+
+ throw new RepositoryErrorException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ methodName,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+
+ /*
+ * Process the retrieved metadata collection
+ */
+ try
+ {
+ ArrayList<TypeDef> results = metadataCollection.findTypeDefsByProperty(userId, matchCriteria);
+ String metadataCollectionId = metadataCollection.getMetadataCollectionId();
+
+ /*
+ * Step through the list of returned TypeDefs and remove duplicates.
+ */
+ if (results != null)
+ {
+ for (TypeDef returnedTypeDef : results)
+ {
+ combinedResults = this.addUniqueTypeDef(combinedResults,
+ returnedTypeDef,
+ metadataCollectionId);
+ }
+ }
+ }
+ catch (InvalidParameterException error)
+ {
+ invalidParameterException = error;
+ }
+ catch (RepositoryErrorException error)
+ {
+ repositoryErrorException = error;
+ }
+ catch (UserNotAuthorizedException error)
+ {
+ userNotAuthorizedException = error;
+ }
+ catch (RuntimeException error)
+ {
+ anotherException = error;
+ }
+ }
+
+ /*
+ * Return any results, or null if nothing is found.
+ */
+ if (combinedResults.size() > 0)
+ {
+ if (repositoryValidator.validateEnterpriseTypeDefs(enterpriseMetadataCollectionName, combinedResults))
+ {
+ return combinedResults;
+ }
+ else
+ {
+ OMRSErrorCode errorCode = OMRSErrorCode.CONFLICTING_ENTERPRISE_TYPEDEFS;
+ String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage();
+
+ throw new RepositoryErrorException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ methodName,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+ }
+ else
+ {
+ if (userNotAuthorizedException != null)
+ {
+ throw userNotAuthorizedException;
+ }
+ else if (repositoryErrorException != null)
+ {
+ throw repositoryErrorException;
+ }
+ else if (invalidParameterException != null)
+ {
+ throw invalidParameterException;
+ }
+ else if (anotherException != null)
+ {
+ throw anotherException;
+ }
+ else
+ {
+ return null;
+ }
+ }
+ }
+
+
+ /**
+ * Return the types that are linked to the elements from the specified standard.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param standard - name of the standard - null means any.
+ * @param organization - name of the organization - null means any.
+ * @param identifier - identifier of the element in the standard - null means any.
+ * @return TypeDefs list - each entry in the list contains a typedef. This is is a structure
+ * describing the TypeDef's category and properties.
+ * @throws InvalidParameterException - all attributes of the external Id are null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public TypeDefGallery findTypesByExternalID(String userId,
+ String standard,
+ String organization,
+ String identifier) throws InvalidParameterException,
+ RepositoryErrorException,
+ UserNotAuthorizedException
+ {
+ final String methodName = "findTypeDefsByExternalID()";
+
+ if ((standard == null) && (organization == null) && (identifier == null))
+ {
+ /*
+ * No external Id properties supplied so can not perform the search
+ */
+ OMRSErrorCode errorCode = OMRSErrorCode.NO_EXTERNAL_ID;
+ String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage();
+
+ throw new InvalidParameterException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ methodName,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+
+ /*
+ * The list of metadata collections are retrieved for each request to ensure that any changes in
+ * the shape of the cohort are reflected immediately.
+ */
+ ArrayList<OMRSMetadataCollection> metadataCollections = parentConnector.getMetadataCollections();
+
+ if (metadataCollections == null)
+ {
+ /*
+ * No repositories available
+ */
+ OMRSErrorCode errorCode = OMRSErrorCode.NO_REPOSITORIES;
+ String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage();
+
+ throw new RepositoryErrorException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ methodName,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+
+ /*
+ * Ready to process the request. Search results need to come from all members of the cohort.
+ * They need to be combined and then duplicates removed to create the final list of results.
+ * Some repositories may produce exceptions. These exceptions are saved and may be returned if
+ * there are no results from any repository.
+ */
+ ArrayList<TypeDef> combinedTypeDefResults = new ArrayList<>();
+ ArrayList<AttributeTypeDef> combinedAttributeTypeDefResults = new ArrayList<>();
+ InvalidParameterException invalidParameterException = null;
+ UserNotAuthorizedException userNotAuthorizedException = null;
+ RepositoryErrorException repositoryErrorException = null;
+ RuntimeException anotherException = null;
+
+ /*
+ * Loop through the metadata collections extracting the typedefs from each repository.
+ */
+ for (OMRSMetadataCollection metadataCollection : metadataCollections)
+ {
+ if (metadataCollection == null)
+ {
+ /*
+ * A problem in the set up of the metadata collection list. Repository connectors implemented
+ * with no metadata collection are tested for in the OMRSEnterpriseConnectorManager so something
+ * else has gone wrong.
+ */
+ OMRSErrorCode errorCode = OMRSErrorCode.NULL_ENTERPRISE_METADATA_COLLECTION;
+ String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage();
+
+ throw new RepositoryErrorException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ methodName,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+
+ /*
+ * Process the retrieved metadata collection
+ */
+ try
+ {
+ TypeDefGallery results = metadataCollection.findTypesByExternalID(userId,
+ standard,
+ organization,
+ identifier);
+ String metadataCollectionId = metadataCollection.getMetadataCollectionId();
+
+ /*
+ * Combine the results from the metadata collection with those elements previously retrieved.
+ */
+ if (results != null)
+ {
+ ArrayList<TypeDef> typeDefResults = results.getTypeDefs();
+ ArrayList<AttributeTypeDef> attributeResults = results.getAttributeTypeDefs();
+
+ if (typeDefResults != null)
+ {
+ combinedTypeDefResults.addAll(typeDefResults);
+ }
+
+ if (attributeResults != null)
+ {
+ combinedAttributeTypeDefResults.addAll(attributeResults);
+ }
+ }
+ }
+ catch (InvalidParameterException error)
+ {
+ invalidParameterException = error;
+ }
+ catch (RepositoryErrorException error)
+ {
+ repositoryErrorException = error;
+ }
+ catch (UserNotAuthorizedException error)
+ {
+ userNotAuthorizedException = error;
+ }
+ catch (RuntimeException error)
+ {
+ anotherException = error;
+ }
+ }
+
+ int resultCount = (combinedTypeDefResults.size() + combinedAttributeTypeDefResults.size());
+
+ /*
+ * Return any results, or exception if nothing is found.
+ */
+ if (resultCount > 0)
+ {
+ TypeDefGallery combinedResults = new TypeDefGallery();
+
+ combinedResults.setAttributeTypeDefs(combinedAttributeTypeDefResults);
+ combinedResults.setTypeDefs(combinedTypeDefResults);
+
+ if (repositoryValidator.validateEnterpriseTypeDefs(enterpriseMetadataCollectionName,
+ combinedTypeDefResults))
+ {
+ return combinedResults;
+ }
+ else
+ {
+ OMRSErrorCode errorCode = OMRSErrorCode.CONFLICTING_ENTERPRISE_TYPEDEFS;
+ String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage();
+
+ throw new RepositoryErrorException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ methodName,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+ }
+ else
+ {
+ if (userNotAuthorizedException != null)
+ {
+ throw userNotAuthorizedException;
+ }
+ else if (repositoryErrorException != null)
+ {
+ throw repositoryErrorException;
+ }
+ else if (invalidParameterException != null)
+ {
+ throw invalidParameterException;
+ }
+ else if (anotherException != null)
+ {
+ throw anotherException;
+ }
+ else
+ {
+ return null;
+ }
+ }
+ }
+
+
+ /**
+ * Return the TypeDefs that match the search criteria.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param searchCriteria - String - search criteria.
+ * @return TypeDefs list - each entry in the list contains a typedef. This is is a structure
+ * describing the TypeDef's category and properties.
+ * @throws InvalidParameterException - the searchCriteria is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public ArrayList<TypeDef> searchForTypeDefs(String userId,
+ String searchCriteria) throws InvalidParameterException,
+ RepositoryErrorException,
+ UserNotAuthorizedException
+ {
+ final String methodName = "searchForTypeDefs()";
+
+ if (searchCriteria == null)
+ {
+ /*
+ * No search criteria supplied so can not perform the search
+ */
+ OMRSErrorCode errorCode = OMRSErrorCode.NO_SEARCH_CRITERIA;
+ String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage();
+
+ throw new InvalidParameterException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ methodName,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+
+ /*
+ * The list of metadata collections are retrieved for each request to ensure that any changes in
+ * the shape of the cohort are reflected immediately.
+ */
+ ArrayList<OMRSMetadataCollection> metadataCollections = parentConnector.getMetadataCollections();
+
+ if (metadataCollections == null)
+ {
+ /*
+ * No repositories available
+ */
+ OMRSErrorCode errorCode = OMRSErrorCode.NO_REPOSITORIES;
+ String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage();
+
+ throw new RepositoryErrorException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ methodName,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+
+ /*
+ * Ready to process the request. Search results need to come from all members of the cohort.
+ * They need to be combined and then duplicates removed to create the final list of results.
+ * Some repositories may produce exceptions. These exceptions are saved and may be returned if
+ * there are no results from any repository.
+ */
+ ArrayList<TypeDef> combinedResults = new ArrayList<>();
+ InvalidParameterException invalidParameterException = null;
+ UserNotAuthorizedException userNotAuthorizedException = null;
+ RepositoryErrorException repositoryErrorException = null;
+ RuntimeException anotherException = null;
+
+ /*
+ * Loop through the metadata collections extracting the typedefs from each repository.
+ */
+ for (OMRSMetadataCollection metadataCollection : metadataCollections)
+ {
+ if (metadataCollection == null)
+ {
+ /*
+ * A problem in the set up of the metadata collection list. Repository connectors implemented
+ * with no metadata collection are tested for in the OMRSEnterpriseConnectorManager so something
+ * else has gone wrong.
+ */
+ OMRSErrorCode errorCode = OMRSErrorCode.NULL_ENTERPRISE_METADATA_COLLECTION;
+ String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage();
+
+ throw new RepositoryErrorException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ methodName,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+
+ /*
+ * Process the retrieved metadata collection
+ */
+ try
+ {
+ ArrayList<TypeDef> results = metadataCollection.searchForTypeDefs(userId, searchCriteria);
+ String metadataCollectionId = metadataCollection.getMetadataCollectionId();
+
+ /*
+ * Step through the list of returned TypeDefs and remove duplicates.
+ */
+ if (results != null)
+ {
+ for (TypeDef returnedTypeDef : results)
+ {
+ combinedResults = this.addUniqueTypeDef(combinedResults,
+ returnedTypeDef,
+ metadataCollectionId);
+ }
+ }
+ }
+ catch (InvalidParameterException error)
+ {
+ invalidParameterException = error;
+ }
+ catch (RepositoryErrorException error)
+ {
+ repositoryErrorException = error;
+ }
+ catch (UserNotAuthorizedException error)
+ {
+ userNotAuthorizedException = error;
+ }
+ catch (RuntimeException error)
+ {
+ anotherException = error;
+ }
+ }
+
+ /*
+ * Return any results, or null if nothing is found.
+ */
+ if (combinedResults.size() > 0)
+ {
+ if (repositoryValidator.validateEnterpriseTypeDefs(enterpriseMetadataCollectionName, combinedResults))
+ {
+ return combinedResults;
+ }
+ else
+ {
+ OMRSErrorCode errorCode = OMRSErrorCode.CONFLICTING_ENTERPRISE_TYPEDEFS;
+ String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage();
+
+ throw new RepositoryErrorException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ methodName,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+ }
+ else
+ {
+ if (userNotAuthorizedException != null)
+ {
+ throw userNotAuthorizedException;
+ }
+ else if (repositoryErrorException != null)
+ {
+ throw repositoryErrorException;
+ }
+ else if (invalidParameterException != null)
+ {
+ throw invalidParameterException;
+ }
+ else if (anotherException != null)
+ {
+ throw anotherException;
+ }
+ else
+ {
+ return null;
+ }
+ }
+ }
+
+
+ /**
+ * Return the TypeDef identified by the GUID.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param guid - String unique Id of the TypeDef
+ * @return TypeDef structure describing its category and properties.
+ * @throws InvalidParameterException - the guid is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws TypeDefNotKnownException - The requested TypeDef is not known in the metadata collection.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public TypeDef getTypeDefByGUID(String userId,
+ String guid) throws InvalidParameterException,
+ RepositoryErrorException,
+ TypeDefNotKnownException,
+ UserNotAuthorizedException
+ {
+ final String methodName = "getTypeDefByGUID()";
+
+ if (guid == null)
+ {
+ /*
+ * No guid supplied so can not perform the search
+ */
+ OMRSErrorCode errorCode = OMRSErrorCode.NO_GUID;
+ String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage();
+
+ throw new InvalidParameterException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ methodName,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+
+ ArrayList<OMRSMetadataCollection> metadataCollections = parentConnector.getMetadataCollections();
+
+ if (metadataCollections == null)
+ {
+ /*
+ * No repositories available
+ */
+ OMRSErrorCode errorCode = OMRSErrorCode.NO_REPOSITORIES;
+ String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage();
+
+ throw new RepositoryErrorException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ methodName,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+
+ TypeDefNotKnownException typeDefNotKnownException = null;
+ UserNotAuthorizedException userNotAuthorizedException = null;
+ RepositoryErrorException repositoryErrorException = null;
+ RuntimeException anotherException = null;
+
+ /*
+ * Loop through the metadata collections requesting the typedef from each repository.
+ * The first TypeDef retrieved is returned to the caller.
+ */
+ for (OMRSMetadataCollection metadataCollection : metadataCollections)
+ {
+ if (metadataCollection != null)
+ {
+ try
+ {
+ TypeDef retrievedTypeDef = getTypeDefByGUID(userId, guid);
+
+ if (retrievedTypeDef != null)
+ {
+ return retrievedTypeDef;
+ }
+ }
+ catch (TypeDefNotKnownException error)
+ {
+ typeDefNotKnownException = error;
+ }
+ catch (UserNotAuthorizedException error)
+ {
+ userNotAuthorizedException = error;
+ }
+ catch (RepositoryErrorException error)
+ {
+ repositoryErrorException = error;
+ }
+ catch (RuntimeException error)
+ {
+ anotherException = error;
+ }
+ }
+ }
+
+ /*
+ * The TypeDef has not been found. Process the exceptions.
+ */
+ if (typeDefNotKnownException != null)
+ {
+ throw typeDefNotKnownException;
+ }
+ else if (userNotAuthorizedException != null)
+ {
+ throw userNotAuthorizedException;
+ }
+ else if (repositoryErrorException != null)
+ {
+ throw repositoryErrorException;
+ }
+ else if (anotherException != null)
+ {
+ throw anotherException;
+ }
+ else
+ {
+ /*
+ * All of the repositories have returned a null TypeDef so default to TypeDefNotKnownException.
+ */
+ OMRSErrorCode errorCode = OMRSErrorCode.TYPEDEF_NOT_KNOWN;
+ String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage();
+
+ throw new TypeDefNotKnownException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ methodName,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+
+ }
+
+
+ /**
+ * Return the AttributeTypeDef identified by the GUID.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param guid - String unique id of the TypeDef
+ * @return TypeDef structure describing its category and properties.
+ * @throws InvalidParameterException - the guid is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws TypeDefNotKnownException - The requested TypeDef is not known in the metadata collection.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public AttributeTypeDef getAttributeTypeDefByGUID(String userId,
+ String guid) throws InvalidParameterException,
+ RepositoryErrorException,
+ TypeDefNotKnownException,
+ UserNotAuthorizedException
+ {
+ return null;
+ }
+
+
+ /**
+ * Return the TypeDef identified by the unique name.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param name - String name of the TypeDef.
+ * @return TypeDef structure describing its category and properties.
+ * @throws InvalidParameterException - the name is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws TypeDefNotKnownException - the requested TypeDef is not found in the metadata collection.
+ */
+ public TypeDef getTypeDefByName(String userId,
+ String name) throws InvalidParameterException,
+ RepositoryErrorException,
+ TypeDefNotKnownException,
+ UserNotAuthorizedException
+ {
+ final String methodName = "getTypeDefByName()";
+
+ if (name == null)
+ {
+ /*
+ * No name supplied so can not perform the search
+ */
+ OMRSErrorCode errorCode = OMRSErrorCode.NO_TYPEDEF_NAME;
+ String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage();
+
+ throw new InvalidParameterException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ methodName,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+
+ ArrayList<OMRSMetadataCollection> metadataCollections = parentConnector.getMetadataCollections();
+
+ if (metadataCollections == null)
+ {
+ /*
+ * No repositories available
+ */
+ OMRSErrorCode errorCode = OMRSErrorCode.NO_REPOSITORIES;
+ String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage();
+
+ throw new RepositoryErrorException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ methodName,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+
+ TypeDefNotKnownException typeDefNotKnownException = null;
+ UserNotAuthorizedException userNotAuthorizedException = null;
+ RepositoryErrorException repositoryErrorException = null;
+ RuntimeException anotherException = null;
+
+ /*
+ * Loop through the metadata collections requesting the typedef from each repository.
+ * The first TypeDef retrieved is returned to the caller.
+ */
+ for (OMRSMetadataCollection metadataCollection : metadataCollections)
+ {
+ if (metadataCollection != null)
+ {
+ try
+ {
+ TypeDef retrievedTypeDef = getTypeDefByName(userId, name);
+
+ if (retrievedTypeDef != null)
+ {
+ return retrievedTypeDef;
+ }
+ }
+ catch (TypeDefNotKnownException error)
+ {
+ typeDefNotKnownException = error;
+ }
+ catch (UserNotAuthorizedException error)
+ {
+ userNotAuthorizedException = error;
+ }
+ catch (RepositoryErrorException error)
+ {
+ repositoryErrorException = error;
+ }
+ catch (RuntimeException error)
+ {
+ anotherException = error;
+ }
+ }
+ }
+
+ /*
+ * The TypeDef has not been found. Process the exceptions.
+ */
+ if (typeDefNotKnownException != null)
+ {
+ throw typeDefNotKnownException;
+ }
+ else if (userNotAuthorizedException != null)
+ {
+ throw userNotAuthorizedException;
+ }
+ else if (repositoryErrorException != null)
+ {
+ throw repositoryErrorException;
+ }
+ else if (anotherException != null)
+ {
+ throw anotherException;
+ }
+ else
+ {
+ /*
+ * All of the repositories have returned a null TypeDef so default to TypeDefNotKnownException.
+ */
+ OMRSErrorCode errorCode = OMRSErrorCode.TYPEDEF_NOT_KNOWN;
+ String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage();
+
+ throw new TypeDefNotKnownException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ methodName,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+ }
+
+
+ /**
+ * Return the AttributeTypeDef identified by the unique name.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param name - String name of the TypeDef.
+ * @return TypeDef structure describing its category and properties.
+ * @throws InvalidParameterException - the name is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws TypeDefNotKnownException - the requested TypeDef is not found in the metadata collection.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public AttributeTypeDef getAttributeTypeDefByName(String userId,
+ String name) throws InvalidParameterException,
+ RepositoryErrorException,
+ TypeDefNotKnownException,
+ UserNotAuthorizedException
+ {
+ return null;
+ }
+
+
+ /**
+ * Create a collection of related types.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param newTypes - TypeDefGallery structure describing the new AttributeTypeDefs and TypeDefs.
+ * @throws InvalidParameterException - the new TypeDef is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws TypeDefNotSupportedException - the repository is not able to support this TypeDef.
+ * @throws TypeDefKnownException - the TypeDef is already stored in the repository.
+ * @throws TypeDefConflictException - the new TypeDef conflicts with an existing TypeDef.
+ * @throws InvalidTypeDefException - the new TypeDef has invalid contents.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public void addTypeDefGallery(String userId,
+ TypeDefGallery newTypes) throws InvalidParameterException,
+ RepositoryErrorException,
+ TypeDefNotSupportedException,
+ TypeDefKnownException,
+ TypeDefConflictException,
+ InvalidTypeDefException,
+ UserNotAuthorizedException
+ {
+
+ }
+
+
+ /**
+ * Create a definition of a new TypeDef. This new TypeDef is pushed to each repository that will accept it.
+ * An exception is passed to the caller if the TypeDef is invalid, or if none of the repositories accept it.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param newTypeDef - TypeDef structure describing the new TypeDef.
+ * @throws InvalidParameterException - the new TypeDef is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws TypeDefNotSupportedException - the repository is not able to support this TypeDef.
+ * @throws TypeDefKnownException - the TypeDef is already stored in the repository.
+ * @throws TypeDefConflictException - the new TypeDef conflicts with an existing TypeDef.
+ * @throws InvalidTypeDefException - the new TypeDef has invalid contents.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public void addTypeDef(String userId,
+ TypeDef newTypeDef) throws InvalidParameterException,
+ RepositoryErrorException,
+ TypeDefNotSupportedException,
+ TypeDefKnownException,
+ TypeDefConflictException,
+ InvalidTypeDefException,
+ UserNotAuthorizedException
+ {
+ final String methodName = "addTypeDef()";
+
+ OMRSErrorCode errorCode = OMRSErrorCode.ENTERPRISE_NOT_SUPPORTED;
+
+ String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage(methodName);
+
+ throw new RepositoryErrorException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ methodName,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+
+ /**
+ * Create a definition of a new AttributeTypeDef.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param newAttributeTypeDef - TypeDef structure describing the new TypeDef.
+ * @throws InvalidParameterException - the new TypeDef is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws TypeDefNotSupportedException - the repository is not able to support this TypeDef.
+ * @throws TypeDefKnownException - the TypeDef is already stored in the repository.
+ * @throws TypeDefConflictException - the new TypeDef conflicts with an existing TypeDef.
+ * @throws InvalidTypeDefException - the new TypeDef has invalid contents.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public void addAttributeTypeDef(String userId,
+ AttributeTypeDef newAttributeTypeDef) throws InvalidParameterException,
+ RepositoryErrorException,
+ TypeDefNotSupportedException,
+ TypeDefKnownException,
+ TypeDefConflictException,
+ InvalidTypeDefException,
+ UserNotAuthorizedException
+ {
+ final String methodName = "addAttributeTypeDef()";
+
+ OMRSErrorCode errorCode = OMRSErrorCode.ENTERPRISE_NOT_SUPPORTED;
+
+ String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage(methodName);
+
+ throw new RepositoryErrorException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ methodName,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+
+
+ /**
+ * Verify that a definition of a TypeDef is either new - or matches the definition already stored.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param typeDef - TypeDef structure describing the TypeDef to test.
+ * @return boolean - true means the TypeDef matches the local definition - false means the TypeDef is not known.
+ * @throws InvalidParameterException - the TypeDef is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws TypeDefNotSupportedException - the repository is not able to support this TypeDef.
+ * @throws TypeDefConflictException - the new TypeDef conflicts with an existing TypeDef.
+ * @throws InvalidTypeDefException - the new TypeDef has invalid contents.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public boolean verifyTypeDef(String userId,
+ TypeDef typeDef) throws InvalidParameterException,
+ RepositoryErrorException,
+ TypeDefNotSupportedException,
+ TypeDefConflictException,
+ InvalidTypeDefException,
+ UserNotAuthorizedException
+ {
+ final String methodName = "verifyTypeDef()";
+
+ OMRSErrorCode errorCode = OMRSErrorCode.ENTERPRISE_NOT_SUPPORTED;
+
+ String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage(methodName);
+
+ throw new RepositoryErrorException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ methodName,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+
+
+ /**
+ * Verify that a definition of an AttributeTypeDef is either new - or matches the definition already stored.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param attributeTypeDef - TypeDef structure describing the TypeDef to test.
+ * @return boolean - true means the TypeDef matches the local definition - false means the TypeDef is not known.
+ * @throws InvalidParameterException - the TypeDef is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws TypeDefNotSupportedException - the repository is not able to support this TypeDef.
+ * @throws TypeDefConflictException - the new TypeDef conflicts with an existing TypeDef.
+ * @throws InvalidTypeDefException - the new TypeDef has invalid contents.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public boolean verifyAttributeTypeDef(String userId,
+ AttributeTypeDef attributeTypeDef) throws InvalidParameterException,
+ RepositoryErrorException,
+ TypeDefNotSupportedException,
+ TypeDefConflictException,
+ InvalidTypeDefException,
+ UserNotAuthorizedException
+ {
+ final String methodName = "verifyAttributeTypeDef()";
+
+ OMRSErrorCode errorCode = OMRSErrorCode.ENTERPRISE_NOT_SUPPORTED;
+
+ String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage(methodName);
+
+ throw new RepositoryErrorException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ methodName,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+
+
+ /**
+ * Update one or more properties of the TypeDef. The TypeDefPatch controls what types of updates
+ * are safe to make to the TypeDef.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param typeDefPatch - TypeDef patch describing change to TypeDef.
+ * @return updated TypeDef
+ * @throws InvalidParameterException - the TypeDefPatch is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws TypeDefNotKnownException - the requested TypeDef is not found in the metadata collection.
+ * @throws PatchErrorException - the TypeDef can not be updated because the supplied patch is incompatible
+ * with the stored TypeDef.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public TypeDef updateTypeDef(String userId,
+ TypeDefPatch typeDefPatch) throws InvalidParameterException,
+ RepositoryErrorException,
+ TypeDefNotKnownException,
+ PatchErrorException,
+ UserNotAuthorizedException
+ {
+ final String methodName = "updateTypeDef()";
+
+ OMRSErrorCode errorCode = OMRSErrorCode.ENTERPRISE_NOT_SUPPORTED;
+
+ String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage(methodName);
+
+ throw new RepositoryErrorException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ methodName,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+
+
+ /**
+ * Delete the TypeDef. This is only possible if the TypeDef has never been used to create instances or any
+ * instances of this TypeDef have been purged from the metadata collection.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param obsoleteTypeDefGUID - String unique identifier for the TypeDef.
+ * @param obsoleteTypeDefName - String unique name for the TypeDef.
+ * @throws InvalidParameterException - the one of TypeDef identifiers is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws TypeDefNotKnownException - the requested TypeDef is not found in the metadata collection.
+ * @throws TypeDefInUseException - the TypeDef can not be deleted because there are instances of this type in the
+ * the metadata collection. These instances need to be purged before the
+ * TypeDef can be deleted.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public void deleteTypeDef(String userId,
+ String obsoleteTypeDefGUID,
+ String obsoleteTypeDefName) throws InvalidParameterException,
+ RepositoryErrorException,
+ TypeDefNotKnownException,
+ TypeDefInUseException,
+ UserNotAuthorizedException
+ {
+ final String methodName = "deleteTypeDef()";
+
+ OMRSErrorCode errorCode = OMRSErrorCode.ENTERPRISE_NOT_SUPPORTED;
+
+ String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage(methodName);
+
+ throw new RepositoryErrorException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ methodName,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+
+
+ /**
+ * Delete an AttributeTypeDef. This is only possible if the AttributeTypeDef has never been used to create
+ * instances or any instances of this AttributeTypeDef have been purged from the metadata collection.
+ *
+ * @param userId - unique identifier for requesting user.
+ * @param obsoleteTypeDefGUID - String unique identifier for the AttributeTypeDef.
+ * @param obsoleteTypeDefName - String unique name for the AttributeTypeDef.
+ * @throws InvalidParameterException - the one of AttributeTypeDef identifiers is null.
+ * @throws RepositoryErrorException - there is a problem communicating with the metadata repository where
+ * the metadata collection is stored.
+ * @throws TypeDefNotKnownException - the requested AttributeTypeDef is not found in the metadata collection.
+ * @throws TypeDefInUseException - the AttributeTypeDef can not be deleted because there are instances of this type in the
+ * the metadata collection. These instances need to be purged before the
+ * AttributeTypeDef can be deleted.
+ * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation.
+ */
+ public void deleteAttributeTypeDef(String userId,
+ String obsoleteTypeDefGUID,
+ String obsoleteTypeDefName) throws InvalidParameterException,
+
<TRUNCATED>
[19/30] atlas git commit: ATLAS-2246: OMRS Connector API plus REST
and IGC Connector skeleton - 15th February 2018
Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/OMRSRepositoryEventManager.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/OMRSRepositoryEventManager.java b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/OMRSRepositoryEventManager.java
new file mode 100644
index 0000000..ff06a76
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/eventmanagement/OMRSRepositoryEventManager.java
@@ -0,0 +1,1608 @@
+/*
+ * 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.auditlog.OMRSAuditLog;
+import org.apache.atlas.omrs.auditlog.OMRSAuditingComponent;
+import org.apache.atlas.omrs.eventmanagement.events.OMRSInstanceEventProcessor;
+import org.apache.atlas.omrs.eventmanagement.events.OMRSTypeDefEventProcessor;
+import org.apache.atlas.omrs.localrepository.repositorycontentmanager.OMRSRepositoryValidator;
+import org.apache.atlas.omrs.metadatacollection.properties.instances.EntityDetail;
+import org.apache.atlas.omrs.metadatacollection.properties.instances.InstanceProvenanceType;
+import org.apache.atlas.omrs.metadatacollection.properties.instances.InstanceType;
+import org.apache.atlas.omrs.metadatacollection.properties.instances.Relationship;
+import org.apache.atlas.omrs.metadatacollection.properties.typedefs.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+
+/**
+ * OMRSRepositoryEventManager is responsible for managing the distribution of TypeDef and instance events.
+ * There is one OMRSRepositoryEventManager for each cohort that the local server is registered with and one for
+ * the local repository.
+ *
+ * Since OMRSRepositoryEventManager sits at the crossroads of the flow of events between the cohorts,
+ * the local repository and the enterprise access components, it performs detailed error checking of the
+ * event contents to help assure the integrity of the open metadata ecosystem.
+ */
+public class OMRSRepositoryEventManager implements OMRSRepositoryEventProcessor
+{
+ private ArrayList<OMRSTypeDefEventProcessor> typeDefEventConsumers = new ArrayList<>();
+ private ArrayList<OMRSInstanceEventProcessor> instanceEventConsumers = new ArrayList<>();
+ private OMRSRepositoryValidator repositoryValidator = new OMRSRepositoryValidator();
+ private OMRSRepositoryEventExchangeRule exchangeRule; /* set in constructor */
+
+ /*
+ * The audit log provides a verifiable record of the open metadata archives that have been loaded into
+ * the open metadata repository. The Logger is for standard debug.
+ */
+ private static final OMRSAuditLog auditLog = new OMRSAuditLog(OMRSAuditingComponent.REPOSITORY_EVENT_MANAGER);
+ private static final Logger log = LoggerFactory.getLogger(OMRSRepositoryEventManager.class);
+
+ /**
+ * Constructor to initialize a repository event manager
+ *
+ * @param exchangeRule - this is the rule that determines which events are processed.
+ */
+ public OMRSRepositoryEventManager(OMRSRepositoryEventExchangeRule exchangeRule)
+ {
+ /*
+ * If the exchangeRule is null, throw exception
+ */
+ if (exchangeRule == null)
+ {
+ // TODO throw exception
+ }
+
+ this.exchangeRule = exchangeRule;
+ }
+
+ /**
+ * Adds a new consumer to the list of consumers that the OMRSRepositoryEventManager will notify of
+ * any TypeDef events it receives.
+ *
+ * @param typeDefEventConsumer - the new consumer of TypeDef events from other members of the cohort
+ */
+ public void registerTypeDefProcessor(OMRSTypeDefEventProcessor typeDefEventConsumer)
+ {
+ typeDefEventConsumers.add(typeDefEventConsumer);
+ }
+
+
+ /**
+ * Adds a new consumer to the list of consumers that the OMRSRepositoryEventManager will notify of
+ * any instance events it receives.
+ *
+ * @param instanceEventConsumer - the new consumer of instance events from other members of the cohort
+ */
+ public void registerInstanceProcessor(OMRSInstanceEventProcessor instanceEventConsumer)
+ {
+ instanceEventConsumers.add(instanceEventConsumer);
+ }
+
+
+ /**
+ * A new TypeDef has been defined in a metadata repository.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param typeDef - details of the new TypeDef.
+ */
+ public void processNewTypeDefEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ TypeDef typeDef)
+ {
+ if (exchangeRule.processTypeDefEvents())
+ {
+ for (OMRSTypeDefEventProcessor consumer: typeDefEventConsumers)
+ {
+ consumer.processNewTypeDefEvent(sourceName,
+ originatorMetadataCollectionId,
+ originatorServerName,
+ originatorServerType,
+ originatorOrganizationName,
+ typeDef);
+ }
+ }
+ }
+
+
+ /**
+ * A new AttributeTypeDef has been defined in an open metadata repository.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param attributeTypeDef - details of the new AttributeTypeDef.
+ */
+ public void processNewAttributeTypeDefEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ AttributeTypeDef attributeTypeDef)
+ {
+ if (exchangeRule.processTypeDefEvents())
+ {
+ for (OMRSTypeDefEventProcessor consumer: typeDefEventConsumers)
+ {
+ consumer.processNewAttributeTypeDefEvent(sourceName,
+ originatorMetadataCollectionId,
+ originatorServerName,
+ originatorServerType,
+ originatorOrganizationName,
+ attributeTypeDef);
+ }
+ }
+ }
+
+
+ /**
+ * An existing TypeDef has been updated in a remote metadata repository.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param typeDefPatch - details of the new versionName of the TypeDef
+ */
+ public void processUpdatedTypeDefEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ TypeDefPatch typeDefPatch)
+ {
+ if (exchangeRule.processTypeDefEvents())
+ {
+ for (OMRSTypeDefEventProcessor consumer: typeDefEventConsumers)
+ {
+ consumer.processUpdatedTypeDefEvent(sourceName,
+ originatorMetadataCollectionId,
+ originatorServerName,
+ originatorServerType,
+ originatorOrganizationName,
+ typeDefPatch);
+ }
+ }
+ }
+
+
+ /**
+ * An existing TypeDef has been deleted in a remote metadata repository. Both the name and the
+ * GUID are provided to ensure the right TypeDef is deleted in other cohort member repositories.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param typeDefGUID - unique identifier of the TypeDef
+ * @param typeDefName - unique name of the TypeDef
+ */
+ public void processDeletedTypeDefEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ String typeDefGUID,
+ String typeDefName)
+ {
+ if (exchangeRule.processTypeDefEvents())
+ {
+ for (OMRSTypeDefEventProcessor consumer: typeDefEventConsumers)
+ {
+ consumer.processDeletedTypeDefEvent(sourceName,
+ originatorMetadataCollectionId,
+ originatorServerName,
+ originatorServerType,
+ originatorOrganizationName,
+ typeDefGUID,
+ typeDefName);
+ }
+ }
+ }
+
+
+ /**
+ * An existing AttributeTypeDef has been deleted in an open metadata repository. Both the name and the
+ * GUID are provided to ensure the right AttributeTypeDef is deleted in other cohort member repositories.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param attributeTypeDefGUID - unique identifier of the AttributeTypeDef
+ * @param attributeTypeDefName - unique name of the AttributeTypeDef
+ */
+ public void processDeletedAttributeTypeDefEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ String attributeTypeDefGUID,
+ String attributeTypeDefName)
+ {
+ if (exchangeRule.processTypeDefEvents())
+ {
+ for (OMRSTypeDefEventProcessor consumer: typeDefEventConsumers)
+ {
+ consumer.processDeletedAttributeTypeDefEvent(sourceName,
+ originatorMetadataCollectionId,
+ originatorServerName,
+ originatorServerType,
+ originatorOrganizationName,
+ attributeTypeDefGUID,
+ attributeTypeDefName);
+ }
+ }
+ }
+
+
+ /**
+ * Process an event that changes either the name or guid of a TypeDef. It is resolving a Conflicting TypeDef Error.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param originalTypeDefSummary - details of the original TypeDef
+ * @param typeDef - updated TypeDef with new identifiers inside.
+ */
+ public void processReIdentifiedTypeDefEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ TypeDefSummary originalTypeDefSummary,
+ TypeDef typeDef)
+ {
+ if (exchangeRule.processTypeDefEvents())
+ {
+ for (OMRSTypeDefEventProcessor consumer: typeDefEventConsumers)
+ {
+ consumer.processReIdentifiedTypeDefEvent(sourceName,
+ originatorMetadataCollectionId,
+ originatorServerName,
+ originatorServerType,
+ originatorOrganizationName,
+ originalTypeDefSummary,
+ typeDef);
+ }
+ }
+ }
+
+
+ /**
+ * Process an event that changes either the name or guid of an AttributeTypeDef.
+ * It is resolving a Conflicting AttributeTypeDef Error.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param originalAttributeTypeDef - description of original AttributeTypeDef
+ * @param attributeTypeDef - updated AttributeTypeDef with new identifiers inside.
+ */
+ public void processReIdentifiedAttributeTypeDefEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ AttributeTypeDef originalAttributeTypeDef,
+ AttributeTypeDef attributeTypeDef)
+ {
+ if (exchangeRule.processTypeDefEvents())
+ {
+ for (OMRSTypeDefEventProcessor consumer: typeDefEventConsumers)
+ {
+ consumer.processReIdentifiedAttributeTypeDefEvent(sourceName,
+ originatorMetadataCollectionId,
+ originatorServerName,
+ originatorServerType,
+ originatorOrganizationName,
+ originalAttributeTypeDef,
+ attributeTypeDef);
+ }
+ }
+ }
+
+
+ /**
+ * Process a detected conflict in type definitions (TypeDefs) used in the cohort.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param originatorTypeDefSummary - details of the TypeDef in the event originator
+ * @param otherMetadataCollectionId - the metadataCollection using the conflicting TypeDef
+ * @param conflictingTypeDefSummary - the detaild of the TypeDef in the other metadata collection
+ * @param errorMessage - description of error.
+ */
+ public void processTypeDefConflictEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ TypeDefSummary originatorTypeDefSummary,
+ String otherMetadataCollectionId,
+ TypeDefSummary conflictingTypeDefSummary,
+ String errorMessage)
+ {
+ if (exchangeRule.processTypeDefEvents())
+ {
+ for (OMRSTypeDefEventProcessor consumer: typeDefEventConsumers)
+ {
+ consumer.processTypeDefConflictEvent(sourceName,
+ originatorMetadataCollectionId,
+ originatorServerName,
+ originatorServerType,
+ originatorOrganizationName,
+ originatorTypeDefSummary,
+ otherMetadataCollectionId,
+ conflictingTypeDefSummary,
+ errorMessage);
+ }
+ }
+ }
+
+
+ /**
+ * Process a detected conflict in the attribute type definitions (AttributeTypeDefs) used in the cohort.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param originatorAttributeTypeDef- description of the AttributeTypeDef in the event originator.
+ * @param otherMetadataCollectionId - the metadataCollection using the conflicting AttributeTypeDef.
+ * @param conflictingAttributeTypeDef - description of the AttributeTypeDef in the other metadata collection.
+ * @param errorMessage - details of the error that occurs when the connection is used.
+ */
+ public void processAttributeTypeDefConflictEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ AttributeTypeDef originatorAttributeTypeDef,
+ String otherMetadataCollectionId,
+ AttributeTypeDef conflictingAttributeTypeDef,
+ String errorMessage)
+ {
+ if (exchangeRule.processTypeDefEvents())
+ {
+ for (OMRSTypeDefEventProcessor consumer: typeDefEventConsumers)
+ {
+ consumer.processAttributeTypeDefConflictEvent(sourceName,
+ originatorMetadataCollectionId,
+ originatorServerName,
+ originatorServerType,
+ originatorOrganizationName,
+ originatorAttributeTypeDef,
+ otherMetadataCollectionId,
+ conflictingAttributeTypeDef,
+ errorMessage);
+ }
+ }
+ }
+
+ /**
+ * A TypeDef from another member in the cohort is at a different versionName than the local repository. This may
+ * create some inconsistencies in the different copies of instances of this type in different members of the
+ * cohort. The recommended action is to update all TypeDefs to the latest versionName.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param targetMetadataCollectionId - identifier of the metadata collection that is reporting a TypeDef at a
+ * different level to the local repository.
+ * @param targetTypeDefSummary - details of the target TypeDef
+ * @param otherTypeDef - details of the TypeDef in the local repository.
+ * @param errorMessage - description of error.
+ */
+ public void processTypeDefPatchMismatchEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ String targetMetadataCollectionId,
+ TypeDefSummary targetTypeDefSummary,
+ TypeDef otherTypeDef,
+ String errorMessage)
+ {
+ if (exchangeRule.processTypeDefEvents())
+ {
+ for (OMRSTypeDefEventProcessor consumer: typeDefEventConsumers)
+ {
+ consumer.processTypeDefPatchMismatchEvent(sourceName,
+ originatorMetadataCollectionId,
+ originatorServerName,
+ originatorServerType,
+ originatorOrganizationName,
+ targetMetadataCollectionId,
+ targetTypeDefSummary,
+ otherTypeDef,
+ errorMessage);
+ }
+ }
+ }
+
+
+ /**
+ * A new entity has been created.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param entity - details of the new entity
+ */
+ public void processNewEntityEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ EntityDetail entity)
+ {
+ if (repositoryValidator.validEntity(sourceName, entity))
+ {
+ if (exchangeRule.processInstanceEvent(entity))
+ {
+ for (OMRSInstanceEventProcessor consumer : instanceEventConsumers)
+ {
+ consumer.processNewEntityEvent(sourceName,
+ originatorMetadataCollectionId,
+ originatorServerName,
+ originatorServerType,
+ originatorOrganizationName,
+ entity);
+ }
+ }
+ }
+ }
+
+
+ /**
+ * An existing entity has been updated.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param entity - details of the new versionName of the entity.
+ */
+ public void processUpdatedEntityEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ EntityDetail entity)
+ {
+ if (repositoryValidator.validEntity(sourceName, entity))
+ {
+ if (exchangeRule.processInstanceEvent(entity))
+ {
+ for (OMRSInstanceEventProcessor consumer : instanceEventConsumers)
+ {
+ consumer.processUpdatedEntityEvent(sourceName,
+ originatorMetadataCollectionId,
+ originatorServerName,
+ originatorServerType,
+ originatorOrganizationName,
+ entity);
+ }
+ }
+ }
+ }
+
+
+ /**
+ * An update to an entity has been undone.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param entity - details of the versionName of the entity that has been restored.
+ */
+ public void processUndoneEntityEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ EntityDetail entity)
+ {
+ if (repositoryValidator.validEntity(sourceName, entity))
+ {
+ if (exchangeRule.processInstanceEvent(entity))
+ {
+ for (OMRSInstanceEventProcessor consumer : instanceEventConsumers)
+ {
+ consumer.processUndoneEntityEvent(sourceName,
+ originatorMetadataCollectionId,
+ originatorServerName,
+ originatorServerType,
+ originatorOrganizationName,
+ entity);
+ }
+ }
+ }
+ }
+
+
+ /**
+ * A new classification has been added to an entity.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param entity - details of the entity with the new classification added.
+ */
+ public void processClassifiedEntityEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ EntityDetail entity)
+ {
+ if (repositoryValidator.validEntity(sourceName, entity))
+ {
+ if (exchangeRule.processInstanceEvent(entity))
+ {
+ for (OMRSInstanceEventProcessor consumer : instanceEventConsumers)
+ {
+ consumer.processClassifiedEntityEvent(sourceName,
+ originatorMetadataCollectionId,
+ originatorServerName,
+ originatorServerType,
+ originatorOrganizationName,
+ entity);
+ }
+ }
+ }
+ }
+
+
+ /**
+ * A classification has been removed from an entity.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param entity - details of the entity after the classification has been removed.
+ */
+ public void processDeclassifiedEntityEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ EntityDetail entity)
+ {
+ if (repositoryValidator.validEntity(sourceName, entity))
+ {
+ if (exchangeRule.processInstanceEvent(entity))
+ {
+ for (OMRSInstanceEventProcessor consumer : instanceEventConsumers)
+ {
+ consumer.processDeclassifiedEntityEvent(sourceName,
+ originatorMetadataCollectionId,
+ originatorServerName,
+ originatorServerType,
+ originatorOrganizationName,
+ entity);
+ }
+ }
+ }
+ }
+
+
+ /**
+ * An existing classification has been changed on an entity.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param entity - details of the entity after the classification has been changed.
+ */
+ public void processReclassifiedEntityEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ EntityDetail entity)
+ {
+ if (repositoryValidator.validEntity(sourceName, entity))
+ {
+ if (exchangeRule.processInstanceEvent(entity))
+ {
+ for (OMRSInstanceEventProcessor consumer : instanceEventConsumers)
+ {
+ consumer.processReclassifiedEntityEvent(sourceName,
+ originatorMetadataCollectionId,
+ originatorServerName,
+ originatorServerType,
+ originatorOrganizationName,
+ entity);
+ }
+ }
+ }
+ }
+
+
+ /**
+ * An existing entity has been deleted. This is a soft delete. This means it is still in the repository
+ * but it is no longer returned on queries.
+ *
+ * All relationships to the entity are also soft-deleted and will no longer be usable. These deleted relationships
+ * will be notified through separate events.
+ *
+ * Details of the TypeDef are included with the entity's unique id (guid) to ensure the right entity is deleted in
+ * the remote repositories.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param typeDefGUID - unique identifier for this entity's TypeDef
+ * @param typeDefName - name of this entity's TypeDef
+ * @param instanceGUID - unique identifier for the entity
+ */
+ public void processDeletedEntityEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ String typeDefGUID,
+ String typeDefName,
+ String instanceGUID)
+ {
+ if (repositoryValidator.validInstanceId(sourceName, typeDefGUID, typeDefName, TypeDefCategory.ENTITY_DEF, instanceGUID))
+ {
+ if (exchangeRule.processInstanceEvent(typeDefGUID,
+ typeDefName))
+ {
+ for (OMRSInstanceEventProcessor consumer : instanceEventConsumers)
+ {
+ consumer.processDeletedEntityEvent(sourceName,
+ originatorMetadataCollectionId,
+ originatorServerName,
+ originatorServerType,
+ originatorOrganizationName,
+ typeDefGUID,
+ typeDefName,
+ instanceGUID);
+ }
+ }
+ }
+ }
+
+
+ /**
+ * A deleted entity has been permanently removed from the repository. This request can not be undone.
+ *
+ * Details of the TypeDef are included with the entity's unique id (guid) to ensure the right entity is purged in
+ * the remote repositories.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param typeDefGUID - unique identifier for this entity's TypeDef
+ * @param typeDefName - name of this entity's TypeDef
+ * @param instanceGUID - unique identifier for the entity
+ */
+ public void processPurgedEntityEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ String typeDefGUID,
+ String typeDefName,
+ String instanceGUID)
+ {
+ if (repositoryValidator.validInstanceId(sourceName, typeDefGUID, typeDefName, TypeDefCategory.ENTITY_DEF, instanceGUID))
+ {
+ if (exchangeRule.processInstanceEvent(typeDefGUID, typeDefName))
+ {
+ for (OMRSInstanceEventProcessor consumer: instanceEventConsumers)
+ {
+ consumer.processPurgedEntityEvent(sourceName,
+ originatorMetadataCollectionId,
+ originatorServerName,
+ originatorServerType,
+ originatorOrganizationName,
+ typeDefGUID,
+ typeDefName,
+ instanceGUID);
+ }
+ }
+ }
+ }
+
+
+ /**
+ * A deleted entity has been restored to the state it was before it was deleted.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param entity - details of the versionName of the entity that has been restored.
+ */
+ public void processRestoredEntityEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ EntityDetail entity)
+ {
+ if (repositoryValidator.validEntity(sourceName, entity))
+ {
+ if (exchangeRule.processInstanceEvent(entity))
+ {
+ for (OMRSInstanceEventProcessor consumer: instanceEventConsumers)
+ {
+ consumer.processRestoredEntityEvent(sourceName,
+ originatorMetadataCollectionId,
+ originatorServerName,
+ originatorServerType,
+ originatorOrganizationName,
+ entity);
+ }
+ }
+ }
+ }
+
+
+ /**
+ * An existing entity has had its type changed. Typically this action is taken to move an entity's
+ * type to either a super type (so the subtype can be deleted) or a new subtype (so additional properties can be
+ * added.) However, the type can be changed to any compatible type.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param originalTypeDefSummary - details of this entity's original TypeDef.
+ * @param entity - new values for this entity, including the new type information.
+ */
+ public void processReTypedEntityEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ TypeDefSummary originalTypeDefSummary,
+ EntityDetail entity)
+ {
+ if (repositoryValidator.validEntity(sourceName, entity))
+ {
+ if (exchangeRule.processInstanceEvent(entity))
+ {
+ for (OMRSInstanceEventProcessor consumer: instanceEventConsumers)
+ {
+ consumer.processReTypedEntityEvent(sourceName,
+ originatorMetadataCollectionId,
+ originatorServerName,
+ originatorServerType,
+ originatorOrganizationName,
+ originalTypeDefSummary,
+ entity);
+ }
+ }
+ }
+ }
+
+
+ /**
+ * An existing entity has changed home repository. This action is taken for example, if a repository
+ * becomes permanently unavailable, or if the user community updating this entity move to working
+ * from a different repository in the open metadata repository cluster.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param originalHomeMetadataCollectionId - unique identifier for the original home metadata collection/repository.
+ * @param entity - new values for this entity, including the new home information.
+ */
+ public void processReHomedEntityEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ String originalHomeMetadataCollectionId,
+ EntityDetail entity)
+ {
+ if (repositoryValidator.validEntity(sourceName, entity))
+ {
+ if (exchangeRule.processInstanceEvent(entity))
+ {
+ for (OMRSInstanceEventProcessor consumer: instanceEventConsumers)
+ {
+ consumer.processReHomedEntityEvent(sourceName,
+ originatorMetadataCollectionId,
+ originatorServerName,
+ originatorServerType,
+ originatorOrganizationName,
+ originalHomeMetadataCollectionId,
+ entity);
+ }
+ }
+ }
+ }
+
+
+ /**
+ * The guid of an existing entity has been changed to a new value. This is used if two different
+ * entities are discovered to have the same guid. This is extremely unlikely but not impossible so
+ * the open metadata protocol has provision for this.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param originalEntityGUID - the existing identifier for the entity.
+ * @param entity - new values for this entity, including the new guid.
+ */
+ public void processReIdentifiedEntityEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ String originalEntityGUID,
+ EntityDetail entity)
+ {
+ if (repositoryValidator.validEntity(sourceName, entity))
+ {
+ if (exchangeRule.processInstanceEvent(entity))
+ {
+ for (OMRSInstanceEventProcessor consumer: instanceEventConsumers)
+ {
+ consumer.processReIdentifiedEntityEvent(sourceName,
+ originatorMetadataCollectionId,
+ originatorServerName,
+ originatorServerType,
+ originatorOrganizationName,
+ originalEntityGUID,
+ entity);
+ }
+ }
+ }
+ }
+
+
+ /**
+ * The local repository is requesting that an entity from another repository's metadata collection is
+ * refreshed so the local repository can create a reference copy.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param typeDefGUID - - unique identifier for this entity's TypeDef
+ * @param typeDefName - name of this entity's TypeDef
+ * @param instanceGUID - unique identifier for the entity
+ * @param homeMetadataCollectionId - metadata collection id for the home of this instance.
+ */
+ public void processRefreshEntityRequested(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ String typeDefGUID,
+ String typeDefName,
+ String instanceGUID,
+ String homeMetadataCollectionId)
+ {
+ if (repositoryValidator.validInstanceId(sourceName, typeDefGUID, typeDefName, TypeDefCategory.ENTITY_DEF, instanceGUID))
+ {
+ if (exchangeRule.processInstanceEvent(typeDefGUID, typeDefName))
+ {
+ for (OMRSInstanceEventProcessor consumer: instanceEventConsumers)
+ {
+ consumer.processRefreshEntityRequested(sourceName,
+ originatorMetadataCollectionId,
+ originatorServerName,
+ originatorServerType,
+ originatorOrganizationName,
+ typeDefGUID,
+ typeDefName,
+ instanceGUID,
+ homeMetadataCollectionId);
+ }
+ }
+ }
+ }
+
+
+ /**
+ * A remote repository in the cohort has sent entity details in response to a refresh request.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param entity - details of the requested entity
+ */
+ public void processRefreshEntityEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ EntityDetail entity)
+ {
+ if (repositoryValidator.validEntity(sourceName, entity))
+ {
+ if (exchangeRule.processInstanceEvent(entity))
+ {
+ for (OMRSInstanceEventProcessor consumer: instanceEventConsumers)
+ {
+ consumer.processRefreshEntityEvent(sourceName,
+ originatorMetadataCollectionId,
+ originatorServerName,
+ originatorServerType,
+ originatorOrganizationName,
+ entity);
+ }
+ }
+ }
+ }
+
+
+ /**
+ * A new relationship has been created.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param relationship - details of the new relationship
+ */
+ public void processNewRelationshipEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ Relationship relationship)
+ {
+ if (repositoryValidator.validRelationship(sourceName, relationship))
+ {
+ if (exchangeRule.processInstanceEvent(relationship))
+ {
+ for (OMRSInstanceEventProcessor consumer: instanceEventConsumers)
+ {
+ consumer.processNewRelationshipEvent(sourceName,
+ originatorMetadataCollectionId,
+ originatorServerName,
+ originatorServerType,
+ originatorOrganizationName,
+ relationship);
+ }
+ }
+ }
+ }
+
+
+ /**
+ * An existing relationship has been updated.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param relationship - details of the new versionName of the relationship.
+ */
+ public void processUpdatedRelationshipEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ Relationship relationship)
+ {
+ if (repositoryValidator.validRelationship(sourceName, relationship))
+ {
+ if (exchangeRule.processInstanceEvent(relationship))
+ {
+ for (OMRSInstanceEventProcessor consumer: instanceEventConsumers)
+ {
+ consumer.processUpdatedRelationshipEvent(sourceName,
+ originatorMetadataCollectionId,
+ originatorServerName,
+ originatorServerType,
+ originatorOrganizationName,
+ relationship);
+ }
+ }
+ }
+ }
+
+ /**
+ * An update to a relationship has been undone.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param relationship - details of the versionName of the relationship that has been restored.
+ */
+ public void processUndoneRelationshipEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ Relationship relationship)
+ {
+ if (repositoryValidator.validRelationship(sourceName, relationship))
+ {
+ if (exchangeRule.processInstanceEvent(relationship))
+ {
+ for (OMRSInstanceEventProcessor consumer: instanceEventConsumers)
+ {
+ consumer.processUndoneRelationshipEvent(sourceName,
+ originatorMetadataCollectionId,
+ originatorServerName,
+ originatorServerType,
+ originatorOrganizationName,
+ relationship);
+ }
+ }
+ }
+ }
+
+
+ /**
+ * An existing relationship has been deleted. This is a soft delete. This means it is still in the repository
+ * but it is no longer returned on queries.
+ *
+ * Details of the TypeDef are included with the relationship's unique id (guid) to ensure the right
+ * relationship is deleted in the remote repositories.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param typeDefGUID - unique identifier for this relationship's TypeDef
+ * @param typeDefName - name of this relationship's TypeDef
+ * @param instanceGUID - unique identifier for the relationship
+ */
+ public void processDeletedRelationshipEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ String typeDefGUID,
+ String typeDefName,
+ String instanceGUID)
+ {
+ if (repositoryValidator.validInstanceId(sourceName, typeDefGUID, typeDefName, TypeDefCategory.RELATIONSHIP_DEF, instanceGUID))
+ {
+ if (exchangeRule.processInstanceEvent(typeDefGUID, typeDefName))
+ {
+ for (OMRSInstanceEventProcessor consumer: instanceEventConsumers)
+ {
+ consumer.processDeletedRelationshipEvent(sourceName,
+ originatorMetadataCollectionId,
+ originatorServerName,
+ originatorServerType,
+ originatorOrganizationName,
+ typeDefGUID,
+ typeDefName,
+ instanceGUID);
+ }
+ }
+ }
+ }
+
+
+ /**
+ * A deleted relationship has been permanently removed from the repository. This request can not be undone.
+ *
+ * Details of the TypeDef are included with the relationship's unique id (guid) to ensure the right
+ * relationship is purged in the remote repositories.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param typeDefGUID - unique identifier for this relationship's TypeDef.
+ * @param typeDefName - name of this relationship's TypeDef.
+ * @param instanceGUID - unique identifier for the relationship.
+ */
+ public void processPurgedRelationshipEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ String typeDefGUID,
+ String typeDefName,
+ String instanceGUID)
+ {
+ if (repositoryValidator.validInstanceId(sourceName, typeDefGUID, typeDefName, TypeDefCategory.RELATIONSHIP_DEF, instanceGUID))
+ {
+ if (exchangeRule.processInstanceEvent(typeDefGUID, typeDefName))
+ {
+ for (OMRSInstanceEventProcessor consumer: instanceEventConsumers)
+ {
+ consumer.processPurgedRelationshipEvent(sourceName,
+ originatorMetadataCollectionId,
+ originatorServerName,
+ originatorServerType,
+ originatorOrganizationName,
+ typeDefGUID,
+ typeDefName,
+ instanceGUID);
+ }
+ }
+ }
+ }
+
+
+ /**
+ * A deleted relationship has been restored to the state it was before it was deleted.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param relationship - details of the versionName of the relationship that has been restored.
+ */
+ public void processRestoredRelationshipEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ Relationship relationship)
+ {
+ if (repositoryValidator.validRelationship(sourceName, relationship))
+ {
+ if (exchangeRule.processInstanceEvent(relationship))
+ {
+ for (OMRSInstanceEventProcessor consumer: instanceEventConsumers)
+ {
+ consumer.processRestoredRelationshipEvent(sourceName,
+ originatorMetadataCollectionId,
+ originatorServerName,
+ originatorServerType,
+ originatorOrganizationName,
+ relationship);
+ }
+ }
+ }
+ }
+
+
+ /**
+ * An existing relationship has had its type changed. Typically this action is taken to move a relationship's
+ * type to either a super type (so the subtype can be deleted) or a new subtype (so additional properties can be
+ * added.) However, the type can be changed to any compatible type.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param originalTypeDefSummary - original details for this relationship's TypeDef.
+ * @param relationship - new values for this relationship, including the new type information.
+ */
+ public void processReTypedRelationshipEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ TypeDefSummary originalTypeDefSummary,
+ Relationship relationship)
+ {
+ if (repositoryValidator.validRelationship(sourceName, relationship))
+ {
+ if (exchangeRule.processInstanceEvent(relationship))
+ {
+ for (OMRSInstanceEventProcessor consumer: instanceEventConsumers)
+ {
+ consumer.processReTypedRelationshipEvent(sourceName,
+ originatorMetadataCollectionId,
+ originatorServerName,
+ originatorServerType,
+ originatorOrganizationName,
+ originalTypeDefSummary,
+ relationship);
+ }
+ }
+ }
+ }
+
+
+ /**
+ * An existing relationship has changed home repository. This action is taken for example, if a repository
+ * becomes permanently unavailable, or if the user community updating this relationship move to working
+ * from a different repository in the open metadata repository cluster.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param originalHomeMetadataCollection - unique identifier for the original home repository.
+ * @param relationship - new values for this relationship, including the new home information.
+ */
+ public void processReHomedRelationshipEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ String originalHomeMetadataCollection,
+ Relationship relationship)
+ {
+ if (repositoryValidator.validRelationship(sourceName, relationship))
+ {
+ if (exchangeRule.processInstanceEvent(relationship))
+ {
+ for (OMRSInstanceEventProcessor consumer: instanceEventConsumers)
+ {
+ consumer.processReHomedRelationshipEvent(sourceName,
+ originatorMetadataCollectionId,
+ originatorServerName,
+ originatorServerType,
+ originatorOrganizationName,
+ originalHomeMetadataCollection,
+ relationship);
+ }
+ }
+ }
+ }
+
+
+ /**
+ * The guid of an existing relationship has changed. This is used if two different
+ * relationships are discovered to have the same guid. This is extremely unlikely but not impossible so
+ * the open metadata protocol has provision for this.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param originalRelationshipGUID - the existing identifier for the relationship.
+ * @param relationship - new values for this relationship, including the new guid.
+ */
+ public void processReIdentifiedRelationshipEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ String originalRelationshipGUID,
+ Relationship relationship)
+ {
+ if (repositoryValidator.validRelationship(sourceName, relationship))
+ {
+ if (exchangeRule.processInstanceEvent(relationship))
+ {
+ for (OMRSInstanceEventProcessor consumer: instanceEventConsumers)
+ {
+ consumer.processReIdentifiedRelationshipEvent(sourceName,
+ originatorMetadataCollectionId,
+ originatorServerName,
+ originatorServerType,
+ originatorOrganizationName,
+ originalRelationshipGUID,
+ relationship);
+ }
+ }
+ }
+ }
+
+
+ /**
+ * A repository has requested the home repository of a relationship send details of the relationship so
+ * its local metadata collection can create a reference copy of the instance.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param typeDefGUID - unique identifier for this instance's TypeDef
+ * @param typeDefName - name of this relationship's TypeDef
+ * @param instanceGUID - unique identifier for the instance
+ * @param homeMetadataCollectionId - metadata collection id for the home of this instance.
+ */
+ public void processRefreshRelationshipRequest(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ String typeDefGUID,
+ String typeDefName,
+ String instanceGUID,
+ String homeMetadataCollectionId)
+ {
+ if (repositoryValidator.validInstanceId(sourceName, typeDefGUID, typeDefName, TypeDefCategory.RELATIONSHIP_DEF, instanceGUID))
+ {
+ if (exchangeRule.processInstanceEvent(typeDefGUID, typeDefName))
+ {
+ for (OMRSInstanceEventProcessor consumer: instanceEventConsumers)
+ {
+ consumer.processRefreshRelationshipRequest(sourceName,
+ originatorMetadataCollectionId,
+ originatorServerName,
+ originatorServerType,
+ originatorOrganizationName,
+ typeDefGUID,
+ typeDefName,
+ instanceGUID,
+ homeMetadataCollectionId);
+ }
+ }
+ }
+ }
+
+
+ /**
+ * The local repository is refreshing the information about a relationship for the other
+ * repositories in the cohort.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param relationship - relationship details
+ */
+ public void processRefreshRelationshipEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ Relationship relationship)
+ {
+ if (repositoryValidator.validRelationship(sourceName, relationship))
+ {
+ if (exchangeRule.processInstanceEvent(relationship))
+ {
+ for (OMRSInstanceEventProcessor consumer: instanceEventConsumers)
+ {
+ consumer.processRefreshRelationshipEvent(sourceName,
+ originatorMetadataCollectionId,
+ originatorServerName,
+ originatorServerType,
+
<TRUNCATED>
[26/30] atlas git commit: ATLAS-2246: OMRS Connector API plus REST
and IGC Connector skeleton - 15th February 2018
Posted by da...@apache.org.
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;
+ }
+}
[13/30] atlas git commit: ATLAS-2246: OMRS Connector API plus REST
and IGC Connector skeleton - 15th February 2018
Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositoryconnector/LocalOMRSConnectorProvider.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositoryconnector/LocalOMRSConnectorProvider.java b/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositoryconnector/LocalOMRSConnectorProvider.java
new file mode 100644
index 0000000..0e7b26f
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositoryconnector/LocalOMRSConnectorProvider.java
@@ -0,0 +1,200 @@
+/*
+ * 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.localrepository.repositoryconnector;
+
+import org.apache.atlas.ocf.Connector;
+import org.apache.atlas.ocf.ConnectorBroker;
+import org.apache.atlas.ocf.ConnectorProvider;
+import org.apache.atlas.ocf.ffdc.ConnectionCheckedException;
+import org.apache.atlas.ocf.ffdc.ConnectorCheckedException;
+import org.apache.atlas.ocf.properties.Connection;
+import org.apache.atlas.omrs.eventmanagement.OMRSRepositoryEventExchangeRule;
+import org.apache.atlas.omrs.eventmanagement.OMRSRepositoryEventManager;
+import org.apache.atlas.omrs.eventmanagement.repositoryeventmapper.OMRSRepositoryEventMapper;
+import org.apache.atlas.omrs.ffdc.OMRSErrorCode;
+import org.apache.atlas.omrs.localrepository.repositorycontentmanager.OMRSRepositoryContentManager;
+import org.apache.atlas.omrs.localrepository.repositorycontentmanager.OMRSRepositoryHelper;
+import org.apache.atlas.omrs.localrepository.repositorycontentmanager.OMRSRepositoryValidator;
+import org.apache.atlas.omrs.metadatacollection.repositoryconnector.OMRSRepositoryConnector;
+
+import java.util.UUID;
+
+
+/**
+ * LocalOMRSConnectorProvider implements the connector provider for LocalOMRSRepositoryConnector. Since a server only
+ * has one LocalOMRSRepositoryConnector, this connector provider returns the singleton connector for the local repository.
+ */
+public class LocalOMRSConnectorProvider extends ConnectorProvider
+{
+ private String localMetadataCollectionId = null;
+ private Connection localRepositoryRemoteConnection = null;
+ private String localServerName = null;
+ private String localServerType = null;
+ private String localOrganizationName = null;
+ private OMRSRepositoryEventMapper repositoryEventMapper = null;
+ private OMRSRepositoryEventManager outboundRepositoryEventManager = null;
+ private OMRSRepositoryContentManager repositoryContentManager = null;
+ private OMRSRepositoryEventExchangeRule saveExchangeRule = null;
+ private LocalOMRSRepositoryConnector localRepositoryConnector = null;
+
+
+
+ /**
+ * Constructor used by OMRSOperationalServices during server start-up - it
+ * provides the configuration information about the local server that is used to set up the
+ * local repository connector.
+ *
+ * @param localMetadataCollectionId - metadata collection Id for the local repository
+ * @param localRepositoryRemoteConnection - connection object for creating a remote connector to this repository.
+ * @param localServerName - name of the local server
+ * @param localServerType - type of the local server
+ * @param localOrganizationName - name of organization that owns the server
+ * @param repositoryEventMapper - optional event mapper for local repository
+ * @param outboundRepositoryEventManager - event manager to call for outbound events.
+ * @param repositoryContentManager - repositoryContentManager for supporting OMRS in managing TypeDefs.
+ * @param saveExchangeRule - rule to determine what events to save to the local repository.
+ */
+ public LocalOMRSConnectorProvider(String localMetadataCollectionId,
+ Connection localRepositoryRemoteConnection,
+ String localServerName,
+ String localServerType,
+ String localOrganizationName,
+ OMRSRepositoryEventMapper repositoryEventMapper,
+ OMRSRepositoryEventManager outboundRepositoryEventManager,
+ OMRSRepositoryContentManager repositoryContentManager,
+ OMRSRepositoryEventExchangeRule saveExchangeRule)
+ {
+ this.localMetadataCollectionId = localMetadataCollectionId;
+ this.localRepositoryRemoteConnection = localRepositoryRemoteConnection;
+ this.localServerName = localServerName;
+ this.localServerType = localServerType;
+ this.localOrganizationName = localOrganizationName;
+ this.repositoryEventMapper = repositoryEventMapper;
+ this.outboundRepositoryEventManager = outboundRepositoryEventManager;
+ this.repositoryContentManager = repositoryContentManager;
+ this.saveExchangeRule = saveExchangeRule;
+ }
+
+
+ /**
+ * Constructor used by the OCF ConnectorBroker. This approach will result in an exception
+ * when getConnector is called because there is no localMetadataCollectionId (amongst other things).
+ */
+ public LocalOMRSConnectorProvider()
+ {
+ }
+
+
+ /**
+ * Creates a new instance of a connector based on the information in the supplied connection.
+ *
+ * @param realLocalConnection - connection that should have all of the properties needed by the Connector Provider
+ * to create a connector instance.
+ * @return Connector - instance of the LocalOMRSRepositoryConnector wrapping the real local connector.
+ * @throws ConnectionCheckedException - if there are missing or invalid properties in the connection
+ * @throws ConnectorCheckedException - if there are issues instantiating or initializing the connector
+ */
+ public synchronized Connector getConnector(Connection realLocalConnection) throws ConnectionCheckedException,
+ ConnectorCheckedException
+ {
+ if (localMetadataCollectionId == null)
+ {
+ String methodName = "getConnector()";
+
+ /*
+ * Throw runtime exception to indicate that the local repository is not available. This
+ * is likely to be a configuration error.
+ */
+ OMRSErrorCode errorCode = OMRSErrorCode.LOCAL_REPOSITORY_CONFIGURATION_ERROR;
+ String errorMessage = errorCode.getErrorMessageId()
+ + errorCode.getFormattedErrorMessage();
+
+ throw new ConnectorCheckedException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ methodName,
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+
+ /*
+ * Only create one instance of the connector
+ */
+ if (localRepositoryConnector == null)
+ {
+ OMRSRepositoryConnector realLocalConnector = null;
+
+ /*
+ * Any problems creating the connector to the local repository are passed to the caller as exceptions.
+ */
+ ConnectorBroker connectorBroker = new ConnectorBroker();
+ Connector connector = connectorBroker.getConnector(realLocalConnection);
+
+ /*
+ * Try casting the returned connector to a repository connector. This should work unless the connection
+ * passed is for a different type of connector.
+ */
+ try
+ {
+ realLocalConnector = (OMRSRepositoryConnector) connector;
+ }
+ catch (Throwable error)
+ {
+ // TODO throw ConnectionChecked Exception
+ }
+
+ /*
+ * Set up the local metadata collection Id in the real local connector.
+ */
+ realLocalConnector.setMetadataCollectionId(localMetadataCollectionId);
+
+ /*
+ * With the connection to the real local repository established it is possible to create the wrapper
+ * for the local repository. This wrapper is seen by most OMRS Components as the local repository
+ * connector. The exceptions are the inbound event processors that work with the real local connector.
+ */
+ localRepositoryConnector = new LocalOMRSRepositoryConnector(localServerName,
+ localServerType,
+ localOrganizationName,
+ realLocalConnector,
+ repositoryEventMapper,
+ outboundRepositoryEventManager,
+ repositoryContentManager,
+ saveExchangeRule);
+ localRepositoryConnector.initialize(this.getNewConnectorGUID(), localRepositoryRemoteConnection);
+ localRepositoryConnector.setMetadataCollectionId(localMetadataCollectionId);
+ }
+
+ return localRepositoryConnector;
+ }
+
+
+ /**
+ * Each connector has a guid to make it easier to correlate log messages from the various components that
+ * serve it. It uses a type 4 (pseudo randomly generated) UUID.
+ * The UUID is generated using a cryptographically strong pseudo random number generator.
+ *
+ * @return guid for a new connector instance
+ */
+ private String getNewConnectorGUID()
+ {
+ UUID newUUID = UUID.randomUUID();
+
+ return newUUID.toString();
+ }
+}
http://git-wip-us.apache.org/repos/asf/atlas/blob/8a57e657/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositoryconnector/LocalOMRSInstanceEventProcessor.java
----------------------------------------------------------------------
diff --git a/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositoryconnector/LocalOMRSInstanceEventProcessor.java b/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositoryconnector/LocalOMRSInstanceEventProcessor.java
new file mode 100644
index 0000000..5a0182e
--- /dev/null
+++ b/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositoryconnector/LocalOMRSInstanceEventProcessor.java
@@ -0,0 +1,1056 @@
+/*
+ * 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.localrepository.repositoryconnector;
+
+import org.apache.atlas.omrs.auditlog.OMRSAuditLog;
+import org.apache.atlas.omrs.auditlog.OMRSAuditingComponent;
+import org.apache.atlas.omrs.eventmanagement.*;
+import org.apache.atlas.omrs.eventmanagement.events.OMRSInstanceEventProcessor;
+import org.apache.atlas.omrs.ffdc.exception.*;
+import org.apache.atlas.omrs.localrepository.repositorycontentmanager.OMRSTypeDefHelper;
+import org.apache.atlas.omrs.metadatacollection.OMRSMetadataCollection;
+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.TypeDefSummary;
+import org.apache.atlas.omrs.metadatacollection.repositoryconnector.OMRSRepositoryConnector;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+
+
+/**
+ * LocalOMRSInstanceEventProcessor processes incoming metadata instance events that describe changes to the
+ * entities and relationships in other repositories in the connected cohorts.
+ * It uses the save exchange rule to decide which events to process and which to ignore.
+ * Events that are to be processed are converted into reference copies of their respective entities and
+ * relationships and stored in the local repository.
+ */
+public class LocalOMRSInstanceEventProcessor implements OMRSInstanceEventProcessor, OMRSInstanceRetrievalEventProcessor
+{
+ private String localMetadataCollectionId = null;
+ private OMRSRepositoryConnector realLocalConnector = null;
+ private OMRSTypeDefHelper typeDefHelper = null;
+ private OMRSRepositoryEventExchangeRule saveExchangeRule = null;
+
+
+ /*
+ * The audit log provides a verifiable record of the open metadata archives that have been loaded into
+ * the open metadata repository. The Logger is for standard debug.
+ */
+ private static final OMRSAuditLog auditLog = new OMRSAuditLog(OMRSAuditingComponent.INSTANCE_EVENT_PROCESSOR);
+ private static final Logger log = LoggerFactory.getLogger(LocalOMRSInstanceEventProcessor.class);
+
+
+ /**
+ * Constructor saves all of the information necessary to process incoming instance events. It is intolerant
+ * of nulls in any of its parameters and will throw a logic error exception is it finds any.
+ *
+ * @param localMetadataCollectionId - local metadata collection identifier
+ * @param realLocalConnector - connector to the real local repository
+ * @param typeDefHelper - helper class for building instances
+ * @param saveExchangeRule - rule that determines which events to process.
+ */
+ LocalOMRSInstanceEventProcessor(String localMetadataCollectionId,
+ OMRSRepositoryConnector realLocalConnector,
+ OMRSTypeDefHelper typeDefHelper,
+ OMRSRepositoryEventExchangeRule saveExchangeRule)
+ {
+ if (localMetadataCollectionId == null)
+ {
+ // TODO throw exception
+ }
+ this.localMetadataCollectionId = localMetadataCollectionId;
+
+ if (realLocalConnector == null)
+ {
+ // TODO throw exception
+ }
+ this.realLocalConnector = realLocalConnector;
+
+ if (typeDefHelper == null)
+ {
+ // TODO Throw exception
+ }
+ this.typeDefHelper = typeDefHelper;
+
+ if (saveExchangeRule == null)
+ {
+ // TODO Throw exception
+ }
+ this.saveExchangeRule = saveExchangeRule;
+ }
+
+
+ /*
+ * ====================================
+ * OMRSInstanceEventProcessor
+ */
+
+ /**
+ * A new entity has been created.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param entity - details of the new entity
+ */
+ public void processNewEntityEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ EntityDetail entity)
+ {
+ OMRSMetadataCollection metadataCollection = realLocalConnector.getMetadataCollection();
+
+ if (metadataCollection != null)
+ {
+ try
+ {
+ metadataCollection.saveEntityReferenceCopy(null, entity);
+ }
+ catch (RepositoryErrorException error)
+ {
+ // TODO log an error to say that the repository is not available
+
+ if (log.isDebugEnabled())
+ {
+ log.debug("Entity not added because repository is not available", entity);
+ log.debug("RepositoryErrorException:", error);
+ }
+ }
+ catch (TypeErrorException error)
+ {
+ // TODO log an error to say that the repository does not recognize the entity's type
+
+ if (log.isDebugEnabled())
+ {
+ log.debug("Entity not added because repository does not recognise its type", entity);
+ log.debug("TypeErrorException:", error);
+ }
+ }
+ catch (PropertyErrorException error)
+ {
+ // TODO log an error to say that the entity contains properties that conflict with its type
+
+ if (log.isDebugEnabled())
+ {
+ log.debug("Entity not added because it has properties that conflict with its type", entity);
+ log.debug("PropertyErrorException:", error);
+ }
+ }
+ catch (HomeEntityException error)
+ {
+ // TODO log an error to say that the metadata collection Id of the archive conflicts with the
+ // TODO the local repository's local metadata collection Id
+
+ if (log.isDebugEnabled())
+ {
+ log.debug("Entity not added because it has metadata collection Id " +
+ "that conflicts with local repository's metadata collection Id", entity);
+ log.debug("HomeEntityException:", error);
+ }
+ }
+ catch (EntityConflictException error)
+ {
+ // TODO log an error to say that the entity contents conflict with the versionName of the entity already stored.
+
+ if (log.isDebugEnabled())
+ {
+ log.debug("Entity not added because it has properties that conflict with the versionName of the entity already stored", entity);
+ log.debug("EntityConflictException:", error);
+ }
+ }
+ catch (InvalidEntityException error)
+ {
+ // TODO log an error to say that the entity contents are invalid.
+
+ if (log.isDebugEnabled())
+ {
+ log.debug("Entity not added because entity has properties that are invalid", entity);
+ log.debug("InvalidEntityException:", error);
+ }
+ }
+ catch (Throwable error)
+ {
+ // TODO log a generic error
+
+ if (log.isDebugEnabled())
+ {
+ log.debug("Entity not applied because of an error", entity);
+ log.debug("Throwable:", error);
+ }
+ }
+ }
+ else
+ {
+ // TODO log that metadata collection is null (logic Error)
+ }
+ }
+
+
+ /**
+ * An existing entity has been updated.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param entity - details of the new versionName of the entity.
+ */
+ public void processUpdatedEntityEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ EntityDetail entity)
+ {
+
+ }
+
+
+ /**
+ * An update to an entity has been undone.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param entity - details of the versionName of the entity that has been restored.
+ */
+ public void processUndoneEntityEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ EntityDetail entity)
+ {
+
+ }
+
+
+ /**
+ * A new classification has been added to an entity.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param entity - details of the entity with the new classification added.
+ */
+ public void processClassifiedEntityEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ EntityDetail entity)
+ {
+
+ }
+
+
+ /**
+ * A classification has been removed from an entity.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param entity - details of the entity after the classification has been removed.
+ */
+ public void processDeclassifiedEntityEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ EntityDetail entity)
+ {
+
+ }
+
+
+ /**
+ * An existing classification has been changed on an entity.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param entity - details of the entity after the classification has been changed.
+ */
+ public void processReclassifiedEntityEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ EntityDetail entity)
+ {
+
+ }
+
+
+ /**
+ * An existing entity has been deleted. This is a soft delete. This means it is still in the repository
+ * but it is no longer returned on queries.
+ *
+ * All relationships to the entity are also soft-deleted and will no longer be usable. These deleted relationships
+ * will be notified through separate events.
+ *
+ * Details of the TypeDef are included with the entity's unique id (guid) to ensure the right entity is deleted in
+ * the remote repositories.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param typeDefGUID - unique identifier for this entity's TypeDef
+ * @param typeDefName - name of this entity's TypeDef
+ * @param instanceGUID - unique identifier for the entity
+ */
+ public void processDeletedEntityEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ String typeDefGUID,
+ String typeDefName,
+ String instanceGUID)
+ {
+
+ }
+
+
+ /**
+ * A deleted entity has been permanently removed from the repository. This request can not be undone.
+ *
+ * Details of the TypeDef are included with the entity's unique id (guid) to ensure the right entity is purged in
+ * the remote repositories.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param typeDefGUID - unique identifier for this entity's TypeDef
+ * @param typeDefName - name of this entity's TypeDef
+ * @param instanceGUID - unique identifier for the entity
+ */
+ public void processPurgedEntityEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ String typeDefGUID,
+ String typeDefName,
+ String instanceGUID)
+ {
+
+ }
+
+
+ /**
+ * A deleted entity has been restored to the state it was before it was deleted.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param entity - details of the versionName of the entity that has been restored.
+ */
+ public void processRestoredEntityEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ EntityDetail entity)
+ {
+
+ }
+
+
+ /**
+ * The guid of an existing entity has been changed to a new value. This is used if two different
+ * entities are discovered to have the same guid. This is extremely unlikely but not impossible so
+ * the open metadata protocol has provision for this.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param originalEntityGUID - the existing identifier for the entity.
+ * @param entity - new values for this entity, including the new guid.
+ */
+ public void processReIdentifiedEntityEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ String originalEntityGUID,
+ EntityDetail entity)
+ {
+
+ }
+
+
+ /**
+ * An existing entity has had its type changed. Typically this action is taken to move an entity's
+ * type to either a super type (so the subtype can be deleted) or a new subtype (so additional properties can be
+ * added.) However, the type can be changed to any compatible type.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param originalTypeDefSummary - original details of this entity's TypeDef.
+ * @param entity - new values for this entity, including the new type information.
+ */
+ public void processReTypedEntityEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ TypeDefSummary originalTypeDefSummary,
+ EntityDetail entity)
+ {
+
+ }
+
+
+ /**
+ * An existing entity has changed home repository. This action is taken for example, if a repository
+ * becomes permanently unavailable, or if the user community updating this entity move to working
+ * from a different repository in the open metadata repository cluster.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param originalHomeMetadataCollectionId - unique identifier for the original home repository.
+ * @param entity - new values for this entity, including the new home information.
+ */
+ public void processReHomedEntityEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ String originalHomeMetadataCollectionId,
+ EntityDetail entity)
+ {
+
+ }
+
+
+ /**
+ * The local repository is requesting that an entity from another repository's metadata collection is
+ * refreshed so the local repository can create a reference copy.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param typeDefGUID - - unique identifier for this entity's TypeDef
+ * @param typeDefName - name of this entity's TypeDef
+ * @param instanceGUID - unique identifier for the entity
+ * @param homeMetadataCollectionId - metadata collection id for the home of this instance.
+ */
+ public void processRefreshEntityRequested(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ String typeDefGUID,
+ String typeDefName,
+ String instanceGUID,
+ String homeMetadataCollectionId)
+ {
+
+ }
+
+
+ /**
+ * A remote repository in the cohort has sent entity details in response to a refresh request.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param entity - details of the requested entity
+ */
+ public void processRefreshEntityEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ EntityDetail entity)
+ {
+
+ }
+
+
+ /**
+ * A new relationship has been created.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param relationship - details of the new relationship
+ */
+ public void processNewRelationshipEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ Relationship relationship)
+ {
+ OMRSMetadataCollection metadataCollection = realLocalConnector.getMetadataCollection();
+
+ if (metadataCollection != null)
+ {
+ try
+ {
+ metadataCollection.saveRelationshipReferenceCopy(null, relationship);
+ }
+ catch (RepositoryErrorException error)
+ {
+ // TODO log an error to say that the repository is not available
+
+ if (log.isDebugEnabled())
+ {
+ log.debug("Relationship not added because repository is not available", relationship);
+ log.debug("RepositoryErrorException:", error);
+ }
+ }
+ catch (TypeErrorException error)
+ {
+ // TODO log an error to say that the repository does not recognize the relationship's type
+
+ if (log.isDebugEnabled())
+ {
+ log.debug("Relationship not added because repository does not recognise its type", relationship);
+ log.debug("TypeErrorException:", error);
+ }
+ }
+ catch (PropertyErrorException error)
+ {
+ // TODO log an error to say that the relationship contains properties that conflict with its type
+
+ if (log.isDebugEnabled())
+ {
+ log.debug("Relationship not added because its has properties that conflict with its type", relationship);
+ log.debug("PropertyErrorException:", error);
+ }
+ }
+ catch (HomeRelationshipException error)
+ {
+ // TODO log an error to say that the metadata collection Id of the archive conflicts with the
+ // TODO the local repository's local metadata collection Id
+
+ if (log.isDebugEnabled())
+ {
+ log.debug("Relationship not added because its has metadata collection Id " +
+ "that conflicts with local repository's metadata collection Id", relationship);
+ log.debug("HomeRelationshipException:", error);
+ }
+ }
+ catch (RelationshipConflictException error)
+ {
+ // TODO log an error to say that the relationship contents conflict with the versionName of the relationship already stored.
+
+ if (log.isDebugEnabled())
+ {
+ log.debug("Relationship not added because it has properties that conflict with " +
+ "the versionName of the relationship already stored", relationship);
+ log.debug("EntityConflictException:", error);
+ }
+ }
+ catch (InvalidRelationshipException error)
+ {
+ // TODO log an error to say that the entity contents are invalid.
+
+ if (log.isDebugEnabled())
+ {
+ log.debug("Relationship not added because it has properties that are invalid", relationship);
+ log.debug("InvalidRelationshipException:", error);
+ }
+ }
+ catch (Throwable error)
+ {
+ // TODO log a generic error
+
+ if (log.isDebugEnabled())
+ {
+ log.debug("Relationship not applied because of an error", relationship);
+ log.debug("Throwable:", error);
+ }
+ }
+ }
+ else
+ {
+ // TODO log that metadata collection is null (logic Error)
+ }
+ }
+
+
+ /**
+ * An existing relationship has been updated.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param relationship - details of the new versionName of the relationship.
+ */
+ public void processUpdatedRelationshipEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ Relationship relationship)
+ {
+
+ }
+
+
+ /**
+ * An update to a relationship has been undone.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param relationship - details of the versionName of the relationship that has been restored.
+ */
+ public void processUndoneRelationshipEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ Relationship relationship)
+ {
+ }
+
+
+ /**
+ * An existing relationship has been deleted. This is a soft delete. This means it is still in the repository
+ * but it is no longer returned on queries.
+ *
+ * Details of the TypeDef are included with the relationship's unique id (guid) to ensure the right
+ * relationship is deleted in the remote repositories.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param typeDefGUID - unique identifier for this relationship's TypeDef
+ * @param typeDefName - name of this relationship's TypeDef
+ * @param instanceGUID - unique identifier for the relationship
+ */
+ public void processDeletedRelationshipEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ String typeDefGUID,
+ String typeDefName,
+ String instanceGUID)
+ {
+
+ }
+
+
+ /**
+ * A deleted relationship has been permanently removed from the repository. This request can not be undone.
+ *
+ * Details of the TypeDef are included with the relationship's unique id (guid) to ensure the right
+ * relationship is purged in the remote repositories.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param typeDefGUID - unique identifier for this relationship's TypeDef.
+ * @param typeDefName - name of this relationship's TypeDef.
+ * @param instanceGUID - unique identifier for the relationship.
+ */
+ public void processPurgedRelationshipEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ String typeDefGUID,
+ String typeDefName,
+ String instanceGUID)
+ {
+
+ }
+
+
+ /**
+ * A deleted relationship has been restored to the state it was before it was deleted.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param relationship - details of the versionName of the relationship that has been restored.
+ */
+ public void processRestoredRelationshipEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ Relationship relationship)
+ {
+
+ }
+
+
+ /**
+ * The guid of an existing relationship has changed. This is used if two different
+ * relationships are discovered to have the same guid. This is extremely unlikely but not impossible so
+ * the open metadata protocol has provision for this.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param originalRelationshipGUID - the existing identifier for the relationship.
+ * @param relationship - new values for this relationship, including the new guid.
+ */
+ public void processReIdentifiedRelationshipEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ String originalRelationshipGUID,
+ Relationship relationship)
+ {
+
+ }
+
+
+ /**
+ * An existing relationship has had its type changed. Typically this action is taken to move a relationship's
+ * type to either a super type (so the subtype can be deleted) or a new subtype (so additional properties can be
+ * added.) However, the type can be changed to any compatible type.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param originalTypeDefSummary - original details of this relationship's TypeDef.
+ * @param relationship - new values for this relationship, including the new type information.
+ */
+ public void processReTypedRelationshipEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ TypeDefSummary originalTypeDefSummary,
+ Relationship relationship)
+ {
+
+ }
+
+
+ /**
+ * An existing relationship has changed home repository. This action is taken for example, if a repository
+ * becomes permanently unavailable, or if the user community updating this relationship move to working
+ * from a different repository in the open metadata repository cluster.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param originalHomeMetadataCollection - unique identifier for the original home repository.
+ * @param relationship - new values for this relationship, including the new home information.
+ */
+ public void processReHomedRelationshipEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ String originalHomeMetadataCollection,
+ Relationship relationship)
+ {
+
+ }
+
+
+ /**
+ * A repository has requested the home repository of a relationship send details of the relationship so
+ * the local repository can create a reference copy of the instance.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param typeDefGUID - unique identifier for this instance's TypeDef
+ * @param typeDefName - name of this relationship's TypeDef
+ * @param instanceGUID - unique identifier for the instance
+ * @param homeMetadataCollectionId - metadata collection id for the home of this instance.
+ */
+ public void processRefreshRelationshipRequest(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ String typeDefGUID,
+ String typeDefName,
+ String instanceGUID,
+ String homeMetadataCollectionId)
+ {
+
+ }
+
+
+ /**
+ * The local repository is refreshing the information about a relationship for the other
+ * repositories in the cohort.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - unique identifier for the metadata collection hosted by the server that
+ * sent the event.
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param relationship - relationship details
+ */
+ public void processRefreshRelationshipEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ Relationship relationship)
+ {
+
+ }
+
+
+ /**
+ * An open metadata repository has detected two metadata instances with the same identifier (guid).
+ * This is a serious error because it could lead to corruption of the metadata collections within the cohort.
+ * When this occurs, all repositories in the cohort delete their reference copies of the metadata instances and
+ * at least one of the instances has its GUID changed in its respective home repository. The updated instance(s)
+ * are redistributed around the cohort.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - metadata collection id of the repository reporting the conflicting instance
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param 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 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
+ * @param errorMessage - description of the error.
+ */
+ public void processConflictingInstancesEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ String targetMetadataCollectionId,
+ TypeDefSummary targetTypeDefSummary,
+ String targetInstanceGUID,
+ String otherMetadataCollectionId,
+ InstanceProvenanceType otherOrigin,
+ TypeDefSummary otherTypeDefSummary,
+ String otherInstanceGUID,
+ String errorMessage)
+ {
+
+ }
+
+
+ /**
+ * An open metadata repository has detected an inconsistency in the versionName of the type used in an updated metadata
+ * instance compared to its stored versionName.
+ *
+ * @param sourceName - name of the source of the event. It may be the cohort name for incoming events or the
+ * local repository, or event mapper name.
+ * @param originatorMetadataCollectionId - metadata collection id of the repository reporting the conflicting instance
+ * @param originatorServerName - name of the server that the event came from.
+ * @param originatorServerType - type of server that the event came from.
+ * @param originatorOrganizationName - name of the organization that owns the server that sent the event.
+ * @param 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 copy of the instance's TypeDef
+ * @param errorMessage - description of the error.
+ */
+ public void processConflictingTypeEvent(String sourceName,
+ String originatorMetadataCollectionId,
+ String originatorServerName,
+ String originatorServerType,
+ String originatorOrganizationName,
+ String targetMetadataCollectionId,
+ TypeDefSummary targetTypeDefSummary,
+ String targetInstanceGUID,
+ TypeDefSummary otherTypeDefSummary,
+ String errorMessage)
+ {
+
+ }
+
+
+ /*
+ * =======================
+ * OMRSInstanceRetrievalEventProcessor
+ */
+
+
+ /**
+ * Pass an entity that has been retrieved from a remote open metadata repository so it can be validated and
+ * (if the rules permit) cached in the local repository.
+ *
+ * @param metadataCollectionId - unique identifier for the metadata from the remote repository
+ * @param entity - the retrieved entity.
+ * @return Validated and processed entity.
+ */
+ public EntityDetail processRetrievedEntity(String metadataCollectionId,
+ EntityDetail entity)
+ {
+ return entity;
+ }
+
+
+ /**
+ * Pass a list of entities that have been retrieved from a remote open metadata repository so they can be
+ * validated and (if the rules permit) cached in the local repository.
+ *
+ * @param metadataCollectionId - unique identifier for the metadata from the remote repository
+ * @param entities - the retrieved relationships
+ * @return the validated and processed relationships
+ */
+ public ArrayList<EntityDetail> processRetrievedEntities(String metadataCollectionId,
+ ArrayList<EntityDetail> entities)
+ {
+ return entities;
+ }
+
+
+ /**
+ * Pass a relationship that has been retrieved from a remote open metadata repository so it can be validated and
+ * (if the rules permit) cached in the local repository.
+ *
+ * @param metadataCollectionId - unique identifier for the metadata from the remote repository
+ * @param relationship - the retrieved relationship
+ * @return the validated and processed relationship
+ */
+ public Relationship processRetrievedRelationship(String metadataCollectionId,
+ Relationship relationship)
+ {
+ return relationship;
+ }
+
+
+ /**
+ * Pass a list of relationships that have been retrieved from a remote open metadata repository so they can be
+ * validated and (if the rules permit) cached in the local repository.
+ *
+ * @param metadataCollectionId - unique identifier for the metadata from the remote repository
+ * @param relationships - the list of retrieved relationships
+ * @return the validated and processed relationships
+ */
+ public ArrayList<Relationship> processRetrievedRelationships(String metadataCollectionId,
+ ArrayList<Relationship> relationships)
+ {
+ return relationships;
+ }
+}