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/01/27 00:41:42 UTC
[7/7] atlas git commit: ATLAS-1095:final code drop for OCF
ATLAS-1095:final code drop for OCF
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/cbfdd7fc
Tree: http://git-wip-us.apache.org/repos/asf/atlas/tree/cbfdd7fc
Diff: http://git-wip-us.apache.org/repos/asf/atlas/diff/cbfdd7fc
Branch: refs/heads/master
Commit: cbfdd7fcc2ccb011c6f3000e3cb7a9de79268445
Parents: 804c463
Author: Mandy Chessell <ma...@uk.ibm.com>
Authored: Fri Jan 19 09:27:26 2018 +0000
Committer: David Radley <da...@uk.ibm.com>
Committed: Sat Jan 27 00:40:56 2018 +0000
----------------------------------------------------------------------
om-fwk-ocf/README.md | 85 +++++
om-fwk-ocf/pom.xml | 64 ++++
.../java/org/apache/atlas/ocf/Connector.java | 121 ++++++
.../org/apache/atlas/ocf/ConnectorBase.java | 220 +++++++++++
.../org/apache/atlas/ocf/ConnectorBroker.java | 357 ++++++++++++++++++
.../org/apache/atlas/ocf/ConnectorProvider.java | 49 +++
.../apache/atlas/ocf/ConnectorProviderBase.java | 323 ++++++++++++++++
.../ocf/ffdc/ConnectionCheckedException.java | 78 ++++
.../ocf/ffdc/ConnectorCheckedException.java | 76 ++++
.../atlas/ocf/ffdc/OCFCheckedExceptionBase.java | 178 +++++++++
.../org/apache/atlas/ocf/ffdc/OCFErrorCode.java | 270 +++++++++++++
.../atlas/ocf/ffdc/OCFRuntimeException.java | 190 ++++++++++
.../atlas/ocf/ffdc/PropertyServerException.java | 77 ++++
.../java/org/apache/atlas/ocf/ffdc/README.md | 46 +++
.../ocf/properties/AdditionalProperties.java | 167 ++++++++
.../apache/atlas/ocf/properties/Annotation.java | 377 +++++++++++++++++++
.../atlas/ocf/properties/AnnotationStatus.java | 104 +++++
.../atlas/ocf/properties/Annotations.java | 128 +++++++
.../atlas/ocf/properties/AssetDescriptor.java | 166 ++++++++
.../atlas/ocf/properties/AssetDetail.java | 332 ++++++++++++++++
.../atlas/ocf/properties/AssetPropertyBase.java | 140 +++++++
.../properties/AssetPropertyIteratorBase.java | 107 ++++++
.../atlas/ocf/properties/AssetSummary.java | 253 +++++++++++++
.../atlas/ocf/properties/AssetUniverse.java | 338 +++++++++++++++++
.../atlas/ocf/properties/Certification.java | 303 +++++++++++++++
.../atlas/ocf/properties/Certifications.java | 128 +++++++
.../atlas/ocf/properties/Classification.java | 175 +++++++++
.../atlas/ocf/properties/Classifications.java | 128 +++++++
.../apache/atlas/ocf/properties/Comment.java | 177 +++++++++
.../atlas/ocf/properties/CommentType.java | 102 +++++
.../apache/atlas/ocf/properties/Comments.java | 127 +++++++
.../properties/ConnectedAssetProperties.java | 137 +++++++
.../apache/atlas/ocf/properties/Connection.java | 364 ++++++++++++++++++
.../atlas/ocf/properties/Connections.java | 127 +++++++
.../atlas/ocf/properties/ConnectorType.java | 221 +++++++++++
.../ocf/properties/DerivedSchemaElement.java | 169 +++++++++
.../atlas/ocf/properties/ElementHeader.java | 161 ++++++++
.../atlas/ocf/properties/ElementOrigin.java | 134 +++++++
.../atlas/ocf/properties/ElementType.java | 182 +++++++++
.../ocf/properties/EmbeddedConnection.java | 131 +++++++
.../ocf/properties/EmbeddedConnections.java | 127 +++++++
.../apache/atlas/ocf/properties/Endpoint.java | 294 +++++++++++++++
.../ocf/properties/ExternalIdentifier.java | 215 +++++++++++
.../ocf/properties/ExternalIdentifiers.java | 127 +++++++
.../atlas/ocf/properties/ExternalReference.java | 193 ++++++++++
.../ocf/properties/ExternalReferences.java | 127 +++++++
.../apache/atlas/ocf/properties/Feedback.java | 192 ++++++++++
.../atlas/ocf/properties/InformalTag.java | 196 ++++++++++
.../atlas/ocf/properties/InformalTags.java | 127 +++++++
.../apache/atlas/ocf/properties/KeyPattern.java | 104 +++++
.../apache/atlas/ocf/properties/License.java | 299 +++++++++++++++
.../apache/atlas/ocf/properties/Licenses.java | 127 +++++++
.../org/apache/atlas/ocf/properties/Like.java | 102 +++++
.../org/apache/atlas/ocf/properties/Likes.java | 127 +++++++
.../apache/atlas/ocf/properties/Lineage.java | 77 ++++
.../apache/atlas/ocf/properties/Location.java | 124 ++++++
.../apache/atlas/ocf/properties/Locations.java | 127 +++++++
.../atlas/ocf/properties/MapSchemaElement.java | 170 +++++++++
.../apache/atlas/ocf/properties/Meaning.java | 131 +++++++
.../apache/atlas/ocf/properties/Meanings.java | 127 +++++++
.../org/apache/atlas/ocf/properties/Note.java | 155 ++++++++
.../apache/atlas/ocf/properties/NoteLog.java | 161 ++++++++
.../apache/atlas/ocf/properties/NoteLogs.java | 127 +++++++
.../org/apache/atlas/ocf/properties/Notes.java | 127 +++++++
.../atlas/ocf/properties/PagingIterator.java | 337 +++++++++++++++++
.../ocf/properties/PrimitiveSchemaElement.java | 150 ++++++++
.../atlas/ocf/properties/PropertyBase.java | 113 ++++++
.../org/apache/atlas/ocf/properties/Rating.java | 142 +++++++
.../apache/atlas/ocf/properties/Ratings.java | 128 +++++++
.../atlas/ocf/properties/Referenceable.java | 176 +++++++++
.../atlas/ocf/properties/RelatedAsset.java | 167 ++++++++
.../ocf/properties/RelatedAssetProperties.java | 143 +++++++
.../atlas/ocf/properties/RelatedAssets.java | 127 +++++++
.../ocf/properties/RelatedMediaReference.java | 240 ++++++++++++
.../ocf/properties/RelatedMediaReferences.java | 127 +++++++
.../atlas/ocf/properties/RelatedMediaType.java | 92 +++++
.../atlas/ocf/properties/RelatedMediaUsage.java | 102 +++++
.../org/apache/atlas/ocf/properties/Schema.java | 245 ++++++++++++
.../atlas/ocf/properties/SchemaAttribute.java | 147 ++++++++
.../atlas/ocf/properties/SchemaAttributes.java | 128 +++++++
.../atlas/ocf/properties/SchemaElement.java | 173 +++++++++
.../properties/SchemaImplementationQueries.java | 129 +++++++
.../properties/SchemaImplementationQuery.java | 141 +++++++
.../apache/atlas/ocf/properties/SchemaLink.java | 172 +++++++++
.../atlas/ocf/properties/SchemaLinks.java | 128 +++++++
.../apache/atlas/ocf/properties/SchemaType.java | 97 +++++
.../apache/atlas/ocf/properties/StarRating.java | 103 +++++
.../atlas/ocf/properties/VirtualConnection.java | 152 ++++++++
pom.xml | 13 +
89 files changed, 14367 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/atlas/blob/cbfdd7fc/om-fwk-ocf/README.md
----------------------------------------------------------------------
diff --git a/om-fwk-ocf/README.md b/om-fwk-ocf/README.md
new file mode 100644
index 0000000..2048d31
--- /dev/null
+++ b/om-fwk-ocf/README.md
@@ -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
+ ~
+ ~ 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 Connector Framework (OCF)
+
+The OCF, as the name suggests, is an open framework for supporting connectors.
+Connectors support access to remote assets such as data sets, APIs and software components.
+OCF Connectors also provide access to metadata about the asset and they may call the Governance Action Framework
+GAF to execute appropriate governance actions related to the use of these assets in real-time.
+
+## Terminology
+
+There are a number of key components within the OCF:
+
+* **Connector** - this is a Java object for accessing an asset and its
+related metadata and governance functions.
+
+* **Connection** - this is a Java object containing the properties needed to
+create a connector instance.
+Connection properties are typically managed as metadata entities in the metadata
+repository but they can also be manually populated.
+Connections have 2 sub-objects:
+ * **ConnectorType** - this is a Java object that describes the type of
+ the connector, including the Java implementation class of its connector provider (see below).
+ * **Endpoint** - this is the Java object that describes the server endpoint where the asset is accessed from.
+
+* **Connector Broker** - this is a generic factory for all OCF connectors.
+
+* **Connector Provider** - this is a factory for a specific type of connector.
+It is used by the Connector Broker.
+
+* **Connected Asset** - this is the asset that the connector is accessing. It is hosted on a server
+and the connector makes the remote calls necessary to retrieve, update, delete the asset itself.
+The connector also includes an API to retrieve the metadata properties about the connected asset.
+
+## Open Metadata Type Models
+
+Model 0040 defines the structure of an Endpoint and
+model 0201 defines the structures for Connections and Connector Types.
+Model 0205 defines the linkage between the connection and the connected asset.
+
+## Java Implementation
+
+The OCF provides the interface schema and base class implementation for these components.
+The Java implementation is located in packages org.apache.atlas.ocf.*:
+
+* **org.apache.atlas.ocf** - Java interface and base classes for Connector and Connector Provider
+plus the implementation of the Connector Broker.
+
+* **org.apache.atlas.ocf.ffdc** - Implementation of the OCF's error codes and exceptions.
+
+* **org.apache.atlas.ocf.properties** - Implementation of the properties for connections and connected assets.
+These are simple POJO objects.
+
+## Related Modules
+
+The ConnectedAsset OMAS (omas-connectedasset) supports the retrieval
+of connection and connected asset properties from the open metadata
+repository/repositories.
+
+The AssetConsumer OMAS (omas-assetconsumer) embeds the OCF to provide
+client-side support for connectors.
+
+The Open Metadata Repository Services (omrs) provides implementations
+of OCF connectors for accessing open metadata repository servers.
+These connectors are collectively called the OMRS Connectors.
+
+## Wiki References
+
+Further information on the OCF at: https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=69408729
http://git-wip-us.apache.org/repos/asf/atlas/blob/cbfdd7fc/om-fwk-ocf/pom.xml
----------------------------------------------------------------------
diff --git a/om-fwk-ocf/pom.xml b/om-fwk-ocf/pom.xml
new file mode 100644
index 0000000..9da5c1a
--- /dev/null
+++ b/om-fwk-ocf/pom.xml
@@ -0,0 +1,64 @@
+<?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/xsd/maven-4.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>om-fwk-ocf</artifactId>
+
+ <name>Open Connector Framework (OCF)</name>
+ <description>Open Connector Framework (OCF) interfaces and implementation for building metadata and governance enabled connectors.</description>
+
+ <packaging>jar</packaging>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ <scope>test</scope>
+ </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/cbfdd7fc/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/Connector.java
----------------------------------------------------------------------
diff --git a/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/Connector.java b/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/Connector.java
new file mode 100644
index 0000000..1ae7dd6
--- /dev/null
+++ b/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/Connector.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
+ *
+ * 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.
+ */
+
+package org.apache.atlas.ocf;
+
+import org.apache.atlas.ocf.ffdc.ConnectorCheckedException;
+import org.apache.atlas.ocf.ffdc.PropertyServerException;
+import org.apache.atlas.ocf.properties.ConnectedAssetProperties;
+import org.apache.atlas.ocf.properties.Connection;
+
+/**
+ * <p>
+ * The Connector is the interface for all connector instances. Connectors are client-side interfaces to assets
+ * such as data stores, data sets, APIs, analytical functions. They handle the communication with the server that
+ * hosts the assets, along with the communication with the metadata server to serve up metadata (properties) about
+ * the assets.
+ * </p>
+ * <p>
+ * Each connector implementation is paired with a connector provider. The connector provider is the factory for
+ * connector instances.
+ * </p>
+ * <p>
+ * The Connector interface defines that a connector instance should be able to return a unique
+ * identifier, a connection object and a metadata object called ConnectedAssetProperties.
+ * </p>
+ * <p>
+ * Each specific implementation of a connector then extends the Connector interface to add the methods to work with the
+ * particular type of asset it supports. For example, a JDBC connector would add the standard JDBC SQL interface, the
+ * OMRS Connectors add the metadata repository management APIs...
+ * </p>
+ * <p>
+ * The initialize() method is called by the Connector Provider to set up the connector instance Id and the
+ * Connection properties for the connector as part of its construction process.
+ * </p>
+ * <p>
+ * ConnectedAssetProperties provides descriptive properties about the asset that the connector is accessing.
+ * It is supplied to the connector later during its initialization through the initializeConnectedAssetProperties() method.
+ * See AssetConsumer OMAS for an example of this.
+ * </p>
+ * <p>
+ * Both the connector and the connector provider have base classes (ConnectorBase and
+ * ConnectorProviderBase respectively) that implement all of the standard methods. The connector developer extends
+ * these classes to add the specific methods to manage the asset and configure the base classes.
+ * </p>
+ */
+public abstract class Connector
+{
+ /**
+ * Call made by the ConnectorProvider to initialize the Connector with the base services.
+ *
+ * @param connectorInstanceId - unique id for the connector instance - useful for messages etc
+ * @param connection - POJO for the configuration used to create the connector.
+ */
+ public abstract void initialize(String connectorInstanceId,
+ Connection connection);
+
+
+ /**
+ * Returns the unique connector instance id that assigned to the connector instance when it was created.
+ * It is useful for error and audit messages.
+ *
+ * @return guid for the connector instance
+ */
+ public abstract String getConnectorInstanceId();
+
+
+ /**
+ * Returns the connection object that was used to create the connector instance. Its contents are never refreshed
+ * during the lifetime of a connector instance even if the connection information is updated or removed from
+ * the originating metadata repository.
+ *
+ * @return connection object
+ */
+ public abstract Connection getConnection();
+
+
+ /**
+ * Set up the connected asset properties object. This provides the known metadata properties stored in one or more
+ * metadata repositories. The implementation of the connected asset properties object is free to determine when
+ * the properties are populated. It may be as lazy as whenever getConnectedAssetProperties() is called.
+ *
+ * @param connectedAssetProperties - properties of the connected asset
+ */
+ public abstract void initializeConnectedAssetProperties(ConnectedAssetProperties connectedAssetProperties);
+
+
+ /**
+ * Returns the properties that contain the metadata for the asset. The asset metadata is retrieved from the
+ * metadata repository and cached in the ConnectedAssetProperties object each time the getConnectedAssetProperties
+ * method is requested by the caller. Once the ConnectedAssetProperties object has the metadata cached, it can be
+ * used to access the asset property values many times without a return to the metadata repository.
+ * The cache of metadata can be refreshed simply by calling this getConnectedAssetProperties() method again.
+ *
+ * @return ConnectedAssetProperties - connected asset properties
+ * @throws PropertyServerException - indicates a problem retrieving properties from a metadata repository
+ */
+ public abstract ConnectedAssetProperties getConnectedAssetProperties() throws PropertyServerException;
+
+
+ /**
+ * Free up any resources held since the connector is no longer needed.
+ *
+ * @throws ConnectorCheckedException - there is a problem disconnecting the connector.
+ */
+ public abstract void disconnect() throws ConnectorCheckedException;
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/atlas/blob/cbfdd7fc/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
new file mode 100644
index 0000000..cc2e430
--- /dev/null
+++ b/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/ConnectorBase.java
@@ -0,0 +1,220 @@
+/*
+ * 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.ocf;
+
+import org.apache.atlas.ocf.ffdc.PropertyServerException;
+import org.apache.atlas.ocf.properties.ConnectedAssetProperties;
+import org.apache.atlas.ocf.properties.Connection;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.UUID;
+
+/**
+ * The ConnectorBase is an implementation of the Connector interface.
+ *
+ * Connectors are client-side interfaces to assets such as data stores, data sets, APIs, analytical functions.
+ * They handle the communication with the server that hosts the assets, along with the communication with the
+ * metadata server to serve up metadata about the assets, and support for an audit log for the caller to log its
+ * activity.
+ *
+ * Each connector implementation is paired with a connector provider. The connector provider is the factory for
+ * connector instances.
+ *
+ * The Connector interface defines that a connector instance should be able to return a unique
+ * identifier, a connection object and a metadata properties object for its connected asset.
+ * These are supplied to the connector during its initialization.
+ *
+ * The ConnectorBase base class implements all of the methods required by the Connector interface.
+ * Each specific implementation of a connector then extends this interface to add the methods to work with the
+ * particular type of asset it supports. For example, a JDBC connector would add the standard JDBC SQL interface, the
+ * OMRS Connectors add the metadata repository management APIs...
+ */
+public abstract class ConnectorBase extends Connector
+{
+ protected String connectorInstanceId = null;
+ protected Connection connection = null;
+ protected ConnectedAssetProperties connectedAssetProperties = null;
+
+ private static final int hashCode = UUID.randomUUID().hashCode();
+ private static final Logger log = LoggerFactory.getLogger(ConnectorBase.class);
+
+ /**
+ * Typical Constructor - Connectors should always have a constructor requiring no parameters and perform
+ * initialization in the initialize method.
+ */
+ public ConnectorBase()
+ {
+ /*
+ * Nothing to do - real initialization happens in the initialize() method.
+ * This pattern is used to make it possible for ConnectorBrokerBase to support the dynamic loading and
+ * instantiation of arbitrary connector instances without needing to know the specifics of their constructor
+ * methods
+ */
+
+ if (log.isDebugEnabled())
+ {
+ log.debug("New Connector Requested");
+ }
+ }
+
+
+ /**
+ * Call made by the ConnectorProvider to initialize the Connector with the base services.
+ *
+ * @param connectorInstanceId - unique id for the connector instance - useful for messages etc
+ * @param connection - POJO for the configuration used to create the connector.
+ */
+ public void initialize(String connectorInstanceId,
+ Connection connection)
+ {
+ this.connectorInstanceId = connectorInstanceId;
+ this.connection = connection;
+
+ if (log.isDebugEnabled())
+ {
+ log.debug("New Connector initialized: " + connectorInstanceId + ", " + connection.getConnectionName());
+ }
+ }
+
+
+ /**
+ * Returns the unique connector instance id that assigned to the connector instance when it was created.
+ * It is useful for error and audit messages.
+ *
+ * @return guid for the connector instance
+ */
+ public String getConnectorInstanceId()
+ {
+ return connectorInstanceId;
+ }
+
+
+ /**
+ * Returns the connection object that was used to create the connector instance. Its contents are never refreshed
+ * during the lifetime of the connector instance, even if the connection information is updated or removed
+ * from the originating metadata repository.
+ *
+ * @return connection object
+ */
+ public Connection getConnection()
+ {
+ return connection;
+ }
+
+
+ /**
+ * Set up the connected asset properties object. This provides the known metadata properties stored in one or more
+ * metadata repositories. The properties are populated whenever getConnectedAssetProperties() is called.
+ *
+ * @param connectedAssetProperties - properties of the connected asset
+ */
+ public void initializeConnectedAssetProperties(ConnectedAssetProperties connectedAssetProperties)
+ {
+ this.connectedAssetProperties = connectedAssetProperties;
+ }
+
+
+ /**
+ * Returns the properties that contain the metadata for the asset. The asset metadata is retrieved from the
+ * metadata repository and cached in the ConnectedAssetProperties object each time the getConnectedAssetProperties
+ * method is requested by the caller. Once the ConnectedAssetProperties object has the metadata cached, it can be
+ * used to access the asset property values many times without a return to the metadata repository.
+ * The cache of metadata can be refreshed simply by calling this getConnectedAssetProperties() method again.
+ *
+ * @return ConnectedAssetProperties - connected asset properties
+ * @throws PropertyServerException - indicates a problem retrieving properties from a metadata repository
+ */
+ public ConnectedAssetProperties getConnectedAssetProperties() throws PropertyServerException
+ {
+ if (log.isDebugEnabled())
+ {
+ log.debug("ConnectedAssetProperties requested: " + connectorInstanceId + ", " + connection.getConnectionName());
+ }
+
+ if (connectedAssetProperties != null)
+ {
+ connectedAssetProperties.refresh();
+ }
+
+ return connectedAssetProperties;
+ }
+
+
+ /**
+ * Provide a common implementation of hashCode for all OCF Connector objects. The UUID is unique and
+ * is randomly assigned and so its hashCode is as good as anything to describe the hash code of the connector
+ * object.
+ *
+ * @return random UUID as hashcode
+ */
+ public int hashCode()
+ {
+ return hashCode;
+ }
+
+
+ /**
+ * Provide a common implementation of equals for all OCF Connector Provider objects. The UUID is unique and
+ * is randomly assigned and so its hashCode is as good as anything to evaluate the equality of the connector
+ * provider object.
+ *
+ * @param object - object to test
+ * @return boolean flag
+ */
+ @Override
+ public boolean equals(Object object)
+ {
+ if (this == object)
+ {
+ return true;
+ }
+ if (object == null || getClass() != object.getClass())
+ {
+ return false;
+ }
+
+ ConnectorBase that = (ConnectorBase) object;
+
+ if (connectorInstanceId != null ? !connectorInstanceId.equals(that.connectorInstanceId) : that.connectorInstanceId != null)
+ {
+ return false;
+ }
+ if (connection != null ? !connection.equals(that.connection) : that.connection != null)
+ {
+ return false;
+ }
+ return connectedAssetProperties != null ? connectedAssetProperties.equals(that.connectedAssetProperties) : that.connectedAssetProperties == null;
+ }
+
+
+ /**
+ * Standard toString method.
+ *
+ * @return print out of variables in a JSON-style
+ */
+ @Override
+ public String toString()
+ {
+ return "ConnectorBase{" +
+ "connectorInstanceId='" + connectorInstanceId + '\'' +
+ ", connection=" + connection +
+ ", connectedAssetProperties=" + connectedAssetProperties +
+ '}';
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/atlas/blob/cbfdd7fc/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/ConnectorBroker.java
----------------------------------------------------------------------
diff --git a/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/ConnectorBroker.java b/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/ConnectorBroker.java
new file mode 100644
index 0000000..18fec9a
--- /dev/null
+++ b/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/ConnectorBroker.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.ocf;
+
+import org.apache.atlas.ocf.ffdc.*;
+import org.apache.atlas.ocf.properties.Connection;
+import org.apache.atlas.ocf.properties.ConnectorType;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.UUID;
+
+/**
+ * The ConnectorBroker is a generic factory for Open Connector Framework (OCF) Connectors.
+ * The OCF provides a default implementation because all of the implementation that is specific to a
+ * particular type of connector is delegated to the connector provider specified in the connection.
+ */
+public class ConnectorBroker
+{
+ private static final Logger log = LoggerFactory.getLogger(ConnectorBroker.class);
+ private final int hashCode = UUID.randomUUID().hashCode();
+
+
+ /**
+ * Typical constructor
+ */
+ public ConnectorBroker()
+ {
+ /* Nothing to do */
+ }
+
+
+ /**
+ * Creates a new instance of a connector using the name of the connector provider in the supplied connection.
+ *
+ * @param connection - properties for the connector and connector provider.
+ * @return new connector instance.
+ * @throws ConnectionCheckedException - an error with the connection.
+ * @throws ConnectorCheckedException - an error initializing the connector.
+ */
+ public Connector getConnector(Connection connection) throws ConnectionCheckedException, ConnectorCheckedException
+ {
+ ConnectorProvider connectorProvider = null;
+ Connector connectorInstance = null;
+
+ if (log.isDebugEnabled())
+ {
+ log.debug("==> ConnectorBroker.getConnector()");
+ }
+
+ if (connection == null)
+ {
+ /*
+ * It is not possible to create a connector without a connection.
+ */
+ OCFErrorCode errorCode = OCFErrorCode.NULL_CONNECTION;
+ String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage();
+
+ throw new ConnectionCheckedException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ "getConnector",
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+
+
+ /*
+ * Within the connection is a structure called the connector type. This defines the factory for a new
+ * connector instance. This factory is called the Connector Provider.
+ */
+ ConnectorType requestedConnectorType = connection.getConnectorType();
+
+ if (requestedConnectorType == null)
+ {
+ /*
+ * It is not possible to create a connector without a connector type since it
+ * holds the name of the connector provider's Java class. Build an exception.
+ */
+ OCFErrorCode errorCode = OCFErrorCode.NULL_CONNECTOR_TYPE;
+ String connectionName = connection.getConnectionName();
+ String errorMessage = errorCode.getErrorMessageId()
+ + errorCode.getFormattedErrorMessage(connectionName);
+
+ throw new ConnectionCheckedException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ "getConnector",
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+
+
+ /*
+ * The connection has a valid connector type so the next step is to extract the class name for the
+ * connector provider. This is the specialized factory for the connector.
+ */
+ String connectorProviderClassName = requestedConnectorType.getConnectorProviderClassName();
+
+ if (connectorProviderClassName == null)
+ {
+ /*
+ * The connector provider class name is blank so it is not possible to create the
+ * connector provider. Throw an exception.
+ */
+ OCFErrorCode errorCode = OCFErrorCode.NULL_CONNECTOR_PROVIDER;
+ String connectionName = connection.getConnectionName();
+ String errorMessage = errorCode.getErrorMessageId()
+ + errorCode.getFormattedErrorMessage(connectionName);
+
+ throw new ConnectionCheckedException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ "getConnector",
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+
+
+ /*
+ * Extract the class for the connector provider and then create a connector provider object.
+ * These actions may reveal that the class is not known to local JVM (ClassNotFound) or
+ * the class is there but its dependencies are not (LinkageError) or it is there and loads
+ * but it is not a connector provider (ClassCastException). Each of these error conditions
+ * results in a connection error exception that hopefully guides the consumer to correct
+ * the config and/or setup error.
+ */
+ try
+ {
+ Class connectorProviderClass = Class.forName(connectorProviderClassName);
+ Object potentialConnectorProvider = connectorProviderClass.newInstance();
+
+ connectorProvider = (ConnectorProvider)potentialConnectorProvider;
+ }
+ catch (ClassNotFoundException classException)
+ {
+ /*
+ * Wrap exception in the ConnectionCheckedException with a suitable message
+ */
+ OCFErrorCode errorCode = OCFErrorCode.UNKNOWN_CONNECTOR_PROVIDER;
+ String connectionName = connection.getConnectionName();
+ String errorMessage = errorCode.getErrorMessageId()
+ + errorCode.getFormattedErrorMessage(connectorProviderClassName, connectionName);
+
+ throw new ConnectionCheckedException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ "getConnector",
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction(),
+ classException);
+ }
+ catch (LinkageError linkageError)
+ {
+ /*
+ * Wrap linkage error in an exception
+ */
+ OCFErrorCode errorCode = OCFErrorCode.INCOMPLETE_CONNECTOR_PROVIDER;
+ String connectionName = connection.getConnectionName();
+ String errorMessage = errorCode.getErrorMessageId()
+ + errorCode.getFormattedErrorMessage(connectorProviderClassName, connectionName);
+
+ throw new ConnectionCheckedException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ "getConnector",
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction(),
+ linkageError);
+ }
+ catch (ClassCastException castException)
+ {
+ /*
+ * Wrap class cast exception in a connection exception with error message to say that
+ */
+ OCFErrorCode errorCode = OCFErrorCode.NOT_CONNECTOR_PROVIDER;
+ String connectionName = connection.getConnectionName();
+ String errorMessage = errorCode.getErrorMessageId()
+ + errorCode.getFormattedErrorMessage(connectorProviderClassName, connectionName);
+
+ throw new ConnectionCheckedException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ "getConnector",
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction(),
+ castException);
+ }
+ catch (Throwable unexpectedSomething)
+ {
+ /*
+ * Wrap throwable in a connection exception with error message to say that there was a problem with
+ * the connector provider.
+ */
+ OCFErrorCode errorCode = OCFErrorCode.INVALID_CONNECTOR_PROVIDER;
+ String connectionName = connection.getConnectionName();
+ String errorMessage = errorCode.getErrorMessageId()
+ + errorCode.getFormattedErrorMessage(connectorProviderClassName, connectionName);
+
+ throw new ConnectionCheckedException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ "getConnector",
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction(),
+ unexpectedSomething);
+ }
+
+
+ /*
+ * At this point we hopefully have a valid connector provider so all that is left to do is call
+ * it to get the connector instance. This is done in a different try ... catch block from the
+ * instantiation of the connector provider so we can separate errors in the Connection from
+ * errors generated in the Connector Provider, since both classes are
+ * potentially code from a source outside of Apache Atlas.
+ */
+ try
+ {
+ connectorInstance = connectorProvider.getConnector(connection);
+ }
+ catch (ConnectionCheckedException connectionError)
+ {
+ /*
+ * The connector provider has already provided first failure data capture in a ConnectionCheckedException.
+ * This exception is rethrown to the caller.
+ */
+ throw connectionError;
+ }
+ catch (ConnectorCheckedException connectorError)
+ {
+ /*
+ * The connector provider has already provided first failure data capture in a ConnectorCheckedException.
+ * This exception is rethrown to the caller.
+ */
+ throw connectorError;
+ }
+ catch (Throwable unexpectedSomething)
+ {
+ /*
+ * The connector provider threw an unexpected runtime exception or error. This is wrapped in a
+ * ConnectorError and thrown to caller.
+ */
+ OCFErrorCode errorCode = OCFErrorCode.CAUGHT_EXCEPTION;
+ String errorMessage = errorCode.getErrorMessageId()
+ + errorCode.getFormattedErrorMessage();
+
+ throw new ConnectorCheckedException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ "getConnector",
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction(),
+ unexpectedSomething);
+ }
+
+
+ /*
+ * If the connector provider has returned a null connector with no exception then raise a generic exception
+ * since something has gone wrong.
+ */
+ if (connectorInstance == null)
+ {
+ /*
+ * Build and throw exception.
+ */
+ OCFErrorCode errorCode = OCFErrorCode.NULL_CONNECTOR;
+ String errorMessage = errorCode.getErrorMessageId()
+ + errorCode.getFormattedErrorMessage(connection.getConnectionName());
+
+ throw new OCFRuntimeException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ "getConnector",
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+
+ /*
+ * If we reach this point the connector provider has returned a connector that can be passed to the caller.
+ */
+
+ if (log.isDebugEnabled())
+ {
+ log.debug("New connector returned: " + connectorInstance.getConnectorInstanceId());
+ log.debug("Using Connection: " + connectorInstance.getConnection().getQualifiedName() + "(" + connectorInstance.getConnection().getDisplayName() + ")");
+ log.debug("<== ConnectorBroker.getConnector()");
+ }
+
+ return connectorInstance;
+ }
+
+
+ /**
+ * Provide an implementation of hashCode for all OCF Connector Broker objects. The UUID is unique and
+ * is randomly assigned and so its hashCode is as good as anything to describe the hash code of the connector
+ * broker object.
+ */
+ public int hashCode()
+ {
+ return hashCode;
+ }
+
+
+ /**
+ * Provide a common implementation of equals for all OCF Connector Broker objects. The UUID is unique and
+ * is randomly assigned and so its hashCode is as good as anything to evaluate the equality of the connector
+ * broker object.
+ *
+ * @param object - object to test
+ * @return boolean flag
+ */
+ @Override
+ public boolean equals(Object object)
+ {
+ if (this == object)
+ {
+ return true;
+ }
+ if (object == null || getClass() != object.getClass())
+ {
+ return false;
+ }
+
+ ConnectorBroker that = (ConnectorBroker) object;
+
+ return hashCode == that.hashCode;
+ }
+
+
+ /**
+ * Standard toString method.
+ *
+ * @return print out of variables in a JSON-style
+ */
+ @Override
+ public String toString()
+ {
+ return "ConnectorBroker{" +
+ "hashCode=" + hashCode +
+ '}';
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/atlas/blob/cbfdd7fc/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/ConnectorProvider.java
----------------------------------------------------------------------
diff --git a/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/ConnectorProvider.java b/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/ConnectorProvider.java
new file mode 100644
index 0000000..020b79c
--- /dev/null
+++ b/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/ConnectorProvider.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.ocf;
+
+import org.apache.atlas.ocf.ffdc.ConnectionCheckedException;
+import org.apache.atlas.ocf.ffdc.ConnectorCheckedException;
+import org.apache.atlas.ocf.properties.Connection;
+
+/**
+ * The ConnectorProvider is a formal plug-in interface for the Open Connector Framework (OCF). It provides a factory
+ * class for a specific type of connector. Therefore is it typical to find the ConnectorProvider and Connector
+ * implementation written as a pair.
+ *
+ * The ConnectorProvider uses the properties stored in a Connection object to initialize itself and its Connector instances.
+ * the Connection object has the endpoint properties for the server that the connector must communicate with
+ * as well as optional additional properties that may be needed for a particular type of connector.
+ *
+ * It is suggested that the ConnectorProvider validates the contents of the connection and throws
+ * ConnectionErrorExceptions if the connection has missing or invalid properties. If there are errors detected in the
+ * instantiations or initialization of the connector, then these should be thrown as ConnectorErrorExceptions.
+ */
+public abstract class ConnectorProvider
+{
+ /**
+ * Creates a new instance of a connector 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 abstract Connector getConnector(Connection connection) throws ConnectionCheckedException, ConnectorCheckedException;
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/atlas/blob/cbfdd7fc/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
new file mode 100644
index 0000000..fafd20c
--- /dev/null
+++ b/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/ConnectorProviderBase.java
@@ -0,0 +1,323 @@
+/*
+ * 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.ocf;
+
+import org.apache.atlas.ocf.properties.Connection;
+
+import org.apache.atlas.ocf.ffdc.ConnectionCheckedException;
+import org.apache.atlas.ocf.ffdc.ConnectorCheckedException;
+import org.apache.atlas.ocf.ffdc.OCFErrorCode;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.UUID;
+
+/**
+ * ConnectorProviderBase is a base class for a new connector provider. It manages all of the class loading
+ * for subclass implementations of the connector provider along with the generation of new connector guids.
+ *
+ * ConnectorProviderBase creates a connector instance with the class name from the private variable called
+ * connectorClassName. This class name is initialized to null. If the getConnector method is called when
+ * the connectorClassName is null, it throws ConnectorCheckedException.
+ * This is its default behaviour.
+ *
+ * To use the ConnectorProviderBase, create a new class that extends the ConnectorProviderBase class
+ * and in the constructor call super.setConnectorClassName("your connector's class name");
+ */
+public abstract class ConnectorProviderBase extends ConnectorProvider
+{
+ private String connectorClassName = null;
+
+ private final int hashCode = UUID.randomUUID().hashCode();
+
+ private static final Logger log = LoggerFactory.getLogger(ConnectorProviderBase.class);
+
+ /**
+ * Typical constructor
+ */
+ public ConnectorProviderBase ()
+ {
+ /*
+ * Nothing to do
+ */
+ }
+
+
+ /**
+ * 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();
+ }
+
+
+ /**
+ * Return the class name for the connector that the connector provider generates.
+ *
+ * @return connectorClassName - will be null initially.
+ */
+ public String getConnectorClassName()
+ {
+ return connectorClassName;
+ }
+
+
+ /**
+ * Update the class name for this connector provider.
+ *
+ * @param newConnectorClassName - this must be a valid Java class name for a class that implements the
+ * org.apache.atlas.ocf.Connector interface.
+ */
+ public void setConnectorClassName(String newConnectorClassName)
+ {
+ if (log.isDebugEnabled())
+ {
+ log.debug("Connector class name set: " + newConnectorClassName);
+ }
+
+ connectorClassName = newConnectorClassName;
+ }
+
+
+ /**
+ * Creates a new instance of a connector 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
+ {
+ Connector connector = null;
+ String guid = null;
+
+ if (log.isDebugEnabled())
+ {
+ log.debug("getConnector called");
+ }
+
+ if (connection == null)
+ {
+ /*
+ * It is not possible to create a connector without a connection.
+ */
+ OCFErrorCode errorCode = OCFErrorCode.NULL_CONNECTION;
+ String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage();
+
+ throw new ConnectionCheckedException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ "getConnector",
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+
+
+ /*
+ * Validate that a subclass (or external class) has set up the class name of the connector.
+ */
+ if (connectorClassName == null)
+ {
+ /*
+ * This instance of the connector provider is not initialised with the connector's class name so
+ * throw an exception because a connector can not be generated.
+ */
+ OCFErrorCode errorCode = OCFErrorCode.NULL_CONNECTOR_CLASS;
+ String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage();
+
+ throw new ConnectionCheckedException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ "getConnector",
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction());
+ }
+
+
+ /*
+ * Generate a new GUID for the connector.
+ */
+ guid = getNewConnectorGUID();
+
+
+ /*
+ * Create a new instance of the connector and initialize it with the guid and connection.
+ */
+ try
+ {
+ Class connectorClass = Class.forName(connectorClassName);
+ Object potentialConnector = connectorClass.newInstance();
+
+ connector = (Connector)potentialConnector;
+ connector.initialize(guid, connection);
+ }
+ catch (ClassNotFoundException classException)
+ {
+ /*
+ * Wrap exception in the ConnectionCheckedException with a suitable message
+ */
+ OCFErrorCode errorCode = OCFErrorCode.UNKNOWN_CONNECTOR;
+ String connectionName = connection.getConnectionName();
+ String errorMessage = errorCode.getErrorMessageId()
+ + errorCode.getFormattedErrorMessage(connectorClassName, connectionName);
+
+ throw new ConnectionCheckedException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ "getConnector",
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction(),
+ classException);
+ }
+ catch (LinkageError linkageError)
+ {
+ /*
+ * Wrap linkage error in an exception
+ */
+ OCFErrorCode errorCode = OCFErrorCode.INCOMPLETE_CONNECTOR;
+ String connectionName = connection.getConnectionName();
+ String errorMessage = errorCode.getErrorMessageId()
+ + errorCode.getFormattedErrorMessage(connectorClassName, connectionName);
+
+ throw new ConnectionCheckedException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ "getConnector",
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction(),
+ linkageError);
+ }
+ catch (ClassCastException castException)
+ {
+ /*
+ * Wrap class cast exception in a connection exception with error message to say that
+ */
+ OCFErrorCode errorCode = OCFErrorCode.NOT_CONNECTOR;
+ String connectionName = connection.getConnectionName();
+ String errorMessage = errorCode.getErrorMessageId()
+ + errorCode.getFormattedErrorMessage(connectorClassName, connectionName);
+
+ throw new ConnectionCheckedException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ "getConnector",
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction(),
+ castException);
+ }
+ catch (Throwable unexpectedSomething)
+ {
+ /*
+ * Wrap throwable in a connection exception with error message to say that there was a problem with
+ * the connector implementation.
+ */
+ OCFErrorCode errorCode = OCFErrorCode.INVALID_CONNECTOR;
+ String connectionName = connection.getConnectionName();
+ String errorMessage = errorCode.getErrorMessageId()
+ + errorCode.getFormattedErrorMessage(connectorClassName, connectionName);
+
+ throw new ConnectionCheckedException(errorCode.getHTTPErrorCode(),
+ this.getClass().getName(),
+ "getConnector",
+ errorMessage,
+ errorCode.getSystemAction(),
+ errorCode.getUserAction(),
+ unexpectedSomething);
+ }
+
+
+ /*
+ * Return the initialized connector ready for use.
+ */
+
+ if (log.isDebugEnabled())
+ {
+ log.debug("getConnector returns: " + connector.getConnectorInstanceId() + ", " + connection.getConnectionName());
+ }
+
+ return connector;
+ }
+
+
+ /**
+ * Provide a common implementation of hashCode for all OCF Connector Provider objects. The UUID is unique and
+ * is randomly assigned and so its hashCode is as good as anything to describe the hash code of the properties
+ * object.
+ *
+ * @return random UUID as hashcode
+ */
+ public int hashCode()
+ {
+ return hashCode;
+ }
+
+
+ /**
+ * Provide a common implementation of equals for all OCF Connector Provider objects. The UUID is unique and
+ * is randomly assigned and so its hashCode is as good as anything to evaluate the equality of the connector
+ * provider object.
+ *
+ * @param object - object to test
+ * @return boolean flag
+ */
+ @Override
+ public boolean equals(Object object)
+ {
+ if (this == object)
+ {
+ return true;
+ }
+ if (object == null || getClass() != object.getClass())
+ {
+ return false;
+ }
+
+ ConnectorProviderBase that = (ConnectorProviderBase) object;
+
+ if (hashCode != that.hashCode)
+ {
+ return false;
+ }
+
+ return connectorClassName != null ? connectorClassName.equals(that.connectorClassName) : that.connectorClassName == null;
+ }
+
+
+ /**
+ * Standard toString method.
+ *
+ * @return print out of variables in a JSON-style
+ */
+ @Override
+ public String toString()
+ {
+ return "ConnectorProviderBase{" +
+ "connectorClassName='" + connectorClassName + '\'' +
+ ", hashCode=" + hashCode +
+ '}';
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/atlas/blob/cbfdd7fc/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/ffdc/ConnectionCheckedException.java
----------------------------------------------------------------------
diff --git a/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/ffdc/ConnectionCheckedException.java b/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/ffdc/ConnectionCheckedException.java
new file mode 100644
index 0000000..ef28352
--- /dev/null
+++ b/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/ffdc/ConnectionCheckedException.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.ocf.ffdc;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * ConnectionCheckedException provides a checked exception for reporting errors found in connection objects.
+ * Typically these errors are configuration errors that can be fixed by an administrator or power user.
+ * The connection object has a complex structure and the aim of this exception, in conjunction with
+ * OCFErrorCode, is to identify exactly what is wrong with the contents of the connection object
+ * and the consequences of this error.
+ */
+public class ConnectionCheckedException extends OCFCheckedExceptionBase
+{
+ private static final Logger log = LoggerFactory.getLogger(ConnectionCheckedException.class);
+
+ /**
+ * This is the typical constructor for creating a ConnectionCheckedException. 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 ConnectionCheckedException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction)
+ {
+ super(httpCode, className, actionDescription, errorMessage, systemAction, userAction);
+
+ if (log.isDebugEnabled())
+ {
+ log.debug(httpCode + ", " + className + ", " + actionDescription);
+ }
+ }
+
+
+ /**
+ * This constructor is used when an unexpected exception has been caught that needs to be wrapped in a
+ * ConnectionCheckedException 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 caughtError the exception/error that caused this exception to be raised
+ */
+ public ConnectionCheckedException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction, Throwable caughtError)
+ {
+ super(httpCode, className, actionDescription, errorMessage, systemAction, userAction, caughtError);
+
+ if (log.isDebugEnabled())
+ {
+ log.debug(httpCode + ", " + className + ", " + actionDescription + ", " + caughtError.toString());
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/atlas/blob/cbfdd7fc/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/ffdc/ConnectorCheckedException.java
----------------------------------------------------------------------
diff --git a/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/ffdc/ConnectorCheckedException.java b/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/ffdc/ConnectorCheckedException.java
new file mode 100644
index 0000000..d45e944
--- /dev/null
+++ b/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/ffdc/ConnectorCheckedException.java
@@ -0,0 +1,76 @@
+/*
+ * 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.ocf.ffdc;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * ConnectorCheckedException provides a checked exception for reporting errors found when using OCF connectors.
+ * 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 OCFErrorCode 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 ConnectorCheckedException extends OCFCheckedExceptionBase
+{
+ private static final Logger log = LoggerFactory.getLogger(ConnectorCheckedException.class);
+
+ /**
+ * This is the typical constructor used for creating a ConnectorCheckedException.
+ *
+ * @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 ConnectorCheckedException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction)
+ {
+ super(httpCode, className, actionDescription, errorMessage, systemAction, userAction);
+
+ if (log.isDebugEnabled())
+ {
+ log.debug(httpCode + ", " + className + ", " + actionDescription);
+ }
+ }
+
+
+ /**
+ * This is the constructor used for creating a ConnectorCheckedException in response to a previous exception.
+ *
+ * @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 ConnectorCheckedException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction, Throwable caughtError)
+ {
+ super(httpCode, className, actionDescription, errorMessage, systemAction, userAction, caughtError);
+
+ if (log.isDebugEnabled())
+ {
+ log.debug(httpCode + ", " + className + ", " + actionDescription + ", " + caughtError.toString());
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/atlas/blob/cbfdd7fc/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/ffdc/OCFCheckedExceptionBase.java
----------------------------------------------------------------------
diff --git a/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/ffdc/OCFCheckedExceptionBase.java b/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/ffdc/OCFCheckedExceptionBase.java
new file mode 100644
index 0000000..bf0e2c2
--- /dev/null
+++ b/om-fwk-ocf/src/main/java/org/apache/atlas/ocf/ffdc/OCFCheckedExceptionBase.java
@@ -0,0 +1,178 @@
+/*
+ * 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.ocf.ffdc;
+
+
+import java.util.UUID;
+
+/**
+ * OCFCheckedExceptionBase provides a checked exception for reporting errors found when using OCF connectors.
+ * 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 OCFErrorCode 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 OCFCheckedExceptionBase extends Exception
+{
+ private static final int hashCode = UUID.randomUUID().hashCode();
+
+ /*
+ * 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 an OCFCheckedException.
+ *
+ * @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 OCFCheckedExceptionBase(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 an OCFCheckedException 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 OCFCheckedExceptionBase(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; }
+
+
+ /**
+ * Provide a common implementation of hashCode for all OCF properties objects. The UUID is unique and
+ * is randomly assigned and so its hashCode is as good as anything to describe the hash code of the properties
+ * object.
+ */
+ public int hashCode()
+ {
+ return hashCode;
+ }
+}
\ No newline at end of file