[25/31] atlas git commit: ATLAS-2122 OMAG Server Application and OMRS APIs
http://git-wip-us.apache.org/repos/asf/atlas/blob/a1fd4068/omrs/src/main/java/org/apache/atlas/omrs/admin/OMRSOperationalServices.java -- diff --git a/omrs/src/main/java/org/apache/atlas/omrs/admin/OMRSOperationalServices.java b/omrs/src/main/java/org/apache/atlas/omrs/admin/OMRSOperationalServices.java index 8a47945..60b4704 100644 --- a/omrs/src/main/java/org/apache/atlas/omrs/admin/OMRSOperationalServices.java +++ b/omrs/src/main/java/org/apache/atlas/omrs/admin/OMRSOperationalServices.java @@ -19,13 +19,13 @@ package org.apache.atlas.omrs.admin; import org.apache.atlas.ocf.Connector; import org.apache.atlas.ocf.ConnectorBroker; -import org.apache.atlas.ocf.properties.Connection; +import org.apache.atlas.ocf.properties.beans.Connection; import org.apache.atlas.omrs.admin.properties.CohortConfig; import org.apache.atlas.omrs.admin.properties.EnterpriseAccessConfig; import org.apache.atlas.omrs.admin.properties.LocalRepositoryConfig; import org.apache.atlas.omrs.admin.properties.RepositoryServicesConfig; import org.apache.atlas.omrs.archivemanager.OMRSArchiveManager; -import org.apache.atlas.omrs.archivemanager.store.OpenMetadataArchiveStore; +import org.apache.atlas.omrs.archivemanager.store.OpenMetadataArchiveStoreConnector; import org.apache.atlas.omrs.auditlog.OMRSAuditCode; import org.apache.atlas.omrs.auditlog.OMRSAuditLog; import org.apache.atlas.omrs.auditlog.OMRSAuditingComponent; @@ -34,7 +34,7 @@ import org.apache.atlas.omrs.enterprise.connectormanager.OMRSConnectionConsumer; import org.apache.atlas.omrs.enterprise.connectormanager.OMRSEnterpriseConnectorManager; import org.apache.atlas.omrs.eventmanagement.OMRSRepositoryEventExchangeRule; import org.apache.atlas.omrs.eventmanagement.OMRSRepositoryEventManager; -import org.apache.atlas.omrs.eventmanagement.repositoryeventmapper.OMRSRepositoryEventMapper; +import org.apache.atlas.omrs.eventmanagement.repositoryeventmapper.OMRSRepositoryEventMapperConnector; import org.apache.atlas.omrs.ffdc.exception.OMRSConfigErrorException; import org.apache.atlas.omrs.ffdc.OMRSErrorCode; import org.apache.atlas.omrs.ffdc.exception.OMRSLogicErrorException; @@ -53,6 +53,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.ArrayList; +import java.util.List; /** * OMRSOperationalServices provides the OMAG Server with access to the OMRS capabilities. @@ -80,9 +81,12 @@ public class OMRSOperationalServices private static final OMRSAuditLog auditLog = new OMRSAuditLog(OMRSAuditingComponent.OPERATIONAL_SERVICES); -private String localServerName = null; -private String localServerType = null; -private String localOrganizationName = null; +private String localServerName; /* Initialized in constructor */ +private String localServerType; /* Initialized in constructor */ +private String localOrganizationName; /* Initialized in constructor */ +private String localServerURL; /* Initialized in constructor */ +private intmaxPageSize; /* Initialized in constructor */ + private String localMetadataCollectionId = null; private OMRSRepositoryContentManager localRepositoryContentManager = null; @@ -100,10 +104,13 @@ public class OMRSOperationalServices * @param localServerName - name of the local server * @param localServerType - type of the local server * @param organizationName - name of the organization that owns the local server + * @param localServerURL - URL root for this server. */ public OMRSOperationalServices(String localServerName, String localServerType, - String organizationName) + String organizationName, + String localServerURL, + int maxPageSize) { /* * Save details about the local server @@ -111,6 +118,8 @@ public class OMRSOperationalServices this.localServerName = localServerName; this.localServerType = localServerType; this.localOrganizationName = organizationName; +this.localServerURL = localServerURL; +this.maxPageSize = maxPageSize; } @@ -122,7 +131,7 @@ public class OMRSOperationalServices */ public void initialize(RepositoryServicesConfig repositoryServicesConfig) { -final String actionDescription = "Initialize Repository Operational Services"; +
[21/31] atlas git commit: ATLAS-2122 OMAG Server Application and OMRS APIs
http://git-wip-us.apache.org/repos/asf/atlas/blob/a1fd4068/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/properties/OpenMetadataArchive.java -- diff --git a/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/properties/OpenMetadataArchive.java b/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/properties/OpenMetadataArchive.java index 58c5c2a..35e3a85 100644 --- a/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/properties/OpenMetadataArchive.java +++ b/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/properties/OpenMetadataArchive.java @@ -17,6 +17,13 @@ */ package org.apache.atlas.omrs.archivemanager.properties; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + /** * OpenMetadataArchive defines the structure of the properties inside of an open metadata archive. * There are 3 sections: @@ -32,6 +39,9 @@ package org.apache.atlas.omrs.archivemanager.properties; * * */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) public class OpenMetadataArchive { private OpenMetadataArchivePropertiesarchiveProperties= null; http://git-wip-us.apache.org/repos/asf/atlas/blob/a1fd4068/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/properties/OpenMetadataArchiveInstanceStore.java -- diff --git a/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/properties/OpenMetadataArchiveInstanceStore.java b/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/properties/OpenMetadataArchiveInstanceStore.java index 1d9b79b..0283fb4 100644 --- a/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/properties/OpenMetadataArchiveInstanceStore.java +++ b/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/properties/OpenMetadataArchiveInstanceStore.java @@ -18,15 +18,25 @@ package org.apache.atlas.omrs.archivemanager.properties; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; import org.apache.atlas.omrs.metadatacollection.properties.instances.EntityDetail; import org.apache.atlas.omrs.metadatacollection.properties.instances.Relationship; import java.util.ArrayList; +import java.util.List; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; /** * OpenMetadataArchiveInstanceStore defines the contents of the InstanceStore in an open metadata archive. It * consists of a list of entities and a list of relationships. */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) public class OpenMetadataArchiveInstanceStore { private ArrayList entities = null; @@ -46,9 +56,16 @@ public class OpenMetadataArchiveInstanceStore * * @return list of entities */ -public ArrayList getEntities() +public List getEntities() { -return entities; +if (entities == null) +{ +return null; +} +else +{ +return new ArrayList<>(entities); +} } @@ -57,9 +74,16 @@ public class OpenMetadataArchiveInstanceStore * * @param entities - list of entities */ -public void setEntities(ArrayList entities) +public void setEntities(List entities) { -this.entities = entities; +if (entities == null) +{ +this.entities = null; +} +else +{ +this.entities = new ArrayList<>(entities); +} } @@ -68,9 +92,16 @@ public class OpenMetadataArchiveInstanceStore * * @return list of relationships */ -public ArrayList getRelationships() +public List getRelationships() { -return relationships; +if (relationships == null) +{ +return null; +} +else +{ +return new ArrayList<>(relationships); +} } @@ -79,8 +110,15 @@ public class OpenMetadataArchiveInstanceStore * * @param relationships - list of relationship objects */ -public void setRelationships(ArrayList relationships) +public void setRelationships(List relationships) { -this.relationships =
[05/31] atlas git commit: ATLAS-2122 OMAG Server Application and OMRS APIs
http://git-wip-us.apache.org/repos/asf/atlas/blob/a1fd4068/omrs/src/main/java/org/apache/atlas/omrs/metadatahighway/cohortregistry/OMRSCohortRegistry.java -- diff --git a/omrs/src/main/java/org/apache/atlas/omrs/metadatahighway/cohortregistry/OMRSCohortRegistry.java b/omrs/src/main/java/org/apache/atlas/omrs/metadatahighway/cohortregistry/OMRSCohortRegistry.java index 278ad10..26a0dbc 100644 --- a/omrs/src/main/java/org/apache/atlas/omrs/metadatahighway/cohortregistry/OMRSCohortRegistry.java +++ b/omrs/src/main/java/org/apache/atlas/omrs/metadatahighway/cohortregistry/OMRSCohortRegistry.java @@ -18,7 +18,7 @@ package org.apache.atlas.omrs.metadatahighway.cohortregistry; import org.apache.atlas.ocf.ffdc.OCFCheckedExceptionBase; -import org.apache.atlas.ocf.properties.Connection; +import org.apache.atlas.ocf.properties.beans.Connection; import org.apache.atlas.omrs.auditlog.OMRSAuditCode; import org.apache.atlas.omrs.auditlog.OMRSAuditLog; import org.apache.atlas.omrs.auditlog.OMRSAuditingComponent; @@ -37,6 +37,7 @@ import org.slf4j.LoggerFactory; import java.util.ArrayList; import java.util.Date; +import java.util.List; /** @@ -252,6 +253,13 @@ public class OMRSCohortRegistry implements OMRSRegistryEventProcessor this.registryStore = cohortRegistryStore; /* + * Save information about the local server + */ +this.localServerName = localServerName; +this.localServerType = localServerType; +this.localOrganizationName = localOrganizationName; + +/* * Save the cohort name for messages and the registry event processor for sending outbound events. */ this.cohortName = cohortName; @@ -262,6 +270,7 @@ public class OMRSCohortRegistry implements OMRSRegistryEventProcessor * This will throw an exception if there are unresolvable differences. */ this.validateLocalMetadataCollectionId(localMetadataCollectionId); +this.localMetadataCollectionId = localMetadataCollectionId; /* * Save the TypeDef validator. This object is able to generate the list of TypeDef @@ -282,13 +291,6 @@ public class OMRSCohortRegistry implements OMRSRegistryEventProcessor * in the registration request that this repository sends out. */ this.localRepositoryRemoteConnection = localRepositoryRemoteConnection; - -/* - * Save information about the local server - */ -this.localServerName = localServerName; -this.localServerType = localServerType; -this.localOrganizationName = localOrganizationName; } @@ -348,13 +350,9 @@ public class OMRSCohortRegistry implements OMRSRegistryEventProcessor /* * If the local metadata collection Id is null it means there is no local repository. No registration * is required but the cohort registry sends a registration refresh request to ensure it has a complete - * list of the remote members for the connection consumer. The connection consumer will be null - * if enterprise access is disabled. + * list of the remote members for the connection consumer. */ -if (connectionConsumer != null) -{ -this.requestReRegistrationFromCohort(localRegistration); -} +this.requestReRegistrationFromCohort(localRegistration); } else if (localRegistration.getRegistrationTime() == null) { @@ -393,7 +391,6 @@ public class OMRSCohortRegistry implements OMRSRegistryEventProcessor /* * Now read the remote registrations from the registry store and publish them to the connection consumer. - * The connection consumer will be null if enterprise access is disabled. */ if (connectionConsumer != null) { @@ -401,7 +398,7 @@ public class OMRSCohortRegistry implements OMRSRegistryEventProcessor * Extract remote member registrations from the cohort registry store and register each one with the * connection consumer. */ -ArrayList remoteRegistrations = registryStore.retrieveRemoteRegistrations(); +List remoteRegistrations = registryStore.retrieveRemoteRegistrations(); if (remoteRegistrations != null) { @@ -411,6 +408,8 @@ public class OMRSCohortRegistry implements OMRSRegistryEventProcessor { this.registerRemoteConnectionWithConsumer(remoteMember.getMetadataCollectionId(), remoteMember.getServerName(), + remoteMember.getServerType(), +
[13/31] atlas git commit: ATLAS-2122 OMAG Server Application and OMRS APIs
http://git-wip-us.apache.org/repos/asf/atlas/blob/a1fd4068/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositorycontentmanager/OMRSRepositoryContentManager.java -- diff --git a/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositorycontentmanager/OMRSRepositoryContentManager.java b/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositorycontentmanager/OMRSRepositoryContentManager.java index c146be6..95fa649 100644 --- a/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositorycontentmanager/OMRSRepositoryContentManager.java +++ b/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositorycontentmanager/OMRSRepositoryContentManager.java @@ -35,9 +35,7 @@ import org.apache.atlas.omrs.metadatacollection.repositoryconnector.OMRSReposito import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map; +import java.util.*; /** * OMRSRepositoryContentManager supports an in-memory cache of TypeDefs for the local server. It is used by the OMRS @@ -75,7 +73,6 @@ public class OMRSRepositoryContentManager implements OMRSTypeDefEventProcessor, OMRSTypeDefValidator, OMRSInstanceValidator { -private StringlocalMetadataCollectionId = null; private LocalOMRSRepositoryConnector localRepositoryConnector = null; private OMRSRepositoryEventManageroutboundRepositoryEventManager = null; private OMRSRepositoryConnector realLocalConnector = null; @@ -83,8 +80,8 @@ public class OMRSRepositoryContentManager implements OMRSTypeDefEventProcessor, private StringopenTypesOriginGUID= null; private HashMapknownTypes = new HashMap<>(); private HashMap knownAttributeTypes= new HashMap<>(); -private HashMap activeTypes= null; -private HashMap activeAttributeTypes = null; +private HashMap activeTypes= new HashMap<>(); +private HashMap activeAttributeTypes = new HashMap<>(); @@ -120,10 +117,9 @@ public class OMRSRepositoryContentManager implements OMRSTypeDefEventProcessor, OMRSRepositoryEventExchangeRule saveExchangeRule, OMRSRepositoryEventManager outboundRepositoryEventManager) { -this.localRepositoryConnector = localRepositoryConnector; -this.realLocalConnector = realLocalConnector; -this.saveExchangeRule = saveExchangeRule; -this.localMetadataCollectionId = localRepositoryConnector.getMetadataCollectionId(); +this.localRepositoryConnector = localRepositoryConnector; +this.realLocalConnector = realLocalConnector; +this.saveExchangeRule = saveExchangeRule; this.outboundRepositoryEventManager = outboundRepositoryEventManager; } @@ -165,8 +161,6 @@ public class OMRSRepositoryContentManager implements OMRSTypeDefEventProcessor, { log.debug("New Active Type " + newTypeDef.getName() + " from " + sourceName, newTypeDef); } - -// TODO log new active type } } } @@ -180,9 +174,22 @@ public class OMRSRepositoryContentManager implements OMRSTypeDefEventProcessor, */ public void addAttributeTypeDef(String sourceName, AttributeTypeDef newAttributeTypeDef) { +if (this.validAttributeTypeDef(sourceName, newAttributeTypeDef)) +{ +knownAttributeTypes.put(newAttributeTypeDef.getName(), newAttributeTypeDef); +if (localRepositoryConnector != null) +{ +activeAttributeTypes.put(newAttributeTypeDef.getName(), newAttributeTypeDef); +if (log.isDebugEnabled()) +{ +log.debug("New Active Attribute Type " + newAttributeTypeDef.getName() + " from " + sourceName, newAttributeTypeDef); +} +} +} } + /** * Update one or more properties of a cached TypeDef. This method assumes the TypeDef has been successfully * updated in the local repository already and all that is needed is to maintain the cached list of types @@ -209,6 +216,31 @@ public class OMRSRepositoryContentManager implements OMRSTypeDefEventProcessor, /** + * Update one or more properties of a cached TypeDef. + * + * @param sourceName - source of the
[26/31] atlas git commit: ATLAS-2122 OMAG Server Application and OMRS APIs
http://git-wip-us.apache.org/repos/asf/atlas/blob/a1fd4068/omrs/src/main/java/org/apache/atlas/omrs/adapters/inmemory/repositoryconnector/InMemoryOMRSMetadataStore.java -- diff --git a/omrs/src/main/java/org/apache/atlas/omrs/adapters/inmemory/repositoryconnector/InMemoryOMRSMetadataStore.java b/omrs/src/main/java/org/apache/atlas/omrs/adapters/inmemory/repositoryconnector/InMemoryOMRSMetadataStore.java new file mode 100644 index 000..6b9bfd5 --- /dev/null +++ b/omrs/src/main/java/org/apache/atlas/omrs/adapters/inmemory/repositoryconnector/InMemoryOMRSMetadataStore.java @@ -0,0 +1,634 @@ +/* + * 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.omrs.adapters.inmemory.repositoryconnector; + +import org.apache.atlas.omrs.ffdc.OMRSErrorCode; +import org.apache.atlas.omrs.ffdc.exception.InvalidParameterException; +import org.apache.atlas.omrs.metadatacollection.properties.instances.EntityDetail; +import org.apache.atlas.omrs.metadatacollection.properties.instances.EntityProxy; +import org.apache.atlas.omrs.metadatacollection.properties.instances.Relationship; +import org.apache.atlas.omrs.metadatacollection.properties.typedefs.AttributeTypeDef; +import org.apache.atlas.omrs.metadatacollection.properties.typedefs.TypeDef; + +import java.util.*; + +/** + * InMemoryOMRSMetadataStore provides the in memory stores for the InMemoryRepositoryConnector + */ +public class InMemoryOMRSMetadataStore +{ +private StringrepositoryName = null; +private HashMaptypeDefStore = new HashMap<>(); +private HashMap attributeTypeDefStore= new HashMap<>(); +private HashMap entityStore = new HashMap<>(); +private HashMap entityProxyStore = new HashMap<>(); +private ListentityHistoryStore = new ArrayList<>(); +private HashMap relationshipStore= new HashMap<>(); +private ListrelationshipHistoryStore = new ArrayList<>(); + + +/** + * Default constructor + */ +public InMemoryOMRSMetadataStore() +{ +} + + +/** + * Set up the name of the repository for logging. + * + * @param repositoryName - String name + */ +protected void setRepositoryName(StringrepositoryName) +{ +this.repositoryName = repositoryName; +} + + +/** + * Return a list of all of the defined AttributeTypeDefs. + * + * @return list of attribute type definitions + */ +protected List getAttributeTypeDefs() +{ +return new ArrayList<>(attributeTypeDefStore.values()); +} + + +/** + * Return the AttributeTypeDef identified by the supplied guid. + * + * @param guid - unique identifier for the AttributeTypeDef + * @return attribute type definition + */ +protected AttributeTypeDef getAttributeTypeDef(String guid) +{ +return attributeTypeDefStore.get(guid); +} + + +/** + * Add an AttributeDefType to the store. + * + * @param attributeTypeDef - type to add + */ +protected void putAttributeTypeDef(AttributeTypeDef attributeTypeDef) +{ +attributeTypeDefStore.put(attributeTypeDef.getGUID(), attributeTypeDef); +} + + +/** + * Return a list of all of the defined TypeDefs. + * + * @return list of type definitions + */ +protected List getTypeDefs() +{ +return new ArrayList<>(typeDefStore.values()); +} + + +/** + * Return the type definition identified by the guid. + * + * @param guid - unique identifier for type definition + * @return type definition + */ +protected TypeDef getTypeDef(String guid) +{ +return typeDefStore.get(guid); +} + + +/** + * Add a type definition (TypeDef) to the store. + * + * @param typeDef - type definition + */ +protected void putTypeDef(TypeDef typeDef) +{ +typeDefStore.put(typeDef.getGUID(), typeDef); +}
[16/31] atlas git commit: ATLAS-2122 OMAG Server Application and OMRS APIs
http://git-wip-us.apache.org/repos/asf/atlas/blob/a1fd4068/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositoryconnector/LocalOMRSInstanceEventProcessor.java -- diff --git a/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositoryconnector/LocalOMRSInstanceEventProcessor.java b/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositoryconnector/LocalOMRSInstanceEventProcessor.java index 5a0182e..fe144ed 100644 --- a/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositoryconnector/LocalOMRSInstanceEventProcessor.java +++ b/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositoryconnector/LocalOMRSInstanceEventProcessor.java @@ -17,15 +17,20 @@ */ package org.apache.atlas.omrs.localrepository.repositoryconnector; +import org.apache.atlas.ocf.properties.Connection; +import org.apache.atlas.omrs.auditlog.OMRSAuditCode; import org.apache.atlas.omrs.auditlog.OMRSAuditLog; import org.apache.atlas.omrs.auditlog.OMRSAuditingComponent; import org.apache.atlas.omrs.eventmanagement.*; import org.apache.atlas.omrs.eventmanagement.events.OMRSInstanceEventProcessor; +import org.apache.atlas.omrs.ffdc.OMRSErrorCode; import org.apache.atlas.omrs.ffdc.exception.*; -import org.apache.atlas.omrs.localrepository.repositorycontentmanager.OMRSTypeDefHelper; +import org.apache.atlas.omrs.localrepository.repositorycontentmanager.OMRSRepositoryHelper; +import org.apache.atlas.omrs.localrepository.repositorycontentmanager.OMRSRepositoryValidator; import org.apache.atlas.omrs.metadatacollection.OMRSMetadataCollection; import org.apache.atlas.omrs.metadatacollection.properties.instances.EntityDetail; import org.apache.atlas.omrs.metadatacollection.properties.instances.InstanceProvenanceType; +import org.apache.atlas.omrs.metadatacollection.properties.instances.InstanceType; import org.apache.atlas.omrs.metadatacollection.properties.instances.Relationship; import org.apache.atlas.omrs.metadatacollection.properties.typedefs.TypeDefSummary; import org.apache.atlas.omrs.metadatacollection.repositoryconnector.OMRSRepositoryConnector; @@ -44,10 +49,16 @@ import java.util.ArrayList; */ public class LocalOMRSInstanceEventProcessor implements OMRSInstanceEventProcessor, OMRSInstanceRetrievalEventProcessor { -private String localMetadataCollectionId = null; -private OMRSRepositoryConnector realLocalConnector= null; -private OMRSTypeDefHelper typeDefHelper = null; -private OMRSRepositoryEventExchangeRule saveExchangeRule = null; +private String localMetadataCollectionId; +private String localServerName; +private OMRSRepositoryConnector realLocalConnector; +private OMRSRepositoryHelperrepositoryHelper; +private OMRSRepositoryValidator repositoryValidator; +private OMRSRepositoryEventExchangeRule saveExchangeRule; +private String realRepositoryName = "Local Repository"; +private OMRSMetadataCollection realMetadataCollection = null; +private OMRSRepositoryEventProcessoroutboundRepositoryEventProcessor = null; + /* @@ -63,38 +74,41 @@ public class LocalOMRSInstanceEventProcessor implements OMRSInstanceEventProcess * of nulls in any of its parameters and will throw a logic error exception is it finds any. * * @param localMetadataCollectionId - local metadata collection identifier - * @param realLocalConnector - connector to the real local repository - * @param typeDefHelper - helper class for building instances - * @param saveExchangeRule - rule that determines which events to process. + * @param localServerName - name of the local server - for logging + * @param realLocalConnector- connector to the real local repository + * @param repositoryHelper - helper class for building instances + * @param repositoryValidator - helper class for validating instances + * @param saveExchangeRule - rule that determines which events to process. */ -LocalOMRSInstanceEventProcessor(String localMetadataCollectionId, -OMRSRepositoryConnector realLocalConnector, -OMRSTypeDefHelper typeDefHelper, -OMRSRepositoryEventExchangeRule saveExchangeRule) +LocalOMRSInstanceEventProcessor(String localMetadataCollectionId, +String localServerName, +OMRSRepositoryConnector realLocalConnector, +OMRSRepositoryHelper
[17/31] atlas git commit: ATLAS-2122 OMAG Server Application and OMRS APIs
http://git-wip-us.apache.org/repos/asf/atlas/blob/a1fd4068/omrs/src/main/java/org/apache/atlas/omrs/ffdc/OMRSErrorCode.java -- diff --git a/omrs/src/main/java/org/apache/atlas/omrs/ffdc/OMRSErrorCode.java b/omrs/src/main/java/org/apache/atlas/omrs/ffdc/OMRSErrorCode.java index f40f2c6..185311a 100644 --- a/omrs/src/main/java/org/apache/atlas/omrs/ffdc/OMRSErrorCode.java +++ b/omrs/src/main/java/org/apache/atlas/omrs/ffdc/OMRSErrorCode.java @@ -48,111 +48,259 @@ import java.util.Arrays; */ public enum OMRSErrorCode { -ENTITY_NOT_KNOWN(400, "OMRS-REPOSITORY-400-001", -"The entity identified with guid \"{0}\" is not known to the open metadata repository {1}.", -"The system is unable to retrieve the properties for the requested entity because the supplied guid is not recognized.", -"The guid is supplied by the caller to the OMRS. It may have a logic problem that has corrupted the guid, or the entity has been deleted since the guid was retrieved."), -RELATIONSHIP_NOT_KNOWN(400, "OMRS-REPOSITORY-400-002", -"The relationship identified with guid \"{0}\" is not known to the open metadata repository {1}.", -"The system is unable to retrieve the properties for the requested relationship because the supplied guid is not recognized.", -"The guid is supplied by the caller to the OMRS. It may have a logic problem that has corrupted the guid, or the relationship has been deleted since the guid was retrieved."), -TYPEDEF_NOT_KNOWN(400, "OMRS-REPOSITORY-400-003", -"The typedef \"{0}\" is not known to the metadata repository.", -"The system is unable to retrieve the properties for the requested typedef because the supplied identifier is not recognized.", -"The identifier is supplied by the caller. It may have a logic problem that has corrupted the identifier, or the typedef has been deleted since the identifier was retrieved."), -TYPEDEF_IN_USE(400, "OMRS-REPOSITORY-400-004", -"Unable to delete the typedef identified with guid \"{0}\" since it is still in use in the metadata repository.", -"The system is unable to delete the typedef because there are still instances in the metadata repository that are using it.", +TYPEDEF_IN_USE(400, "OMRS-REPOSITORY-400-001 ", +"Unable to delete the TypeDef \"{0}\" (guid = {1}) since it is still in use in the open metadata repository {2}", +"The system is unable to delete the TypeDef because there are still instances in the metadata repository that are using it.", "Remove the existing instances from the open metadata repositories and try the delete again."), -UNKNOWN_CLASSIFICATION(400, "OMRS-REPOSITORY-400-005", -"Classification \"{0}\" is not a recognized classification type", -"The system is unable to create a new classification for an entity because the local repository does not recognize the type.", +ATTRIBUTE_TYPEDEF_IN_USE(400, "OMRS-REPOSITORY-400-002 ", +"Unable to delete the AttributeTypeDef \"{0}\" (guid = {1}) since it is still in use in the open metadata repository {2}", +"The system is unable to delete the AttributeTypeDef because there are still instances in the metadata repository that are using it.", +"Remove the existing instances from the open metadata repositories and try the delete again."), +TYPEDEF_ALREADY_DEFINED(400, "OMRS-REPOSITORY-400-003 ", +"Unable to add the TypeDef \"{0}\" (guid = {1}) since it is already defined in the open metadata repository {2}", +"The system is unable to add the TypeDef to its repository because it is already defined.", +"Validate that the existing definition is as required. It is possible to patch the TypeDef, or delete it and re-define it."), +ATTRIBUTE_TYPEDEF_ALREADY_DEFINED(400, "OMRS-REPOSITORY-400-004 ", +"Unable to add the AttributeTypeDef \"{0}\" (guid = {1}) since it is already defined in the open metadata repository {2}", +"The system is unable to delete the AttributeTypeDef because there are still instances in the metadata repository that are using it.", +"Validate that the existing definition is as required. It is possible to patch the TypeDef, or delete it and re-define it."), +UNKNOWN_CLASSIFICATION(400, "OMRS-REPOSITORY-400-005 ", +"Classification \"{0}\" is not a recognized classification type by open metadata repository {1}", +"The system is unable to create a new classification for an entity because the open metadata repository does not recognize the classification type.", "Create a ClassificationDef for the classification and retry the request."), -INVALID_CLASSIFICATION_FOR_ENTITY(400, "OMRS-REPOSITORY-400-006", -"Unable
[08/31] atlas git commit: ATLAS-2122 OMAG Server Application and OMRS APIs
http://git-wip-us.apache.org/repos/asf/atlas/blob/a1fd4068/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/OMRSMetadataCollectionBase.java -- diff --git a/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/OMRSMetadataCollectionBase.java b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/OMRSMetadataCollectionBase.java index 778f6b0..70c9070 100644 --- a/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/OMRSMetadataCollectionBase.java +++ b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/OMRSMetadataCollectionBase.java @@ -18,12 +18,15 @@ package org.apache.atlas.omrs.metadatacollection; import org.apache.atlas.omrs.ffdc.exception.*; +import org.apache.atlas.omrs.localrepository.repositorycontentmanager.OMRSRepositoryHelper; +import org.apache.atlas.omrs.localrepository.repositorycontentmanager.OMRSRepositoryValidator; import org.apache.atlas.omrs.metadatacollection.properties.MatchCriteria; import org.apache.atlas.omrs.metadatacollection.properties.SequencingOrder; import org.apache.atlas.omrs.metadatacollection.properties.instances.*; import org.apache.atlas.omrs.metadatacollection.properties.typedefs.*; +import org.apache.atlas.omrs.metadatacollection.repositoryconnector.OMRSRepositoryConnector; -import java.util.ArrayList; +import java.util.List; import java.util.Date; /** @@ -74,19 +77,36 @@ import java.util.Date; */ public abstract class OMRSMetadataCollectionBase extends OMRSMetadataCollection { -protected String metadataCollectionId; /** * Constructor to save the metadata collection id. * * @param metadataCollectionId - unique identifier for the metadata managed by the repository. */ +@Deprecated public OMRSMetadataCollectionBase(String metadataCollectionId) { super(metadataCollectionId); } +/** + * Constructor ensures the metadata collection is linked to its connector and knows its metadata collection Id. + * + * @param parentConnector - connector that this metadata collection supports. The connector has the information + *to call the metadata repository. + * @param metadataCollectionId - unique Identifier of the metadata collection Id. + */ +public OMRSMetadataCollectionBase(OMRSRepositoryConnector parentConnector, + String repositoryName, + OMRSRepositoryHelperrepositoryHelper, + OMRSRepositoryValidator repositoryValidator, + String metadataCollectionId) +{ +super(parentConnector, repositoryName, metadataCollectionId, repositoryHelper, repositoryValidator); +} + + /* == * Group 1: Confirm the identity of the metadata repository being called. */ @@ -117,7 +137,7 @@ public abstract class OMRSMetadataCollectionBase extends OMRSMetadataCollection * and classifications. * * @param userId - unique identifier for requesting user. - * @return TypeDefGallery - List of different categories of type definitions. + * @return TypeDefGalleryResponse - List of different categories of type definitions. * @throws RepositoryErrorException - there is a problem communicating with the metadata repository. * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation. */ @@ -159,10 +179,10 @@ public abstract class OMRSMetadataCollectionBase extends OMRSMetadataCollection * @throws RepositoryErrorException - there is a problem communicating with the metadata repository. * @throws UserNotAuthorizedException - the userId is not permitted to perform this operation. */ -public ArrayList findTypeDefsByCategory(String userId, - TypeDefCategory category) throws InvalidParameterException, - RepositoryErrorException, - UserNotAuthorizedException +public List findTypeDefsByCategory(String userId, +TypeDefCategory category) throws InvalidParameterException, + RepositoryErrorException, + UserNotAuthorizedException { return null; } @@ -178,10 +198,10 @@ public abstract class OMRSMetadataCollectionBase extends OMRSMetadataCollection * @throws RepositoryErrorException - there is a problem
[20/31] atlas git commit: ATLAS-2122 OMAG Server Application and OMRS APIs
http://git-wip-us.apache.org/repos/asf/atlas/blob/a1fd4068/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 index 0bd1038..d03fcc0 100644 --- 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 @@ -24,6 +24,9 @@ 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.localrepository.repositorycontentmanager.OMRSRepositoryContentManager; +import org.apache.atlas.omrs.localrepository.repositorycontentmanager.OMRSRepositoryHelper; +import org.apache.atlas.omrs.localrepository.repositorycontentmanager.OMRSRepositoryValidator; import org.apache.atlas.omrs.metadatacollection.OMRSMetadataCollection; import org.apache.atlas.omrs.metadatacollection.repositoryconnector.OMRSRepositoryConnector; @@ -77,10 +80,12 @@ import java.util.UUID; */ public class OMRSEnterpriseConnectorManager implements OMRSConnectionConsumer, OMRSConnectorManager { -private boolean enterpriseAccessEnabled = false; +private booleanenterpriseAccessEnabled; +private intmaxPageSize; private String localMetadataCollectionId = null; private OMRSRepositoryConnectorlocalRepositoryConnector = null; +private OMRSRepositoryContentManager repositoryContentManager = null; private ArrayList registeredRemoteConnectors = new ArrayList<>(); private ArrayList registeredConnectorConsumers = new ArrayList<>(); @@ -92,10 +97,13 @@ public class OMRSEnterpriseConnectorManager implements OMRSConnectionConsumer, O * informed of remote connectors. If enterpriseAccessEnabled = true * the connector consumers will be informed of remote connectors; otherwise * they will not. + * @param maxPageSize - the maximum number of elements that can be requested on a page. */ -public OMRSEnterpriseConnectorManager(boolean enterpriseAccessEnabled) +public OMRSEnterpriseConnectorManager(boolean enterpriseAccessEnabled, + int maxPageSize) { this.enterpriseAccessEnabled = enterpriseAccessEnabled; +this.maxPageSize = maxPageSize; } @@ -141,11 +149,15 @@ public class OMRSEnterpriseConnectorManager implements OMRSConnectionConsumer, O } } + /** * 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 remoteServerName - name of the remote server for this connection. + * @param remoteServerType - type of the remote server. + * @param owningOrganizationName - name of the organization the owns the remote server. * @param metadataCollectionId - Unique identifier for the metadata collection * @param remoteConnection - Connection object providing properties necessary to create an * OMRSRepositoryConnector for the remote repository. @@ -153,14 +165,23 @@ public class OMRSEnterpriseConnectorManager implements OMRSConnectionConsumer, O * @throws ConnectorCheckedException - there is a problem initializing the Connector */ public synchronized void addRemoteConnection(String cohortName, + String remoteServerName, + String remoteServerType, + String owningOrganizationName, 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. + * is thrown by getOMRSRepositoryConnector() to tell the
[18/31] atlas git commit: ATLAS-2122 OMAG Server Application and OMRS APIs
http://git-wip-us.apache.org/repos/asf/atlas/blob/a1fd4068/omrs/src/main/java/org/apache/atlas/omrs/enterprise/repositoryconnector/EnterpriseOMRSRepositoryConnector.java -- diff --git a/omrs/src/main/java/org/apache/atlas/omrs/enterprise/repositoryconnector/EnterpriseOMRSRepositoryConnector.java b/omrs/src/main/java/org/apache/atlas/omrs/enterprise/repositoryconnector/EnterpriseOMRSRepositoryConnector.java index f74a772..0e18748 100644 --- a/omrs/src/main/java/org/apache/atlas/omrs/enterprise/repositoryconnector/EnterpriseOMRSRepositoryConnector.java +++ b/omrs/src/main/java/org/apache/atlas/omrs/enterprise/repositoryconnector/EnterpriseOMRSRepositoryConnector.java @@ -17,14 +17,20 @@ */ package org.apache.atlas.omrs.enterprise.repositoryconnector; +import org.apache.atlas.ocf.Connector; import org.apache.atlas.ocf.ffdc.ConnectorCheckedException; +import org.apache.atlas.omrs.auditlog.OMRSAuditCode; import org.apache.atlas.omrs.enterprise.connectormanager.OMRSConnectorConsumer; import org.apache.atlas.omrs.enterprise.connectormanager.OMRSConnectorManager; import org.apache.atlas.omrs.ffdc.exception.RepositoryErrorException; +import org.apache.atlas.omrs.localrepository.repositorycontentmanager.OMRSRepositoryHelper; +import org.apache.atlas.omrs.localrepository.repositorycontentmanager.OMRSRepositoryValidator; import org.apache.atlas.omrs.metadatacollection.OMRSMetadataCollection; import org.apache.atlas.omrs.metadatacollection.repositoryconnector.OMRSRepositoryConnector; import org.apache.atlas.omrs.ffdc.OMRSErrorCode; import org.apache.atlas.omrs.ffdc.exception.OMRSRuntimeException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.ArrayList; import java.util.Iterator; @@ -57,6 +63,7 @@ public class EnterpriseOMRSRepositoryConnector extends OMRSRepositoryConnector i private FederatedConnector localCohortConnector = null; private ArrayListremoteCohortConnectors = new ArrayList<>(); +private static final Logger log = LoggerFactory.getLogger(EnterpriseOMRSRepositoryConnector.class); /** * Constructor used by the EnterpriseOMRSConnectorProvider. @@ -106,6 +113,8 @@ public class EnterpriseOMRSRepositoryConnector extends OMRSRepositoryConnector i if (metadataCollectionId != null) { enterpriseMetadataCollection = new EnterpriseOMRSMetadataCollection(this, + repositoryHelper, + repositoryValidator, enterpriseMetadataCollectionId, enterpriseMetadataCollectionName); @@ -143,12 +152,25 @@ public class EnterpriseOMRSRepositoryConnector extends OMRSRepositoryConnector i } /** + * Indicates that the connector is completely configured and can begin processing. + * + * @throws ConnectorCheckedException - there is a problem within the connector. + */ +public void start() throws ConnectorCheckedException +{ +super.start(); +} + + +/** * Free up any resources held since the connector is no longer needed. * * @throws ConnectorCheckedException - there is a problem disconnecting the connector. */ public void disconnect() throws ConnectorCheckedException { +super.disconnect(); + if ((connectorManager != null) && (connectorConsumerId != null)) { connectorManager.unregisterConnectorConsumer(connectorConsumerId); @@ -228,9 +250,31 @@ public class EnterpriseOMRSRepositoryConnector extends OMRSRepositoryConnector i /** + * Return a repository helper that can be used by an OMAS to create types and instance objects. + * + * @return an OMRSRepositoryHelper object that is linked to the repository content manager for this server. + */ +public OMRSRepositoryHelper getRepositoryHelper() +{ +return super.repositoryHelper; +} + + +/** + * Return a repository validator that can be used by an OMAS to validate types and instance objects. + * + * @return an OMRSRepositoryValidator object that is linked to the repository content manager for this server. + */ +public OMRSRepositoryValidator getRepositoryValidator() +{ +return super.repositoryValidator; +} + + +/** * Save the connector to the local repository. This is passed from the OMRSConnectorManager. * - * @param metadataCollectionId - Unique identifier for the metadata collection + * @param metadataCollectionId - Unique identifier for the metadata collection. * @param localConnector -
[07/31] atlas git commit: ATLAS-2122 OMAG Server Application and OMRS APIs
http://git-wip-us.apache.org/repos/asf/atlas/blob/a1fd4068/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/MatchCriteria.java -- diff --git a/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/MatchCriteria.java b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/MatchCriteria.java index b60558e..300f28a 100644 --- a/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/MatchCriteria.java +++ b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/MatchCriteria.java @@ -18,8 +18,15 @@ package org.apache.atlas.omrs.metadatacollection.properties; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + import java.io.Serializable; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + /** * The MatchCriteria enum defines how the metadata instances in the metadata collection should be matched * against the properties supplied on the search request. @@ -29,6 +36,9 @@ import java.io.Serializable; * NONE means return instances where none of the supplied properties match. * */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) public enum MatchCriteria implements Serializable { ALL (0, "All", "All properties must match."), http://git-wip-us.apache.org/repos/asf/atlas/blob/a1fd4068/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/SequencingOrder.java -- diff --git a/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/SequencingOrder.java b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/SequencingOrder.java index 9ed91c7..5c1998f 100644 --- a/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/SequencingOrder.java +++ b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/SequencingOrder.java @@ -17,8 +17,15 @@ */ package org.apache.atlas.omrs.metadatacollection.properties; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + import java.io.Serializable; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + /** * SequencingOrder is used for search requests against a metadata collection. It defines how the results should * to be ordered before they are returned. This is particularly important when the results are to returned @@ -55,6 +62,9 @@ import java.io.Serializable; * * */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) public enum SequencingOrder implements Serializable { ANY (0, "Any Order", "Any order."), http://git-wip-us.apache.org/repos/asf/atlas/blob/a1fd4068/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/ArrayPropertyValue.java -- diff --git a/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/ArrayPropertyValue.java b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/ArrayPropertyValue.java index 055293d..154eb16 100644 --- a/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/ArrayPropertyValue.java +++ b/omrs/src/main/java/org/apache/atlas/omrs/metadatacollection/properties/instances/ArrayPropertyValue.java @@ -17,14 +17,25 @@ */ package org.apache.atlas.omrs.metadatacollection.properties.instances; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; import org.apache.atlas.omrs.ffdc.OMRSErrorCode; import org.apache.atlas.omrs.ffdc.exception.OMRSRuntimeException; +import java.util.Objects; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + /** * ArrayPropertyValue stores the values of an array within an entity, struct or relationship properties. * The elements of the array are stored in an InstanceProperties map where the property name is set to the element * number
[28/31] atlas git commit: ATLAS-2122 OMAG Server Application and OMRS APIs
http://git-wip-us.apache.org/repos/asf/atlas/blob/a1fd4068/omag-api/src/main/java/org/apache/atlas/omag/ffdc/exception/OMAGNotAuthorizedException.java -- diff --git a/omag-api/src/main/java/org/apache/atlas/omag/ffdc/exception/OMAGNotAuthorizedException.java b/omag-api/src/main/java/org/apache/atlas/omag/ffdc/exception/OMAGNotAuthorizedException.java new file mode 100644 index 000..2400f0c --- /dev/null +++ b/omag-api/src/main/java/org/apache/atlas/omag/ffdc/exception/OMAGNotAuthorizedException.java @@ -0,0 +1,57 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * 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.omag.ffdc.exception; + +/** + * OMAGNotAuthorizedException is used when invalid parameters are passed on an OMAG call. + */ +public class OMAGNotAuthorizedException extends OMAGCheckedExceptionBase +{ +/** + * This is the typical constructor used for creating a OMAGNotAuthorizedException. + * + * @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 OMAGNotAuthorizedException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction) +{ +super(httpCode, className, actionDescription, errorMessage, systemAction, userAction); +} + + +/** + * This is the constructor used for creating a OMAGNotAuthorizedException that resulted from a previous error. + * + * @param httpCode - http response code to use if this exception flows over a REST call + * @param className - name of class reporting error + * @param actionDescription - description of function it was performing when error detected + * @param errorMessage - description of error + * @param systemAction - actions of the system as a result of the error + * @param userAction - instructions for correcting the error + * @param caughtError - the error that resulted in this exception. + * */ +public OMAGNotAuthorizedException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction, Throwable caughtError) +{ +super(httpCode, className, actionDescription, errorMessage, systemAction, userAction, caughtError); +} +} http://git-wip-us.apache.org/repos/asf/atlas/blob/a1fd4068/omag-server/pom.xml -- diff --git a/omag-server/pom.xml b/omag-server/pom.xml new file mode 100644 index 000..7ebfdeb --- /dev/null +++ b/omag-server/pom.xml @@ -0,0 +1,125 @@ + + + +http://maven.apache.org/POM/4.0.0; + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance; + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd;> + +4.0.0 + + +apache-atlas +org.apache.atlas +1.0.0-SNAPSHOT + + +omag-server + +Open Metadata and Governance (OMAG) Server + +Open Metadata and Governance (OMAG) server for running open metadata function outside of the Apache Atlas server. + + +jar + + + + +org.springframework.boot +spring-boot-starter +1.5.7.RELEASE + + + +org.springframework.boot +spring-boot-starter-web +1.5.7.RELEASE + + + +commons-collections +commons-collections + + + +commons-io +commons-io + + + +com.fasterxml.jackson.jaxrs +jackson-jaxrs-base +${jackson.version} + + + +com.fasterxml.jackson.jaxrs +jackson-jaxrs-json-provider +${jackson.version} + + + +
[15/31] atlas git commit: ATLAS-2122 OMAG Server Application and OMRS APIs
http://git-wip-us.apache.org/repos/asf/atlas/blob/a1fd4068/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositoryconnector/LocalOMRSMetadataCollection.java -- diff --git a/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositoryconnector/LocalOMRSMetadataCollection.java b/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositoryconnector/LocalOMRSMetadataCollection.java index a46c28e..544085a 100644 --- a/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositoryconnector/LocalOMRSMetadataCollection.java +++ b/omrs/src/main/java/org/apache/atlas/omrs/localrepository/repositoryconnector/LocalOMRSMetadataCollection.java @@ -21,13 +21,15 @@ import org.apache.atlas.omrs.eventmanagement.OMRSRepositoryEventProcessor; import org.apache.atlas.omrs.ffdc.*; import org.apache.atlas.omrs.ffdc.exception.*; import org.apache.atlas.omrs.localrepository.repositorycontentmanager.OMRSRepositoryContentManager; +import org.apache.atlas.omrs.localrepository.repositorycontentmanager.OMRSRepositoryHelper; +import org.apache.atlas.omrs.localrepository.repositorycontentmanager.OMRSRepositoryValidator; import org.apache.atlas.omrs.metadatacollection.OMRSMetadataCollection; import org.apache.atlas.omrs.metadatacollection.properties.MatchCriteria; import org.apache.atlas.omrs.metadatacollection.properties.SequencingOrder; import org.apache.atlas.omrs.metadatacollection.properties.instances.*; import org.apache.atlas.omrs.metadatacollection.properties.typedefs.*; -import java.util.ArrayList; +import java.util.List; import java.util.Date; /** @@ -36,14 +38,16 @@ import java.util.Date; */ public class LocalOMRSMetadataCollection extends OMRSMetadataCollection { -private static final String sourceName = "Local Repository"; +private static final String repositoryName = "Local Repository"; -private OMRSMetadataCollection realMetadataCollection = null; -private String localServerName = null; -private String localServerType = null; -private String localOrganizationName= null; -private OMRSRepositoryEventProcessor outboundRepositoryEventProcessor = null; -private OMRSRepositoryContentManager localRepositoryContentManager= null; +private OMRSMetadataCollection realMetadataCollection; +private String localServerName; +private String localServerType; +private String localOrganizationName; +private OMRSRepositoryEventProcessor outboundRepositoryEventProcessor; +private OMRSRepositoryContentManager localRepositoryContentManager; +private OMRSRepositoryValidator repositoryValidator; +private OMRSRepositoryHelper repositoryHelper; /** @@ -53,7 +57,7 @@ public class LocalOMRSMetadataCollection extends OMRSMetadataCollection * @param localServerName - name of the local server. * @param localServerType - type of the local server. * @param localOrganizationName - name of the organization that owns the local server. - * @param realMetadataCollection - metadata collection of the rela local connector. + * @param realMetadataCollection - metadata collection of the real local connector. * @param outboundRepositoryEventProcessor - outbound event processor * (may be null if a repository event mapper is deployed). * @param repositoryContentManager - manager of in-memory cache of type definitions (TypeDefs). @@ -72,13 +76,13 @@ public class LocalOMRSMetadataCollection extends OMRSMetadataCollection super(localMetadataConnectionId); /* - * Save the metadata collection object for the real repository. This is the metadata that does all of the - * work. LocalOMRSMetadataCollection is just a wrapper for managing repository events and debug and - * audit logging. + * Save the metadata collection object for the real repository. This is the metadata collection that + * does all of the work. LocalOMRSMetadataCollection is just a wrapper for managing repository events + * and debug and audit logging. */ if (realMetadataCollection == null) { -StringactionDescription = "Local OMRS Metadata Collection Constructor"; +final String actionDescription = "Local OMRS Metadata Collection Constructor"; OMRSErrorCode errorCode = OMRSErrorCode.NULL_LOCAL_METADATA_COLLECTION; StringerrorMessage = errorCode.getErrorMessageId() @@ -101,6 +105,8 @@ public class LocalOMRSMetadataCollection extends OMRSMetadataCollection this.localOrganizationName = localOrganizationName;
[04/31] atlas git commit: ATLAS-2122 OMAG Server Application and OMRS APIs
http://git-wip-us.apache.org/repos/asf/atlas/blob/a1fd4068/omrs/src/main/java/org/apache/atlas/omrs/rest/repositoryconnector/OMRSRESTMetadataCollection.java -- diff --git a/omrs/src/main/java/org/apache/atlas/omrs/rest/repositoryconnector/OMRSRESTMetadataCollection.java b/omrs/src/main/java/org/apache/atlas/omrs/rest/repositoryconnector/OMRSRESTMetadataCollection.java index db48af7..3aa1330 100644 --- a/omrs/src/main/java/org/apache/atlas/omrs/rest/repositoryconnector/OMRSRESTMetadataCollection.java +++ b/omrs/src/main/java/org/apache/atlas/omrs/rest/repositoryconnector/OMRSRESTMetadataCollection.java @@ -17,8 +17,22 @@ */ package org.apache.atlas.omrs.rest.repositoryconnector; -import org.apache.atlas.omrs.ffdc.exception.NotImplementedRuntimeException; -import org.apache.atlas.omrs.metadatacollection.OMRSMetadataCollectionBase; +import org.apache.atlas.ocf.properties.Connection; +import org.apache.atlas.ocf.properties.Endpoint; +import org.apache.atlas.omrs.ffdc.OMRSErrorCode; +import org.apache.atlas.omrs.ffdc.exception.*; +import org.apache.atlas.omrs.localrepository.repositorycontentmanager.OMRSRepositoryHelper; +import org.apache.atlas.omrs.localrepository.repositorycontentmanager.OMRSRepositoryValidator; +import org.apache.atlas.omrs.metadatacollection.OMRSMetadataCollection; +import org.apache.atlas.omrs.metadatacollection.properties.MatchCriteria; +import org.apache.atlas.omrs.metadatacollection.properties.SequencingOrder; +import org.apache.atlas.omrs.metadatacollection.properties.instances.*; +import org.apache.atlas.omrs.metadatacollection.properties.typedefs.*; +import org.apache.atlas.omrs.rest.properties.*; +import org.springframework.web.client.RestTemplate; + +import java.util.Date; +import java.util.List; /** * The OMRSRESTMetadataCollection represents a remote metadata repository that supports the OMRS REST API. @@ -29,9 +43,16 @@ import org.apache.atlas.omrs.metadatacollection.OMRSMetadataCollectionBase; * This class is using OMRSMetadataCollectionBase while it is under construction. It will change to * inheriting from OMRSMetadataCollection once it is implemented */ -public class OMRSRESTMetadataCollection extends OMRSMetadataCollectionBase +public class OMRSRESTMetadataCollection extends OMRSMetadataCollection { -private OMRSRESTRepositoryConnector parentConnector = null; +static final private String defaultRepositoryName = "REST-connected Repository "; + +private OMRSRESTRepositoryConnector parentConnector;/* Initialized in constructor */ +private StringmetadataCollectionId; /* Initialized in constructor */ +private OMRSRepositoryHelper repositoryHelper; /* Initialized in constructor */ +private OMRSRepositoryValidator repositoryValidator;/* Initialized in constructor */ +private StringrepositoryName; /* Initialized in constructor */ +private StringrestURLRoot;/* Initialized in constructor */ /** * Default constructor. @@ -41,19 +62,4909 @@ public class OMRSRESTMetadataCollection extends OMRSMetadataCollectionBase * @param metadataCollectionId - unique identifier for the metadata collection */ public OMRSRESTMetadataCollection(OMRSRESTRepositoryConnector parentConnector, + OMRSRepositoryHelper repositoryHelper, + OMRSRepositoryValidator repositoryValidator, String metadataCollectionId) { +/* + * The metadata collection Id is the unique Id for the metadata collection. It is managed by the super class. + */ super(metadataCollectionId); +this.metadataCollectionId = metadataCollectionId; /* - * Save parentConnector since this has the connection information. + * Save parentConnector since this has the connection information and access to the metadata about the + * metadata cluster. */ this.parentConnector = parentConnector; /* - * This is a temporary implementation to allow the structural implementation of the connectors to - * be committed before the metadata collection implementation is complete. + * Save the repository helper and validator as they reduce the implementation effort of the metadata + * collection. */ -throw new NotImplementedRuntimeException("OMRSRESTMetadataCollection", "constructor", "ATLAS-1773"); +this.repositoryHelper = repositoryHelper; +this.repositoryValidator = repositoryValidator; + +/* + * The name of the repository comes from the connection + */ +Connection
atlas git commit: ATLAS-2535: import-hive doesn't update entity already present in Atlas
Repository: atlas Updated Branches: refs/heads/master a1fd40682 -> 37d7b8b8f ATLAS-2535: import-hive doesn't update entity already present in Atlas Signed-off-by: Madhan NeethirajProject: http://git-wip-us.apache.org/repos/asf/atlas/repo Commit: http://git-wip-us.apache.org/repos/asf/atlas/commit/37d7b8b8 Tree: http://git-wip-us.apache.org/repos/asf/atlas/tree/37d7b8b8 Diff: http://git-wip-us.apache.org/repos/asf/atlas/diff/37d7b8b8 Branch: refs/heads/master Commit: 37d7b8b8f72b906cb2c133f9b3d843009c92e408 Parents: a1fd406 Author: rmani Authored: Thu Apr 5 17:37:50 2018 -0700 Committer: Madhan Neethiraj Committed: Fri Apr 6 10:06:23 2018 -0700 -- .../atlas/hive/bridge/HiveMetaStoreBridge.java | 61 1 file changed, 51 insertions(+), 10 deletions(-) -- http://git-wip-us.apache.org/repos/asf/atlas/blob/37d7b8b8/addons/hive-bridge/src/main/java/org/apache/atlas/hive/bridge/HiveMetaStoreBridge.java -- diff --git a/addons/hive-bridge/src/main/java/org/apache/atlas/hive/bridge/HiveMetaStoreBridge.java b/addons/hive-bridge/src/main/java/org/apache/atlas/hive/bridge/HiveMetaStoreBridge.java index 65cdd99..da44ff2 100755 --- a/addons/hive-bridge/src/main/java/org/apache/atlas/hive/bridge/HiveMetaStoreBridge.java +++ b/addons/hive-bridge/src/main/java/org/apache/atlas/hive/bridge/HiveMetaStoreBridge.java @@ -67,6 +67,7 @@ import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.util.ArrayList; +import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Map; @@ -235,10 +236,6 @@ public class HiveMetaStoreBridge { return hiveClient; } -public AtlasClientV2 getAtlasClient() { -return atlasClientV2; -} - public boolean isConvertHdfsPathToLowerCase() { return convertHdfsPathToLowerCase; } @@ -458,6 +455,8 @@ public class HiveMetaStoreBridge { } } +clearRelationshipAttributes(ret); + return ret; } @@ -494,6 +493,8 @@ public class HiveMetaStoreBridge { } } +clearRelationshipAttributes(ret); + return ret; } @@ -589,10 +590,6 @@ public class HiveMetaStoreBridge { tableEntity.setAttribute(ATTRIBUTE_PARTITION_KEYS, BaseHiveEvent.getObjectIds(partKeys)); tableEntity.setAttribute(ATTRIBUTE_COLUMNS, BaseHiveEvent.getObjectIds(columns)); -if (MapUtils.isNotEmpty(table.getReferredEntities())) { -table.getReferredEntities().clear(); -} - table.addReferredEntity(database); table.addReferredEntity(sdEntity); @@ -608,6 +605,8 @@ public class HiveMetaStoreBridge { } } +table.setEntity(tableEntity); + return table; } @@ -758,10 +757,10 @@ public class HiveMetaStoreBridge { } private AtlasEntityWithExtInfo findEntity(final String typeName, final String qualifiedName) throws AtlasServiceException { -AtlasClientV2 atlasClientV2 = getAtlasClient(); +AtlasEntityWithExtInfo ret = null; try { -return atlasClientV2.getEntityByAttribute(typeName, Collections.singletonMap(ATTRIBUTE_QUALIFIED_NAME, qualifiedName)); +ret = atlasClientV2.getEntityByAttribute(typeName, Collections.singletonMap(ATTRIBUTE_QUALIFIED_NAME, qualifiedName)); } catch (AtlasServiceException e) { if(e.getStatus() == ClientResponse.Status.NOT_FOUND) { return null; @@ -769,6 +768,10 @@ public class HiveMetaStoreBridge { throw e; } + +clearRelationshipAttributes(ret); + +return ret; } private String getCreateTableString(Table table, String location){ @@ -879,4 +882,42 @@ public class HiveMetaStoreBridge { public static long getTableCreatedTime(Table table) { return table.getTTable().getCreateTime() * MILLIS_CONVERT_FACTOR; } + +private void clearRelationshipAttributes(AtlasEntitiesWithExtInfo entities) { +if (entities != null) { +if (entities.getEntities() != null) { +for (AtlasEntity entity : entities.getEntities()) { +clearRelationshipAttributes(entity);; +} +} + +if (entities.getReferredEntities() != null) { + clearRelationshipAttributes(entities.getReferredEntities().values()); +} +} +} + +private void clearRelationshipAttributes(AtlasEntityWithExtInfo entity) { +if (entity != null) { +clearRelationshipAttributes(entity.getEntity()); + +if (entity.getReferredEntities() != null) { +