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; + } +}
