diff --git a/open-metadata-implementation/access-services/asset-catalog/asset-catalog-api/src/main/java/org/odpi/openmetadata/accessservices/assetcatalog/exception/AssetCatalogErrorCode.java b/open-metadata-implementation/access-services/asset-catalog/asset-catalog-api/src/main/java/org/odpi/openmetadata/accessservices/assetcatalog/exception/AssetCatalogErrorCode.java index 351b16d6235..bcdd67d9f6e 100644 --- a/open-metadata-implementation/access-services/asset-catalog/asset-catalog-api/src/main/java/org/odpi/openmetadata/accessservices/assetcatalog/exception/AssetCatalogErrorCode.java +++ b/open-metadata-implementation/access-services/asset-catalog/asset-catalog-api/src/main/java/org/odpi/openmetadata/accessservices/assetcatalog/exception/AssetCatalogErrorCode.java @@ -41,25 +41,17 @@ public enum AssetCatalogErrorCode implements ExceptionMessageSet { "The system is unable to retrieve the assets neighborhood from the specified asset identifier.", "Check that the unique identifier for the asset is correct."), - LINKING_RELATIONSHIPS_NOT_FOUND(404, "OMAS-ASSET-CATALOG-404-015 ", - "There is no intermediate relationships that connect the {0} with the {1} in OMAS Server {2}", - "The system is unable to retrieve the linking relationship.", - "Check that the unique identifier for the asset is correct."), - - LINKING_ASSETS_NOT_FOUND(404, "OMAS-ASSET-CATALOG-404-016 ", - "There is no intermediate assets that connect the {0} with the {1} in OMAS Server {2}", - "The system is unable to retrieve linking assets.", - "Check that the unique identifier for the asset is correct."), - TYPE_DEF_NOT_FOUND(404, "OMAS-ASSET-CATALOG-404-017 ", - "The provided entity type/s are non known to the OMAS Server", + "The provided entity type {0} is non known to the OMAS Server", "The system is unable to retrieve assets of an unknown type/s.", "Check that the entity type/s provided is/are correct."), SERVICE_NOT_INITIALIZED(503, "OMAS-ASSET-CATALOG-503-001 ", "The access service has not been initialized for server {0} and can not support REST API calls", - "The server has received a call to one of its open metadata access services but is unable to process it because the access service is not active for the requested server.", - "If the server is supposed to have this access service activated, correct the server configuration and restart the server."); + "The server has received a call to one of its open metadata access services but is unable to " + + "process it because the access service is not active for the requested server.", + "If the server is supposed to have this access service activated, correct the server configuration " + + "and restart the server."); private static final long serialVersionUID = 1L; diff --git a/open-metadata-implementation/access-services/asset-catalog/asset-catalog-client/docs/user/asset-catalog-omas-client.md b/open-metadata-implementation/access-services/asset-catalog/asset-catalog-client/docs/user/asset-catalog-omas-client.md index ec6c4253494..6bd8b11c63e 100644 --- a/open-metadata-implementation/access-services/asset-catalog/asset-catalog-client/docs/user/asset-catalog-omas-client.md +++ b/open-metadata-implementation/access-services/asset-catalog/asset-catalog-client/docs/user/asset-catalog-omas-client.md @@ -41,16 +41,10 @@ Once you have an instance of the client, you can use it to: * Fetch the classification for a specific asset - [getClassificationsForAsset]() -* Returns a sub-graph of intermediate assets that connected two assets - [getLinkingAssets]() - -* Return a sub-graph of relationships that connect two assets - [getLinkingRelationships]() - * Returns a list of supported asset types - [getSupportedTypes]() -* Returns the sub-graph that represents the list of assets that in neighborhood of the given asset - [getAssetsFromNeighborhood]() - -* Return a list of assets matching the search criteria without the full context [searchByType](). Entity types are case -insensitive, so proper values should be given in the request, otherwise an EntityNotKnownException will be thrown. If +* Return a list of assets matching the search criteria without the full context [searchByType](). Entity types are case + insensitive, so proper values should be given in the request, otherwise an EntityNotKnownException will be thrown. If no type will be provided the operation will be made using the default search types. In order to determine de supported types call [getSupportedTypes]() before. diff --git a/open-metadata-implementation/access-services/asset-catalog/asset-catalog-client/src/main/java/org/odpi/openmetadata/accessservices/assetcatalog/AssetCatalog.java b/open-metadata-implementation/access-services/asset-catalog/asset-catalog-client/src/main/java/org/odpi/openmetadata/accessservices/assetcatalog/AssetCatalog.java index 51fce8d7fac..62341f00f51 100644 --- a/open-metadata-implementation/access-services/asset-catalog/asset-catalog-client/src/main/java/org/odpi/openmetadata/accessservices/assetcatalog/AssetCatalog.java +++ b/open-metadata-implementation/access-services/asset-catalog/asset-catalog-client/src/main/java/org/odpi/openmetadata/accessservices/assetcatalog/AssetCatalog.java @@ -36,9 +36,6 @@ public class AssetCatalog extends OCFRESTClient implements AssetCatalogInterface private static final String ASSET_UNIVERSE = "/asset-universe/{2}?assetType={3}"; private static final String ASSET_RELATIONSHIPS = "/asset-relationships/{2}?assetType={3}&relationshipType={4}&from={5}&pageSize={6}"; private static final String ASSET_CLASSIFICATIONS = "/asset-classifications/{2}?assetType={3}&classificationName={4}"; - private static final String LINKING_ASSET = "/linking-assets/from/{2}/to/{3}"; - private static final String LINKING_RELATIONSHIPS = "/linking-assets-relationships/from/{2}/to/{3}"; - private static final String ASSETS_FROM_NEIGHBORHOOD = "/assets-from-neighborhood/{2}"; private static final String SEARCH = "/search?searchCriteria={2}"; private static final String ASSET_CONTEXT = "/asset-context/{2}?assetType={3}"; private static final String RELATIONSHIP_BETWEEN_ENTITIES = "/relationship-between-entities/{2}/{3}?relationshipType={4}"; @@ -50,8 +47,8 @@ public class AssetCatalog extends OCFRESTClient implements AssetCatalogInterface private static final String SEARCH_PARAMETERS = "searchParameters"; - private InvalidParameterHandler invalidParameterHandler = new InvalidParameterHandler(); - private RESTExceptionHandler restExceptionHandler = new RESTExceptionHandler(); + private final InvalidParameterHandler invalidParameterHandler = new InvalidParameterHandler(); + private final RESTExceptionHandler restExceptionHandler = new RESTExceptionHandler(); /** * Create a new AssetCatalog client. @@ -153,66 +150,6 @@ public ClassificationListResponse getClassificationsForAsset(String userId, return classificationListResponse; } - /** - * {@inheritDoc} - */ - @Override - public AssetCatalogListResponse getLinkingAssets(String userId, - String startAssetGUID, - String endAssetGUID) - throws InvalidParameterException, PropertyServerException { - String methodName = "getLinkingAssets"; - - validateStartAndEndAssetsGUIDs(userId, startAssetGUID, endAssetGUID, methodName); - - AssetCatalogListResponse response = callGetRESTCall(methodName, AssetCatalogListResponse.class, - serverPlatformURLRoot + BASE_PATH + LINKING_ASSET, serverName, - userId, startAssetGUID, endAssetGUID); - - detectExceptions(response); - return response; - } - - /** - * {@inheritDoc} - */ - @Override - public RelationshipListResponse getLinkingRelationships(String userId, - String startAssetGUID, - String endAssetGUID) - throws InvalidParameterException, PropertyServerException { - String methodName = "getLinkingRelationships"; - - validateStartAndEndAssetsGUIDs(userId, startAssetGUID, endAssetGUID, methodName); - - RelationshipListResponse response = callGetRESTCall(methodName, RelationshipListResponse.class, - serverPlatformURLRoot + BASE_PATH + LINKING_RELATIONSHIPS, serverName, - userId, startAssetGUID, endAssetGUID); - detectExceptions(response); - - return response; - } - - /** - * {@inheritDoc} - */ - @Override - public AssetCatalogListResponse getAssetsFromNeighborhood(String userId, - String assetGUID, - SearchParameters searchParameters) - throws InvalidParameterException, PropertyServerException { - String methodName = "getAssetsFromNeighborhood"; - - validateSearchParams(userId, assetGUID, searchParameters, methodName); - - AssetCatalogListResponse response = callPostRESTCall(methodName, AssetCatalogListResponse.class, - serverPlatformURLRoot + BASE_PATH + ASSETS_FROM_NEIGHBORHOOD, searchParameters, serverName, userId, assetGUID); - - detectExceptions(response); - - return response; - } - /** * {@inheritDoc} */ diff --git a/open-metadata-implementation/access-services/asset-catalog/asset-catalog-client/src/main/java/org/odpi/openmetadata/accessservices/assetcatalog/AssetCatalogInterface.java b/open-metadata-implementation/access-services/asset-catalog/asset-catalog-client/src/main/java/org/odpi/openmetadata/accessservices/assetcatalog/AssetCatalogInterface.java index 7e166e545e5..d67aebd7b5e 100644 --- a/open-metadata-implementation/access-services/asset-catalog/asset-catalog-client/src/main/java/org/odpi/openmetadata/accessservices/assetcatalog/AssetCatalogInterface.java +++ b/open-metadata-implementation/access-services/asset-catalog/asset-catalog-client/src/main/java/org/odpi/openmetadata/accessservices/assetcatalog/AssetCatalogInterface.java @@ -4,7 +4,6 @@ import org.odpi.openmetadata.accessservices.assetcatalog.model.rest.body.SearchParameters; import org.odpi.openmetadata.accessservices.assetcatalog.model.rest.responses.AssetCatalogResponse; import org.odpi.openmetadata.accessservices.assetcatalog.model.rest.responses.AssetCatalogSupportedTypes; -import org.odpi.openmetadata.accessservices.assetcatalog.model.rest.responses.AssetCatalogListResponse; import org.odpi.openmetadata.accessservices.assetcatalog.model.rest.responses.AssetListResponse; import org.odpi.openmetadata.accessservices.assetcatalog.model.rest.responses.AssetResponse; import org.odpi.openmetadata.accessservices.assetcatalog.model.rest.responses.ClassificationListResponse; @@ -77,42 +76,6 @@ public interface AssetCatalogInterface { */ ClassificationListResponse getClassificationsForAsset(String userId, String assetGUID, String assetType, String classificationName) throws InvalidParameterException, PropertyServerException; - /** - * Returns a sub-graph of intermediate assets that connected two assets - * - * @param userId the unique identifier for the user - * @param startAssetGUID the starting asset identifier of the query - * @param endAssetGUID the ending asset identifier of the query - * @return a list of assets between the given assets - * @throws PropertyServerException if a problem occurs while serving the request - * @throws InvalidParameterException if parameter validation fails - */ - AssetCatalogListResponse getLinkingAssets(String userId, String startAssetGUID, String endAssetGUID) throws InvalidParameterException, PropertyServerException; - - /** - * Return a sub-graph of relationships that connect two assets - * - * @param userId the unique identifier for the user - * @param startAssetGUID the starting asset identifier of the query - * @param endAssetGUID the ending asset identifier of the query - * @return a list of relationships that connects the assets - * @throws PropertyServerException if a problem occurs while serving the request - * @throws InvalidParameterException if parameter validation fails - */ - RelationshipListResponse getLinkingRelationships(String userId, String startAssetGUID, String endAssetGUID) throws InvalidParameterException, PropertyServerException; - - /** - * Returns the sub-graph that represents the list of assets that in neighborhood of the given asset - * - * @param userId the unique identifier for the user - * @param assetGUID the starting asset identifier of the query - * @param searchParameters constrains to make the assets's search results more precise - * @return a list of assets that in neighborhood of the given asset - * @throws PropertyServerException if a problem occurs while serving the request - * @throws InvalidParameterException if parameter validation fails - */ - AssetCatalogListResponse getAssetsFromNeighborhood(String userId, String assetGUID, SearchParameters searchParameters) throws InvalidParameterException, PropertyServerException; - /** * Return a list of assets matching the search criteria without the full context * diff --git a/open-metadata-implementation/access-services/asset-catalog/asset-catalog-client/src/test/java/org/odpi/openmetadata/accessservices/assetcatalog/AssetCatalogClientTest.java b/open-metadata-implementation/access-services/asset-catalog/asset-catalog-client/src/test/java/org/odpi/openmetadata/accessservices/assetcatalog/AssetCatalogClientTest.java index 8e9e5e5c9c2..cab0df43955 100644 --- a/open-metadata-implementation/access-services/asset-catalog/asset-catalog-client/src/test/java/org/odpi/openmetadata/accessservices/assetcatalog/AssetCatalogClientTest.java +++ b/open-metadata-implementation/access-services/asset-catalog/asset-catalog-client/src/test/java/org/odpi/openmetadata/accessservices/assetcatalog/AssetCatalogClientTest.java @@ -140,66 +140,6 @@ public void testGetClassificationsForAsset() throws Exception { Assert.assertEquals(CLASSIFICATION_NAME, classificationListResponse.getClassifications().get(0).getName()); } - @Test - public void testGetLinkingAssets() throws Exception { - AssetCatalogListResponse response = mockAssetDescriptionListResponse(); - - when(connector.callGetRESTCall(eq("getLinkingAssets"), - eq(AssetCatalogListResponse.class), - anyString(), - eq(SERVER_NAME), - eq(USER_ID), - eq(ASSET_ID), - eq(SECOND_ASSET_ID))).thenReturn(response); - - AssetCatalogListResponse assetCatalogListResponse = assetCatalog.getLinkingAssets(USER_ID, - ASSET_ID, - SECOND_ASSET_ID); - - Assert.assertEquals(ASSET_ID, assetCatalogListResponse.getAssetCatalogBeanList().get(0).getGuid()); - } - - @Test - public void testGetLinkingRelationships() throws Exception { - RelationshipListResponse response = mockRelationshipsResponse(); - - when(connector.callGetRESTCall(eq("getLinkingRelationships"), - eq(RelationshipListResponse.class), - anyString(), - eq(SERVER_NAME), - eq(USER_ID), - eq(ASSET_ID), - eq(SECOND_ASSET_ID))).thenReturn(response); - - RelationshipListResponse relationshipListResponse = assetCatalog.getLinkingRelationships(USER_ID, - ASSET_ID, - SECOND_ASSET_ID); - - Assert.assertEquals(ASSET_ID, relationshipListResponse.getRelationships().get(0).getFromEntity().getGuid()); - Assert.assertEquals(SECOND_ASSET_ID, relationshipListResponse.getRelationships().get(0).getToEntity().getGuid()); - } - - @Test - public void testGetAssetsFromNeighborhood() throws Exception { - AssetCatalogListResponse response = mockAssetDescriptionListResponse(); - SearchParameters searchParameters = mockSearchParameters(); - - when(connector.callPostRESTCall(eq("getAssetsFromNeighborhood"), - eq(AssetCatalogListResponse.class), - anyString(), - eq(searchParameters), - eq(SERVER_NAME), - eq(USER_ID), - eq(ASSET_ID) - )).thenReturn(response); - - AssetCatalogListResponse assetsFromNeighborhood = assetCatalog.getAssetsFromNeighborhood(USER_ID, - ASSET_ID, - searchParameters); - - Assert.assertEquals(ASSET_ID, assetsFromNeighborhood.getAssetCatalogBeanList().get(0).getGuid()); - } - @Test public void testSearchByType() throws Exception { AssetListResponse response = mockAssetListResponse(); diff --git a/open-metadata-implementation/access-services/asset-catalog/asset-catalog-server/build.gradle b/open-metadata-implementation/access-services/asset-catalog/asset-catalog-server/build.gradle index d045044b5b8..7d0c45b168c 100644 --- a/open-metadata-implementation/access-services/asset-catalog/asset-catalog-server/build.gradle +++ b/open-metadata-implementation/access-services/asset-catalog/asset-catalog-server/build.gradle @@ -14,11 +14,13 @@ dependencies { implementation project(':open-metadata-implementation:admin-services:admin-services-registration') implementation project(':open-metadata-implementation:repository-services:repository-services-apis') implementation project(':open-metadata-implementation:common-services:multi-tenant') + implementation project(':open-metadata-implementation:common-services:generic-handlers') implementation 'org.apache.commons:commons-collections4' implementation project(':open-metadata-implementation:common-services:repository-handler') implementation project(':open-metadata-implementation:frameworks:open-connector-framework') implementation project(':open-metadata-implementation:common-services:ffdc-services') implementation project(':open-metadata-implementation:common-services:ocf-metadata-management:ocf-metadata-handlers') + implementation project(':open-metadata-implementation:common-services:metadata-security:metadata-security-server') implementation 'org.slf4j:slf4j-api' implementation 'org.springframework:spring-core' implementation 'com.fasterxml.jackson.core:jackson-databind' diff --git a/open-metadata-implementation/access-services/asset-catalog/asset-catalog-server/pom.xml b/open-metadata-implementation/access-services/asset-catalog/asset-catalog-server/pom.xml index b2fc580d1d8..45a0c7aae06 100644 --- a/open-metadata-implementation/access-services/asset-catalog/asset-catalog-server/pom.xml +++ b/open-metadata-implementation/access-services/asset-catalog/asset-catalog-server/pom.xml @@ -94,6 +94,11 @@ ocf-metadata-handlers + + org.odpi.egeria + generic-handlers + + org.mockito mockito-core diff --git a/open-metadata-implementation/access-services/asset-catalog/asset-catalog-server/src/main/java/org/odpi/openmetadata/accessservices/assetcatalog/admin/AssetCatalogAdmin.java b/open-metadata-implementation/access-services/asset-catalog/asset-catalog-server/src/main/java/org/odpi/openmetadata/accessservices/assetcatalog/admin/AssetCatalogAdmin.java index 3f29ff5d7fb..70f71832784 100644 --- a/open-metadata-implementation/access-services/asset-catalog/asset-catalog-server/src/main/java/org/odpi/openmetadata/accessservices/assetcatalog/admin/AssetCatalogAdmin.java +++ b/open-metadata-implementation/access-services/asset-catalog/asset-catalog-server/src/main/java/org/odpi/openmetadata/accessservices/assetcatalog/admin/AssetCatalogAdmin.java @@ -3,7 +3,7 @@ package org.odpi.openmetadata.accessservices.assetcatalog.admin; import org.odpi.openmetadata.accessservices.assetcatalog.auditlog.AssetCatalogAuditCode; -import org.odpi.openmetadata.accessservices.assetcatalog.listenenrs.AssetCatalogOMRSTopicListener; +import org.odpi.openmetadata.accessservices.assetcatalog.listeners.AssetCatalogOMRSTopicListener; import org.odpi.openmetadata.adminservices.configuration.properties.AccessServiceConfig; import org.odpi.openmetadata.adminservices.configuration.registration.AccessServiceAdmin; import org.odpi.openmetadata.adminservices.configuration.registration.AccessServiceDescription; diff --git a/open-metadata-implementation/access-services/asset-catalog/asset-catalog-server/src/main/java/org/odpi/openmetadata/accessservices/assetcatalog/admin/AssetCatalogServicesInstance.java b/open-metadata-implementation/access-services/asset-catalog/asset-catalog-server/src/main/java/org/odpi/openmetadata/accessservices/assetcatalog/admin/AssetCatalogServicesInstance.java index cc59f92e059..9bd009c966e 100644 --- a/open-metadata-implementation/access-services/asset-catalog/asset-catalog-server/src/main/java/org/odpi/openmetadata/accessservices/assetcatalog/admin/AssetCatalogServicesInstance.java +++ b/open-metadata-implementation/access-services/asset-catalog/asset-catalog-server/src/main/java/org/odpi/openmetadata/accessservices/assetcatalog/admin/AssetCatalogServicesInstance.java @@ -4,11 +4,13 @@ import lombok.Getter; import org.odpi.openmetadata.accessservices.assetcatalog.connectors.outtopic.AssetCatalogOutTopicClientProvider; +import org.odpi.openmetadata.accessservices.assetcatalog.converters.AssetCatalogConverter; import org.odpi.openmetadata.accessservices.assetcatalog.exception.AssetCatalogErrorCode; import org.odpi.openmetadata.accessservices.assetcatalog.handlers.AssetCatalogHandler; -import org.odpi.openmetadata.accessservices.assetcatalog.handlers.CommonHandler; import org.odpi.openmetadata.accessservices.assetcatalog.handlers.RelationshipHandler; +import org.odpi.openmetadata.accessservices.assetcatalog.model.AssetCatalogBean; import org.odpi.openmetadata.adminservices.configuration.registration.AccessServiceDescription; +import org.odpi.openmetadata.commonservices.generichandlers.OpenMetadataAPIGenericHandler; import org.odpi.openmetadata.commonservices.multitenant.OMASServiceInstance; import org.odpi.openmetadata.commonservices.multitenant.ffdc.exceptions.NewInstanceException; import org.odpi.openmetadata.frameworks.auditlog.AuditLog; @@ -69,12 +71,21 @@ class AssetCatalogServicesInstance extends OMASServiceInstance { super.supportedZones = supportedZones; if (repositoryHandler != null) { + AssetCatalogConverter assetCatalogConverter = + new AssetCatalogConverter<>(repositoryHelper, serviceName, serverName); - assetCatalogHandler = new AssetCatalogHandler(serverName, sourceName, invalidParameterHandler, repositoryHandler, repositoryHelper, - errorHandler, supportedZones, supportedTypesForSearch); - CommonHandler commonHandler = new CommonHandler(sourceName, repositoryHandler, repositoryHelper, errorHandler); - relationshipHandler = new RelationshipHandler(sourceName, invalidParameterHandler, repositoryHandler, repositoryHelper, errorHandler, - commonHandler); + OpenMetadataAPIGenericHandler assetHandler = + new OpenMetadataAPIGenericHandler<>(new AssetCatalogConverter<>(repositoryHelper, serviceName, serverName), + AssetCatalogBean.class, serviceName, serverName, invalidParameterHandler, repositoryHandler, + repositoryHelper, localServerUserId, securityVerifier, supportedZones, defaultZones, publishZones, + auditLog); + + assetCatalogHandler = new AssetCatalogHandler(serverName, sourceName, invalidParameterHandler, + repositoryHandler, repositoryHelper, assetHandler, assetCatalogConverter, errorHandler, + supportedZones, supportedTypesForSearch); + + relationshipHandler = new RelationshipHandler(sourceName, invalidParameterHandler, repositoryHandler, + repositoryHelper, assetHandler, errorHandler); } else { final String methodName = "new ServiceInstance"; throw new NewInstanceException(AssetCatalogErrorCode.OMRS_NOT_INITIALIZED.getMessageDefinition(serverName), diff --git a/open-metadata-implementation/access-services/asset-catalog/asset-catalog-server/src/main/java/org/odpi/openmetadata/accessservices/assetcatalog/builders/AssetCatalogConverter.java b/open-metadata-implementation/access-services/asset-catalog/asset-catalog-server/src/main/java/org/odpi/openmetadata/accessservices/assetcatalog/converters/AssetCatalogConverter.java similarity index 95% rename from open-metadata-implementation/access-services/asset-catalog/asset-catalog-server/src/main/java/org/odpi/openmetadata/accessservices/assetcatalog/builders/AssetCatalogConverter.java rename to open-metadata-implementation/access-services/asset-catalog/asset-catalog-server/src/main/java/org/odpi/openmetadata/accessservices/assetcatalog/converters/AssetCatalogConverter.java index 1acc7b5898d..8a62e720e50 100644 --- a/open-metadata-implementation/access-services/asset-catalog/asset-catalog-server/src/main/java/org/odpi/openmetadata/accessservices/assetcatalog/builders/AssetCatalogConverter.java +++ b/open-metadata-implementation/access-services/asset-catalog/asset-catalog-server/src/main/java/org/odpi/openmetadata/accessservices/assetcatalog/converters/AssetCatalogConverter.java @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: Apache 2.0 */ /* Copyright Contributors to the ODPi Egeria project. */ -package org.odpi.openmetadata.accessservices.assetcatalog.builders; +package org.odpi.openmetadata.accessservices.assetcatalog.converters; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.MapUtils; @@ -14,6 +14,7 @@ import org.odpi.openmetadata.accessservices.assetcatalog.model.Relationship; import org.odpi.openmetadata.accessservices.assetcatalog.model.Type; import org.odpi.openmetadata.accessservices.assetcatalog.util.Constants; +import org.odpi.openmetadata.commonservices.generichandlers.OpenMetadataAPIGenericConverter; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.ArrayPropertyValue; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.EntityDetail; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.EntityProxy; @@ -36,14 +37,10 @@ /** * AssetConverter is a helper class that maps the OMRS objects to Asset Catalog model. */ -public class AssetCatalogConverter { +public class AssetCatalogConverter extends OpenMetadataAPIGenericConverter { - private String sourceName; - private OMRSRepositoryHelper repositoryHelper; - - public AssetCatalogConverter(String sourceName, OMRSRepositoryHelper repositoryHelper) { - this.sourceName = sourceName; - this.repositoryHelper = repositoryHelper; + public AssetCatalogConverter(OMRSRepositoryHelper repositoryHelper, String serviceName, String serverName) { + super(repositoryHelper, serviceName, serverName); } /** @@ -78,7 +75,7 @@ public AssetCatalogBean getAssetCatalogBean(EntityDetail entityDetail) { assetCatalogBean.setClassifications(convertClassifications(entityDetail.getClassifications())); } ElementOrigin elementOrigin = new ElementOrigin(); - elementOrigin.setSourceServer(sourceName); + elementOrigin.setSourceServer(serviceName); elementOrigin.setMetadataCollectionId(entityDetail.getMetadataCollectionId()); elementOrigin.setMetadataCollectionName(entityDetail.getMetadataCollectionName()); elementOrigin.setInstanceLicense(entityDetail.getInstanceLicense()); @@ -272,7 +269,7 @@ public Elements buildAssetElements(EntityDetail entityDetail) { element.setProperties(extractProperties(entityDetail.getProperties())); element.setAdditionalProperties(extractAdditionalProperties(entityDetail.getProperties())); ElementOrigin elementOrigin = new ElementOrigin(); - elementOrigin.setSourceServer(sourceName); + elementOrigin.setSourceServer(serviceName); elementOrigin.setMetadataCollectionId(entityDetail.getMetadataCollectionId()); elementOrigin.setMetadataCollectionName(entityDetail.getMetadataCollectionName()); elementOrigin.setInstanceLicense(entityDetail.getInstanceLicense()); @@ -299,7 +296,7 @@ private Element getElement(EntityProxy entityProxy) { asset.setGuid(entityProxy.getGUID()); if (entityProxy.getUniqueProperties() != null) { - asset.setName(repositoryHelper.getStringProperty(sourceName, Constants.NAME, entityProxy.getUniqueProperties(), method)); + asset.setName(repositoryHelper.getStringProperty(serviceName, Constants.NAME, entityProxy.getUniqueProperties(), method)); } asset.setCreatedBy(entityProxy.getCreatedBy()); asset.setCreateTime(entityProxy.getCreateTime()); @@ -331,10 +328,10 @@ private Map extractProperties(InstanceProperties instancePropert instancePropertiesAsMap.forEach((key, value) -> { if (!key.equals(ADDITIONAL_PROPERTIES_PROPERTY_NAME)) { if (value instanceof ArrayPropertyValue) { - List stringArrayProperty = repositoryHelper.getStringArrayProperty(sourceName, key, instanceProperties, methodName); + List stringArrayProperty = repositoryHelper.getStringArrayProperty(serviceName, key, instanceProperties, methodName); properties.put(key, listToString(stringArrayProperty)); } else if (value instanceof MapPropertyValue) { - Map mapProperty = repositoryHelper.getMapFromProperty(sourceName, key, instanceProperties, methodName); + Map mapProperty = repositoryHelper.getMapFromProperty(serviceName, key, instanceProperties, methodName); properties.put(key, mapToString(mapProperty)); } else { properties.put(key, String.valueOf(value)); @@ -349,7 +346,7 @@ private Map extractProperties(InstanceProperties instancePropert private Map extractAdditionalProperties(InstanceProperties instanceProperties) { String methodName = "extractAdditionalProperties"; - return MapUtils.emptyIfNull(repositoryHelper.removeStringMapFromProperty(sourceName, + return MapUtils.emptyIfNull(repositoryHelper.removeStringMapFromProperty(serviceName, ADDITIONAL_PROPERTIES_PROPERTY_NAME, instanceProperties, methodName)); } diff --git a/open-metadata-implementation/access-services/asset-catalog/asset-catalog-server/src/main/java/org/odpi/openmetadata/accessservices/assetcatalog/handlers/AssetCatalogHandler.java b/open-metadata-implementation/access-services/asset-catalog/asset-catalog-server/src/main/java/org/odpi/openmetadata/accessservices/assetcatalog/handlers/AssetCatalogHandler.java index f0847c754bd..9c295f938ac 100644 --- a/open-metadata-implementation/access-services/asset-catalog/asset-catalog-server/src/main/java/org/odpi/openmetadata/accessservices/assetcatalog/handlers/AssetCatalogHandler.java +++ b/open-metadata-implementation/access-services/asset-catalog/asset-catalog-server/src/main/java/org/odpi/openmetadata/accessservices/assetcatalog/handlers/AssetCatalogHandler.java @@ -3,17 +3,18 @@ package org.odpi.openmetadata.accessservices.assetcatalog.handlers; import org.apache.commons.collections4.CollectionUtils; -import org.odpi.openmetadata.accessservices.assetcatalog.builders.AssetCatalogConverter; +import org.odpi.openmetadata.accessservices.assetcatalog.converters.AssetCatalogConverter; import org.odpi.openmetadata.accessservices.assetcatalog.exception.AssetCatalogErrorCode; import org.odpi.openmetadata.accessservices.assetcatalog.exception.AssetCatalogException; import org.odpi.openmetadata.accessservices.assetcatalog.model.AssetCatalogBean; import org.odpi.openmetadata.accessservices.assetcatalog.model.AssetCatalogItemElement; -import org.odpi.openmetadata.accessservices.assetcatalog.model.Elements; import org.odpi.openmetadata.accessservices.assetcatalog.model.Connection; import org.odpi.openmetadata.accessservices.assetcatalog.model.Element; +import org.odpi.openmetadata.accessservices.assetcatalog.model.Elements; import org.odpi.openmetadata.accessservices.assetcatalog.model.Type; import org.odpi.openmetadata.accessservices.assetcatalog.model.rest.body.SearchParameters; import org.odpi.openmetadata.commonservices.ffdc.InvalidParameterHandler; +import org.odpi.openmetadata.commonservices.generichandlers.OpenMetadataAPIGenericHandler; import org.odpi.openmetadata.commonservices.repositoryhandler.RepositoryErrorHandler; import org.odpi.openmetadata.commonservices.repositoryhandler.RepositoryHandler; import org.odpi.openmetadata.frameworks.auditlog.messagesets.ExceptionMessageDefinition; @@ -21,17 +22,13 @@ import org.odpi.openmetadata.frameworks.connectors.ffdc.PropertyServerException; import org.odpi.openmetadata.frameworks.connectors.ffdc.UserNotAuthorizedException; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.OMRSMetadataCollection; -import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.MatchCriteria; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.SequencingOrder; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.Classification; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.EntityDetail; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.EntityProxy; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.InstanceGraph; -import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.InstanceProperties; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.InstanceStatus; -import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.PrimitivePropertyValue; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.Relationship; -import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.typedefs.PrimitiveDefCategory; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.typedefs.TypeDef; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.repositoryconnector.OMRSRepositoryHelper; import org.odpi.openmetadata.repositoryservices.ffdc.exception.EntityNotKnownException; @@ -46,13 +43,95 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; +import java.util.HashMap; import java.util.HashSet; import java.util.List; +import java.util.Map; import java.util.Optional; import java.util.Set; import java.util.stream.Collectors; -import static org.odpi.openmetadata.accessservices.assetcatalog.util.Constants.*; +import static org.odpi.openmetadata.accessservices.assetcatalog.util.Constants.API_ENDPOINT; +import static org.odpi.openmetadata.accessservices.assetcatalog.util.Constants.API_ENDPOINT_GUID; +import static org.odpi.openmetadata.accessservices.assetcatalog.util.Constants.ASSET; +import static org.odpi.openmetadata.accessservices.assetcatalog.util.Constants.ASSET_GUID; +import static org.odpi.openmetadata.accessservices.assetcatalog.util.Constants.ASSET_LOCATION; +import static org.odpi.openmetadata.accessservices.assetcatalog.util.Constants.ASSET_LOCATION_GUID; +import static org.odpi.openmetadata.accessservices.assetcatalog.util.Constants.ASSET_SCHEMA_TYPE; +import static org.odpi.openmetadata.accessservices.assetcatalog.util.Constants.ASSET_SCHEMA_TYPE_GUID; +import static org.odpi.openmetadata.accessservices.assetcatalog.util.Constants.ATTRIBUTE_FOR_SCHEMA; +import static org.odpi.openmetadata.accessservices.assetcatalog.util.Constants.ATTRIBUTE_FOR_SCHEMA_GUID; +import static org.odpi.openmetadata.accessservices.assetcatalog.util.Constants.COMPLEX_SCHEMA_TYPE; +import static org.odpi.openmetadata.accessservices.assetcatalog.util.Constants.CONNECTION; +import static org.odpi.openmetadata.accessservices.assetcatalog.util.Constants.CONNECTION_CONNECTOR_TYPE; +import static org.odpi.openmetadata.accessservices.assetcatalog.util.Constants.CONNECTION_CONNECTOR_TYPE_GUID; +import static org.odpi.openmetadata.accessservices.assetcatalog.util.Constants.CONNECTION_ENDPOINT; +import static org.odpi.openmetadata.accessservices.assetcatalog.util.Constants.CONNECTION_ENDPOINT_GUID; +import static org.odpi.openmetadata.accessservices.assetcatalog.util.Constants.CONNECTION_TO_ASSET; +import static org.odpi.openmetadata.accessservices.assetcatalog.util.Constants.CONNECTION_TO_ASSET_GUID; +import static org.odpi.openmetadata.accessservices.assetcatalog.util.Constants.DATABASE; +import static org.odpi.openmetadata.accessservices.assetcatalog.util.Constants.DATA_CONTENT_FOR_DATA_SET; +import static org.odpi.openmetadata.accessservices.assetcatalog.util.Constants.DATA_CONTENT_FOR_DATA_SET_GUID; +import static org.odpi.openmetadata.accessservices.assetcatalog.util.Constants.DATA_FILE; +import static org.odpi.openmetadata.accessservices.assetcatalog.util.Constants.DATA_SET; +import static org.odpi.openmetadata.accessservices.assetcatalog.util.Constants.DATA_STORE; +import static org.odpi.openmetadata.accessservices.assetcatalog.util.Constants.DEPLOYED_API; +import static org.odpi.openmetadata.accessservices.assetcatalog.util.Constants.DEPLOYED_VIRTUAL_CONTAINER; +import static org.odpi.openmetadata.accessservices.assetcatalog.util.Constants.DEPLOYED_VIRTUAL_CONTAINER_GUID; +import static org.odpi.openmetadata.accessservices.assetcatalog.util.Constants.DISPLAY_NAME; +import static org.odpi.openmetadata.accessservices.assetcatalog.util.Constants.ENDPOINT; +import static org.odpi.openmetadata.accessservices.assetcatalog.util.Constants.FILE_FOLDER; +import static org.odpi.openmetadata.accessservices.assetcatalog.util.Constants.FOLDER_HIERARCHY; +import static org.odpi.openmetadata.accessservices.assetcatalog.util.Constants.FOLDER_HIERARCHY_GUID; +import static org.odpi.openmetadata.accessservices.assetcatalog.util.Constants.GLOSSARY_TERM; +import static org.odpi.openmetadata.accessservices.assetcatalog.util.Constants.GLOSSARY_TERM_TYPE_GUID; +import static org.odpi.openmetadata.accessservices.assetcatalog.util.Constants.GUID_PARAMETER; +import static org.odpi.openmetadata.accessservices.assetcatalog.util.Constants.HOST; +import static org.odpi.openmetadata.accessservices.assetcatalog.util.Constants.HOST_CLUSTER; +import static org.odpi.openmetadata.accessservices.assetcatalog.util.Constants.HOST_CLUSTER_MEMBER; +import static org.odpi.openmetadata.accessservices.assetcatalog.util.Constants.HOST_CLUSTER_MEMBER_GUID; +import static org.odpi.openmetadata.accessservices.assetcatalog.util.Constants.HOST_LOCATION; +import static org.odpi.openmetadata.accessservices.assetcatalog.util.Constants.HOST_LOCATION_GUID; +import static org.odpi.openmetadata.accessservices.assetcatalog.util.Constants.HOST_NETWORK; +import static org.odpi.openmetadata.accessservices.assetcatalog.util.Constants.HOST_NETWORK_GUID; +import static org.odpi.openmetadata.accessservices.assetcatalog.util.Constants.HOST_OPERATING_PLATFORM; +import static org.odpi.openmetadata.accessservices.assetcatalog.util.Constants.HOST_OPERATING_PLATFORM_GUID; +import static org.odpi.openmetadata.accessservices.assetcatalog.util.Constants.IT_INFRASTRUCTURE; +import static org.odpi.openmetadata.accessservices.assetcatalog.util.Constants.LOCATION; +import static org.odpi.openmetadata.accessservices.assetcatalog.util.Constants.NAME; +import static org.odpi.openmetadata.accessservices.assetcatalog.util.Constants.NESTED_FILE; +import static org.odpi.openmetadata.accessservices.assetcatalog.util.Constants.NESTED_FILE_GUID; +import static org.odpi.openmetadata.accessservices.assetcatalog.util.Constants.NESTED_SCHEMA_ATTRIBUTE; +import static org.odpi.openmetadata.accessservices.assetcatalog.util.Constants.NESTED_SCHEMA_ATTRIBUTE_GUID; +import static org.odpi.openmetadata.accessservices.assetcatalog.util.Constants.NETWORK; +import static org.odpi.openmetadata.accessservices.assetcatalog.util.Constants.NETWORK_GATEWAY_LINK; +import static org.odpi.openmetadata.accessservices.assetcatalog.util.Constants.NETWORK_GATEWAY_LINK_GUID; +import static org.odpi.openmetadata.accessservices.assetcatalog.util.Constants.PORT_IMPLEMENTATION; +import static org.odpi.openmetadata.accessservices.assetcatalog.util.Constants.PORT_SCHEMA; +import static org.odpi.openmetadata.accessservices.assetcatalog.util.Constants.PORT_SCHEMA_GUID; +import static org.odpi.openmetadata.accessservices.assetcatalog.util.Constants.PROCESS; +import static org.odpi.openmetadata.accessservices.assetcatalog.util.Constants.PROCESS_PORT; +import static org.odpi.openmetadata.accessservices.assetcatalog.util.Constants.PROCESS_PORT_GUID; +import static org.odpi.openmetadata.accessservices.assetcatalog.util.Constants.QUALIFIED_NAME; +import static org.odpi.openmetadata.accessservices.assetcatalog.util.Constants.SCHEMA_ATTRIBUTE; +import static org.odpi.openmetadata.accessservices.assetcatalog.util.Constants.SCHEMA_ATTRIBUTE_TYPE; +import static org.odpi.openmetadata.accessservices.assetcatalog.util.Constants.SCHEMA_ATTRIBUTE_TYPE_GUID; +import static org.odpi.openmetadata.accessservices.assetcatalog.util.Constants.SCHEMA_ELEMENT; +import static org.odpi.openmetadata.accessservices.assetcatalog.util.Constants.SCHEMA_ELEMENT_GUID; +import static org.odpi.openmetadata.accessservices.assetcatalog.util.Constants.SEARCH_PARAMETER; +import static org.odpi.openmetadata.accessservices.assetcatalog.util.Constants.SEARCH_STRING_PARAMETER_NAME; +import static org.odpi.openmetadata.accessservices.assetcatalog.util.Constants.SEMANTIC_ASSIGNMENT; +import static org.odpi.openmetadata.accessservices.assetcatalog.util.Constants.SEMANTIC_ASSIGNMENT_GUID; +import static org.odpi.openmetadata.accessservices.assetcatalog.util.Constants.SERVER_ENDPOINT; +import static org.odpi.openmetadata.accessservices.assetcatalog.util.Constants.SERVER_ENDPOINT_GUID; +import static org.odpi.openmetadata.accessservices.assetcatalog.util.Constants.SOFTWARE_SERVER; +import static org.odpi.openmetadata.accessservices.assetcatalog.util.Constants.SOFTWARE_SERVER_DEPLOYMENT; +import static org.odpi.openmetadata.accessservices.assetcatalog.util.Constants.SOFTWARE_SERVER_DEPLOYMENT_GUID; +import static org.odpi.openmetadata.accessservices.assetcatalog.util.Constants.SOFTWARE_SERVER_PLATFORM; +import static org.odpi.openmetadata.accessservices.assetcatalog.util.Constants.SOFTWARE_SERVER_PLATFORM_DEPLOYMENT; +import static org.odpi.openmetadata.accessservices.assetcatalog.util.Constants.SOFTWARE_SERVER_PLATFORM_DEPLOYMENT_GUID; +import static org.odpi.openmetadata.accessservices.assetcatalog.util.Constants.TYPE_SEQUENCING; +import static org.odpi.openmetadata.accessservices.assetcatalog.util.Constants.VIRTUAL_CONTAINER; /** * Asset Catalog Handler supports the lookup of the assets from the repositories. @@ -70,8 +149,9 @@ public class AssetCatalogHandler { private final InvalidParameterHandler invalidParameterHandler; private final RepositoryErrorHandler errorHandler; private final CommonHandler commonHandler; - private final AssetCatalogConverter assetCatalogConverter; - private final List defaultSearchTypes = new ArrayList<>(Arrays.asList(GLOSSARY_TERM_TYPE_GUID, ASSET_GUID, SCHEMA_ELEMENT_GUID)); + private final AssetCatalogConverter assetCatalogConverter; + private final OpenMetadataAPIGenericHandler assetHandler; + private final Map defaultSearchTypes = new HashMap<>(); private List supportedTypesForSearch = new ArrayList<>(Arrays.asList(GLOSSARY_TERM, ASSET, SCHEMA_ELEMENT)); private final List supportedZones; @@ -84,26 +164,33 @@ public class AssetCatalogHandler { * @param invalidParameterHandler handler for managing parameter errors * @param repositoryHandler manages calls to the repository services * @param repositoryHelper provides utilities for manipulating the repository services objects + * @param assetHandler provides utilities for manipulating asset catalog objects using a generic handler + * @param assetCatalogConverter asset catalog bean converter * @param errorHandler provides common validation routines for the other handler classes * @param supportedZones configurable list of zones that Asset Catalog is allowed to serve Assets from * @param supportedTypesForSearch configurable list of supported types used for search */ public AssetCatalogHandler(String serverUserName, String sourceName, InvalidParameterHandler invalidParameterHandler, RepositoryHandler repositoryHandler, OMRSRepositoryHelper repositoryHelper, + OpenMetadataAPIGenericHandler assetHandler, AssetCatalogConverter assetCatalogConverter, RepositoryErrorHandler errorHandler, List supportedZones, List supportedTypesForSearch) { this.serverUserName = serverUserName; this.sourceName = sourceName; this.invalidParameterHandler = invalidParameterHandler; this.repositoryHelper = repositoryHelper; this.repositoryHandler = repositoryHandler; + this.assetHandler = assetHandler; + this.assetCatalogConverter = assetCatalogConverter; this.errorHandler = errorHandler; this.supportedZones = supportedZones; - this.commonHandler = new CommonHandler(sourceName, repositoryHandler, repositoryHelper, errorHandler); + this.commonHandler = new CommonHandler(sourceName, repositoryHandler, repositoryHelper, assetHandler, errorHandler); if (CollectionUtils.isNotEmpty(supportedTypesForSearch)) { this.supportedTypesForSearch = supportedTypesForSearch; Collections.sort(supportedTypesForSearch); } - this.assetCatalogConverter = new AssetCatalogConverter(sourceName, repositoryHelper); + defaultSearchTypes.put(GLOSSARY_TERM, GLOSSARY_TERM_TYPE_GUID); + defaultSearchTypes.put(ASSET, ASSET_GUID); + defaultSearchTypes.put(SCHEMA_ELEMENT, SCHEMA_ELEMENT_GUID); } /** @@ -149,12 +236,9 @@ public List relationshipsByType = repositoryHandler.getRelationshipsByType(userId, - assetGUID, - assetTypeName, - null, - null, - methodName); + List relationshipsByType = assetHandler.getAttachmentLinks(userId, assetGUID, GUID_PARAMETER, + assetTypeName, null, null, null, + 0, invalidParameterHandler.getMaxPagingSize(), null, methodName); if (CollectionUtils.isNotEmpty(relationshipsByType)) { return assetCatalogConverter.convertRelationships(relationshipsByType); @@ -199,53 +283,6 @@ public List getLinkingRelationshipsBetweenAssets(String serverName, - String userId, - String startAssetGUID, - String endAssetGUID) - throws InvalidParameterException, PropertyServerException, UserNotAuthorizedException, AssetCatalogException { - String methodName = "getLinkingRelationshipsBetweenAssets"; - - initialValidationStartEndAssetGUID(userId, startAssetGUID, endAssetGUID, methodName); - - OMRSMetadataCollection metadataCollection = commonHandler.getOMRSMetadataCollection(); - InstanceGraph linkingEntities = null; - try { - linkingEntities = metadataCollection.getLinkingEntities(userId, - startAssetGUID, - endAssetGUID, - Collections.singletonList(InstanceStatus.ACTIVE), - null); - } catch (org.odpi.openmetadata.repositoryservices.ffdc.exception.InvalidParameterException - | FunctionNotSupportedException | RepositoryErrorException - | PropertyErrorException e) { - errorHandler.handleRepositoryError(e, methodName); - } catch (EntityNotKnownException e) { - errorHandler.handleUnknownEntity(e, startAssetGUID, "", methodName, GUID_PARAMETER); - } catch (org.odpi.openmetadata.repositoryservices.ffdc.exception.UserNotAuthorizedException e) { - errorHandler.handleUnauthorizedUser(userId, methodName); - } - - if (linkingEntities == null || CollectionUtils.isEmpty(linkingEntities.getRelationships())) { - throw new AssetCatalogException(AssetCatalogErrorCode.LINKING_RELATIONSHIPS_NOT_FOUND.getMessageDefinition(startAssetGUID, endAssetGUID, serverName), - this.getClass().getName(), - methodName); - } - - return assetCatalogConverter.convertRelationships(linkingEntities.getRelationships()); - } - /** * @param userId user identifier that issues the call * @param assetGUID the asset identifier @@ -272,14 +309,9 @@ public List pagedRelationshipsByType = repositoryHandler.getPagedRelationshipsByType(userId, - assetGUID, - assetTypeName, - relationshipTypeGUID, - relationshipTypeName, - from, - pageSize, - methodName); + List pagedRelationshipsByType = assetHandler.getAttachmentLinks(userId, assetGUID, GUID_PARAMETER, + assetTypeName, relationshipTypeGUID, relationshipTypeName, null, + from, pageSize, null, methodName); if (CollectionUtils.isNotEmpty(pagedRelationshipsByType)) { return assetCatalogConverter.convertRelationships(pagedRelationshipsByType); @@ -288,51 +320,6 @@ public List getIntermediateAssets(String userId, String startAssetGUID, String endAssetGUID, String serverName) - throws InvalidParameterException, PropertyServerException, UserNotAuthorizedException, AssetCatalogException { - - String methodName = "getIntermediateAssets"; - initialValidationStartEndAssetGUID(userId, startAssetGUID, endAssetGUID, methodName); - - OMRSMetadataCollection metadataCollection = commonHandler.getOMRSMetadataCollection(); - - InstanceGraph linkingEntities = null; - try { - linkingEntities = metadataCollection.getLinkingEntities(userId, - startAssetGUID, - endAssetGUID, - Collections.singletonList(InstanceStatus.ACTIVE), - null); - } catch (org.odpi.openmetadata.repositoryservices.ffdc.exception.InvalidParameterException - | FunctionNotSupportedException - | PropertyErrorException | RepositoryErrorException e) { - errorHandler.handleRepositoryError(e, methodName); - } catch (EntityNotKnownException e) { - errorHandler.handleUnknownEntity(e, startAssetGUID, "", methodName, GUID_PARAMETER); - } catch (org.odpi.openmetadata.repositoryservices.ffdc.exception.UserNotAuthorizedException e) { - errorHandler.handleUnauthorizedUser(userId, methodName); - } - - if (linkingEntities == null || CollectionUtils.isEmpty(linkingEntities.getEntities())) { - throw new AssetCatalogException(AssetCatalogErrorCode. LINKING_ASSETS_NOT_FOUND.getMessageDefinition(startAssetGUID, endAssetGUID, serverName), - this.getClass().getName(), - methodName); - } - - return getAssetCatalogBeansAfterValidation(methodName, linkingEntities.getEntities()); - } - /** * @param userId user identifier that issues the call * @param assetGUID the asset identifier @@ -387,7 +374,7 @@ public List searchByType(String userId, String searchCriteria, SearchP throws org.odpi.openmetadata.repositoryservices.ffdc.exception.UserNotAuthorizedException, FunctionNotSupportedException, org.odpi.openmetadata.repositoryservices.ffdc.exception.InvalidParameterException, PropertyErrorException, TypeErrorException, PagingErrorException, - InvalidParameterException, RepositoryErrorException, EntityNotKnownException { + InvalidParameterException, RepositoryErrorException, EntityNotKnownException, PropertyServerException, UserNotAuthorizedException { String methodName = "searchByType"; invalidParameterHandler.validateUserId(userId, methodName); @@ -396,16 +383,18 @@ public List searchByType(String userId, String searchCriteria, SearchP invalidParameterHandler.validatePaging(searchParameters.getFrom(), searchParameters.getPageSize(), methodName); List result; - List typesFilter; + Map typesAndGUIDsFilter; if (CollectionUtils.isNotEmpty(searchParameters.getEntityTypes())) { - typesFilter = commonHandler.getTypesGUID(userId, searchParameters.getEntityTypes()); - if (CollectionUtils.isEmpty(typesFilter)) { - ExceptionMessageDefinition messageDefinition = AssetCatalogErrorCode.TYPE_DEF_NOT_FOUND.getMessageDefinition(); - throw new EntityNotKnownException(messageDefinition, this.getClass().getName(), messageDefinition.getUserAction()); + typesAndGUIDsFilter = commonHandler.getTypesAndGUIDs(userId, searchParameters.getEntityTypes()); + for( Map.Entry typeAndGUID : typesAndGUIDsFilter.entrySet()) { + if (typeAndGUID.getValue() == null) { + ExceptionMessageDefinition messageDefinition = AssetCatalogErrorCode.TYPE_DEF_NOT_FOUND.getMessageDefinition(typeAndGUID.getKey()); + throw new EntityNotKnownException(messageDefinition, this.getClass().getName(), messageDefinition.getUserAction()); + } } - result = collectSearchedEntitiesByType(userId, searchCriteria, searchParameters, typesFilter); + result = collectSearchedEntitiesByType(userId, searchCriteria, searchParameters, typesAndGUIDsFilter, methodName); } else { - result = collectSearchedEntitiesByType(userId, searchCriteria, searchParameters, defaultSearchTypes); + result = collectSearchedEntitiesByType(userId, searchCriteria, searchParameters, defaultSearchTypes, methodName); } Set searchResults = new HashSet<>(); @@ -418,7 +407,7 @@ public List searchByType(String userId, String searchCriteria, SearchP supportedZones, serverUserName, methodName); - Elements elements = assetCatalogConverter.buildAssetElements(entityDetail); + Elements elements = assetCatalogConverter.buildAssetElements(entityDetail); searchResults.add(elements); } catch (org.odpi.openmetadata.commonservices.ffdc.exceptions.InvalidParameterException e) { log.debug(THIS_ASSET_IF_A_DIFFERENT_ZONE, entityDetail.getGUID()); @@ -548,23 +537,14 @@ private EntityDetail getEntity(String userId, return entityByGUID; } - private void initialValidationStartEndAssetGUID(String userId, String startAssetGUID, String endAssetGUID, String methodName) throws org.odpi.openmetadata.commonservices.ffdc.exceptions.InvalidParameterException { - invalidParameterHandler.validateUserId(userId, methodName); - invalidParameterHandler.validateGUID(startAssetGUID, "startAssetGUID", methodName); - invalidParameterHandler.validateGUID(endAssetGUID, "endAssetGUID", methodName); - } - private List collectSearchedEntitiesByType(String userId, String searchCriteria, SearchParameters searchParameters, - List types) - throws org.odpi.openmetadata.repositoryservices.ffdc.exception.UserNotAuthorizedException, FunctionNotSupportedException, - org.odpi.openmetadata.repositoryservices.ffdc.exception.InvalidParameterException, PropertyErrorException, - TypeErrorException, PagingErrorException, RepositoryErrorException, InvalidParameterException { + Map typesAndGUIDs, + String methodName) + throws InvalidParameterException, PropertyServerException, UserNotAuthorizedException { List result = new ArrayList<>(); - OMRSMetadataCollection metadataCollection = commonHandler.getOMRSMetadataCollection(); - if(searchParameters.getExactMatch()) { searchCriteria = repositoryHelper.getExactMatchRegex(searchCriteria, searchParameters.getCaseInsensitive()); } @@ -572,8 +552,9 @@ private List collectSearchedEntitiesByType(String userId, searchCriteria = repositoryHelper.getContainsRegex(searchCriteria, searchParameters.getCaseInsensitive()); } - for (String type : types) { - result.addAll(searchEntityByCriteria(userId, searchCriteria, type, searchParameters, metadataCollection)); + for (Map.Entry typeAndGUID : typesAndGUIDs.entrySet()) { + result.addAll(searchEntityByCriteria(userId, searchCriteria, typeAndGUID.getValue(), typeAndGUID.getKey(), + searchParameters, methodName)); } return result; } @@ -595,14 +576,10 @@ private Elements getContextForGlossaryTerm(String userId, } Elements elements = assetCatalogConverter.buildAssetElements(glossaryTerm); - List schemas = repositoryHandler.getEntitiesForRelationshipType(userId, - glossaryTerm.getGUID(), - GLOSSARY_TERM, - SEMANTIC_ASSIGNMENT_GUID, - SEMANTIC_ASSIGNMENT, - 0, - 0, - method); + List schemas = assetHandler.getAttachedFilteredEntities(userId, glossaryTerm.getGUID(), + GUID_PARAMETER, GLOSSARY_TERM, SEMANTIC_ASSIGNMENT, SEMANTIC_ASSIGNMENT_GUID, + 0, null, null, 0, false, + false, 0, method); if (CollectionUtils.isEmpty(schemas)) { return elements; @@ -636,15 +613,10 @@ private void getContextForDeployedAPI(String userId, throws UserNotAuthorizedException, PropertyServerException, InvalidParameterException { String method = "getContextForDeployedAPI"; - List endpoints = repositoryHandler.getEntitiesForRelationshipType( - userId, - entityDetail.getGUID(), - DEPLOYED_API, - API_ENDPOINT_GUID, - API_ENDPOINT, - 0, - 0, - method); + List endpoints = assetHandler.getAttachedFilteredEntities(userId, entityDetail.getGUID(), + GUID_PARAMETER, DEPLOYED_API, API_ENDPOINT, API_ENDPOINT_GUID, + 0, null, null, 0, false, + false, 0, method); if (CollectionUtils.isEmpty(endpoints)) { return; } @@ -685,26 +657,18 @@ private void getContextForProcess(String userId, throws UserNotAuthorizedException, PropertyServerException, InvalidParameterException { String method = "getContextForProcess"; - List ports = repositoryHandler.getEntitiesForRelationshipType( - userId, - entityDetail.getGUID(), - PROCESS, - PROCESS_PORT_GUID, - PROCESS_PORT, - 0, - 0, - method); + List ports = assetHandler.getAttachedFilteredEntities(userId, entityDetail.getGUID(), + GUID_PARAMETER, PROCESS, PROCESS_PORT, PROCESS_PORT_GUID, + 0, null, null, 0, false, + false, 0, method); if (CollectionUtils.isNotEmpty(ports)) { for (EntityDetail port : ports) { assetCatalogConverter.addContextElement(assetCatalogItemElement, port); if (port.getType().getTypeDefName().equals(PORT_IMPLEMENTATION)) { - EntityDetail schemaType = repositoryHandler.getEntityForRelationshipType(userId, - port.getGUID(), - DATABASE, - PORT_SCHEMA_GUID, - PORT_SCHEMA, - method); + EntityDetail schemaType = assetHandler.getAttachedEntity(userId, port.getGUID(), GUID_PARAMETER, + DATABASE, PORT_SCHEMA_GUID, PORT_SCHEMA, null, false, + false, null, method); if (schemaType != null) { assetCatalogConverter.addElement(assetCatalogItemElement, schemaType); @@ -738,15 +702,10 @@ private void getContextForDatabase(String userId, throws UserNotAuthorizedException, PropertyServerException, InvalidParameterException { String method = "getContextForDatabase"; - List dataSets = repositoryHandler.getEntitiesForRelationshipType( - userId, - entityDetail.getGUID(), - DATABASE, - DATA_CONTENT_FOR_DATA_SET_GUID, - DATA_CONTENT_FOR_DATA_SET, - 0, - 0, - method); + List dataSets = assetHandler.getAttachedFilteredEntities(userId, entityDetail.getGUID(), + GUID_PARAMETER, DATABASE, DATA_CONTENT_FOR_DATA_SET, DATA_CONTENT_FOR_DATA_SET_GUID, + 0, null, null, 0, false, + false, 0, method); if (dataSets != null && !dataSets.isEmpty()) { for (EntityDetail dataSet : dataSets) { @@ -761,14 +720,9 @@ private void getContextForDataSet(String userId, UserNotAuthorizedException, PropertyServerException, InvalidParameterException { String method = "getContextForDataSet"; - EntityDetail schemaType = repositoryHandler.getEntityForRelationshipType( - userId, - dataSet.getGUID(), - DATA_SET, - ASSET_SCHEMA_TYPE_GUID, - ASSET_SCHEMA_TYPE, - method); - + EntityDetail schemaType = assetHandler.getAttachedEntity(userId, dataSet.getGUID(), GUID_PARAMETER, + DATA_SET, ASSET_SCHEMA_TYPE_GUID, ASSET_SCHEMA_TYPE, null, false, + false, null, method); if (schemaType == null) { return; @@ -788,15 +742,10 @@ private void getContextForFileFolder(String userId, throws UserNotAuthorizedException, PropertyServerException, InvalidParameterException { String method = "getContextForFileFolder"; - List connections = repositoryHandler.getEntitiesForRelationshipType( - userId, - entityDetail.getGUID(), - FILE_FOLDER, - CONNECTION_TO_ASSET_GUID, - CONNECTION_TO_ASSET, - 0, - 0, - method); + List connections = assetHandler.getAttachedFilteredEntities(userId, entityDetail.getGUID(), + GUID_PARAMETER, FILE_FOLDER, CONNECTION_TO_ASSET, CONNECTION_TO_ASSET_GUID, + 0, null, null, 0, false, + false, 0, method); if (CollectionUtils.isNotEmpty(connections)) { @@ -805,9 +754,10 @@ private void getContextForFileFolder(String userId, } - List parentFolderRelationships = repositoryHandler.getRelationshipsByType(userId, - entityDetail.getGUID(), entityDetail.getType().getTypeDefName(), - FOLDER_HIERARCHY_GUID, FOLDER_HIERARCHY, method); + List parentFolderRelationships = assetHandler.getAttachmentLinks(userId, entityDetail.getGUID(), + GUID_PARAMETER, entityDetail.getType().getTypeDefName(), FOLDER_HIERARCHY_GUID, + FOLDER_HIERARCHY, null, 0, invalidParameterHandler.getMaxPagingSize(), + null, method); if (CollectionUtils.isEmpty(parentFolderRelationships)) { return; @@ -846,15 +796,10 @@ private void getContextForDataFile(String userId, throws UserNotAuthorizedException, PropertyServerException, InvalidParameterException { String method = "getContextForDataFile"; - List fileFolders = repositoryHandler.getEntitiesForRelationshipType( - userId, - entityDetail.getGUID(), - DATA_FILE, - NESTED_FILE_GUID, - NESTED_FILE, - 0, - 0, - method); + List fileFolders = assetHandler.getAttachedFilteredEntities(userId, entityDetail.getGUID(), + GUID_PARAMETER, DATA_FILE, NESTED_FILE, NESTED_FILE_GUID, + 0, null, null, 0, false, + false, 0, method); if (CollectionUtils.isEmpty(fileFolders)) { return; @@ -869,14 +814,10 @@ private void getContextForSoftwareServerPlatform(String userId, throws UserNotAuthorizedException, PropertyServerException, InvalidParameterException { String method = "getContextForSoftwareServerPlatform"; - EntityDetail host = repositoryHandler.getEntityForRelationshipType( - userId, - entityDetail.getGUID(), - entityDetail.getType().getTypeDefName(), - SOFTWARE_SERVER_PLATFORM_DEPLOYMENT_GUID, - SOFTWARE_SERVER_PLATFORM_DEPLOYMENT, - method); - + EntityDetail host = assetHandler.getAttachedEntity(userId, entityDetail.getGUID(), GUID_PARAMETER, + entityDetail.getType().getTypeDefName(), SOFTWARE_SERVER_PLATFORM_DEPLOYMENT_GUID, + SOFTWARE_SERVER_PLATFORM_DEPLOYMENT, null, false, false, + null, method); if (host != null) { assetCatalogConverter.addElement(assetCatalogItemElement, host); getContextForHost(userId, host, assetCatalogItemElement); @@ -889,26 +830,17 @@ private void getContextForNetwork(String userId, throws UserNotAuthorizedException, PropertyServerException, InvalidParameterException { String method = "getContextForNetwork"; - List networkGateways = repositoryHandler.getEntitiesForRelationshipType( - userId, - entityDetail.getGUID(), - NETWORK, - NETWORK_GATEWAY_LINK_GUID, - NETWORK_GATEWAY_LINK, - 0, - 0, - method); + List networkGateways = assetHandler.getAttachedFilteredEntities(userId, entityDetail.getGUID(), + GUID_PARAMETER, NETWORK, NETWORK_GATEWAY_LINK, NETWORK_GATEWAY_LINK_GUID, + 0, null, null, 0, false, + false, 0, method); + networkGateways.forEach(networkGateway -> assetCatalogConverter.addElement(assetCatalogItemElement, networkGateway)); - List hosts = repositoryHandler.getEntitiesForRelationshipType( - userId, - entityDetail.getGUID(), - NETWORK, - HOST_NETWORK_GUID, - HOST_NETWORK, - 0, - 0, - method); + List hosts = assetHandler.getAttachedFilteredEntities(userId, entityDetail.getGUID(), + GUID_PARAMETER, NETWORK, HOST_NETWORK, HOST_NETWORK_GUID, + 0, null, null, 0, false, + false, 0, method); if (CollectionUtils.isNotEmpty(hosts)) { for (EntityDetail host : hosts) { @@ -925,48 +857,36 @@ private void getContextForHost(String userId, String method = "getContextForHost"; List hosts = null; if (entityDetail.getType().getTypeDefName().equals(VIRTUAL_CONTAINER)) { - hosts = repositoryHandler.getEntitiesForRelationshipType(userId, - entityDetail.getGUID(), - HOST, - DEPLOYED_VIRTUAL_CONTAINER_GUID, - DEPLOYED_VIRTUAL_CONTAINER, - 0, - 0, - method); + hosts = assetHandler.getAttachedFilteredEntities(userId, entityDetail.getGUID(), + GUID_PARAMETER, HOST, DEPLOYED_VIRTUAL_CONTAINER, DEPLOYED_VIRTUAL_CONTAINER_GUID, + 0, null, null, 0, false, + false, 0, method); } else if (entityDetail.getType().getTypeDefName().equals(HOST_CLUSTER)) { - hosts = repositoryHandler.getEntitiesForRelationshipType( - userId, - entityDetail.getGUID(), - HOST, - HOST_CLUSTER_MEMBER_GUID, - HOST_CLUSTER_MEMBER, - 0, - 0, - method); + hosts = assetHandler.getAttachedFilteredEntities(userId, entityDetail.getGUID(), + GUID_PARAMETER, HOST, HOST_CLUSTER_MEMBER, HOST_CLUSTER_MEMBER_GUID, + 0, null, null, 0, false, + false, 0, method); + } if (hosts != null) { hosts.forEach(host -> assetCatalogConverter.addElement(assetCatalogItemElement, host)); } - EntityDetail operatingPlatform = repositoryHandler.getEntityForRelationshipType(userId, - entityDetail.getGUID(), - entityDetail.getType().getTypeDefName(), - HOST_OPERATING_PLATFORM_GUID, - HOST_OPERATING_PLATFORM, - method); - + EntityDetail operatingPlatform = assetHandler.getAttachedEntity(userId, entityDetail.getGUID(), GUID_PARAMETER, + entityDetail.getType().getTypeDefName(), HOST_OPERATING_PLATFORM_GUID, HOST_OPERATING_PLATFORM, + null, false, false, null, method); assetCatalogConverter.addElement(assetCatalogItemElement, operatingPlatform); - List locations = repositoryHandler.getEntitiesForRelationshipType( - userId, - entityDetail.getGUID(), - HOST, - HOST_LOCATION_GUID, - HOST_LOCATION, - 0, - 0, - method); + processLocations(userId, entityDetail, assetCatalogItemElement, method); + } + + private void processLocations(String userId, EntityDetail entityDetail, AssetCatalogItemElement assetCatalogItemElement, + String method) throws InvalidParameterException, PropertyServerException, UserNotAuthorizedException { + List locations = assetHandler.getAttachedFilteredEntities(userId, entityDetail.getGUID(), + GUID_PARAMETER, HOST, HOST_LOCATION, HOST_LOCATION_GUID, 0, + null, null, 0, false, false, + 0, method); if (CollectionUtils.isNotEmpty(locations)) { for (EntityDetail location : locations) { assetCatalogConverter.addElement(assetCatalogItemElement, location); @@ -981,15 +901,10 @@ private void getContextForLocation(String userId, throws UserNotAuthorizedException, PropertyServerException, InvalidParameterException { String method = "getContextForLocation"; - List assetLocations = repositoryHandler.getEntitiesForRelationshipType( - userId, - location.getGUID(), - LOCATION, - ASSET_LOCATION_GUID, - ASSET_LOCATION, - 0, - 0, - method); + List assetLocations = assetHandler.getAttachedFilteredEntities(userId, location.getGUID(), + GUID_PARAMETER, LOCATION, ASSET_LOCATION, ASSET_LOCATION_GUID, + 0, null, null, 0, false, + false, 0, method); if (CollectionUtils.isNotEmpty(assetLocations)) { for (EntityDetail assetLocation : assetLocations) { @@ -998,23 +913,7 @@ private void getContextForLocation(String userId, } } - List nestedLocations = repositoryHandler.getEntitiesForRelationshipType( - userId, - location.getGUID(), - LOCATION, - NESTED_LOCATION_GUID, - NESTED_LOCATION, - 0, - 0, - method); - - - if (CollectionUtils.isNotEmpty(nestedLocations)) { - for (EntityDetail nestedLocation : nestedLocations) { - assetCatalogConverter.addElement(assetCatalogItemElement, nestedLocation); - getContextForLocation(userId, assetCatalogItemElement, nestedLocation); - } - } + processLocations(userId, location, assetCatalogItemElement, method); } private void getContextForSoftwareServer(String userId, @@ -1024,28 +923,18 @@ private void getContextForSoftwareServer(String userId, String method = "getContextForSoftwareServer"; Element parentElement = null; - EntityDetail softwareServerPlatform = repositoryHandler.getEntityForRelationshipType( - userId, - entityDetail.getGUID(), - SOFTWARE_SERVER, - SOFTWARE_SERVER_DEPLOYMENT_GUID, - SOFTWARE_SERVER_DEPLOYMENT, - method); - + EntityDetail softwareServerPlatform = assetHandler.getAttachedEntity(userId, entityDetail.getGUID(), + GUID_PARAMETER, SOFTWARE_SERVER, SOFTWARE_SERVER_DEPLOYMENT_GUID, SOFTWARE_SERVER_DEPLOYMENT, + null, false, false, null, method); if (softwareServerPlatform != null) { parentElement = assetCatalogConverter.getLastNode(assetCatalogItemElement); assetCatalogConverter.addElement(assetCatalogItemElement, softwareServerPlatform); getContextForSoftwareServerPlatform(userId, softwareServerPlatform, assetCatalogItemElement); } - EntityDetail endpoint = repositoryHandler.getEntityForRelationshipType( - userId, - entityDetail.getGUID(), - SOFTWARE_SERVER, - SERVER_ENDPOINT_GUID, - SERVER_ENDPOINT, - method); - + EntityDetail endpoint = assetHandler.getAttachedEntity(userId, entityDetail.getGUID(), + GUID_PARAMETER, SOFTWARE_SERVER, SERVER_ENDPOINT_GUID, SERVER_ENDPOINT, + null, false, false, null, method); if (endpoint != null) { if (parentElement != null) { assetCatalogConverter.addChildElement(parentElement, assetCatalogConverter.buildAssetElements(endpoint)); @@ -1063,16 +952,10 @@ private void getConnectionContext(String userId, throws UserNotAuthorizedException, PropertyServerException, InvalidParameterException { String methodName = "getConnectionContext"; - List connections = repositoryHandler.getEntitiesForRelationshipType( - userId, - endpoint.getGUID(), - ENDPOINT, - CONNECTION_ENDPOINT_GUID, - CONNECTION_ENDPOINT, - 0, - 0, - methodName); - + List connections = assetHandler.getAttachedFilteredEntities(userId, endpoint.getGUID(), + GUID_PARAMETER, ENDPOINT, CONNECTION_ENDPOINT, CONNECTION_ENDPOINT_GUID, + 0, null, null, 0, false, + false, 0, methodName); if (CollectionUtils.isEmpty(connections)) { return; } @@ -1081,26 +964,16 @@ private void getConnectionContext(String userId, assetCatalogConverter.addElement(assetCatalogItemElement, connection); List elements = new ArrayList<>(); - EntityDetail connectorType = repositoryHandler.getEntityForRelationshipType( - userId, - connection.getGUID(), - CONNECTION, - CONNECTION_CONNECTOR_TYPE_GUID, - CONNECTION_CONNECTOR_TYPE, - methodName); - + EntityDetail connectorType = assetHandler.getAttachedEntity(userId, connection.getGUID(), + GUID_PARAMETER, CONNECTION, CONNECTION_CONNECTOR_TYPE_GUID, CONNECTION_CONNECTOR_TYPE, + null, false, false, null, methodName); if (connectorType != null) { elements.add(connectorType); } - EntityDetail asset = repositoryHandler.getEntityForRelationshipType( - userId, - connection.getGUID(), - CONNECTION, - CONNECTION_TO_ASSET_GUID, - CONNECTION_TO_ASSET, - methodName); - + EntityDetail asset = assetHandler.getAttachedEntity(userId, connection.getGUID(), + GUID_PARAMETER, CONNECTION, CONNECTION_TO_ASSET_GUID, CONNECTION_TO_ASSET, + null, false, false, null, methodName); invalidParameterHandler.validateAssetInSupportedZone(asset.getGUID(), GUID_PARAMETER, commonHandler.getAssetZoneMembership(asset.getClassifications()), @@ -1118,26 +991,16 @@ private void findAsset(String userId, String method = "findAsset"; for (EntityDetail entityDetail : entitiesByType) { - List schemaAttributes = repositoryHandler.getEntitiesForRelationshipType( - userId, - entityDetail.getGUID(), - SCHEMA_ATTRIBUTE, - ATTRIBUTE_FOR_SCHEMA_GUID, - ATTRIBUTE_FOR_SCHEMA, - 0, - 0, - method); + List schemaAttributes = assetHandler.getAttachedFilteredEntities(userId, entityDetail.getGUID(), + GUID_PARAMETER, SCHEMA_ATTRIBUTE, ATTRIBUTE_FOR_SCHEMA, ATTRIBUTE_FOR_SCHEMA_GUID, + 0, null, null, 0, false, + false, 0, method); if (CollectionUtils.isEmpty(schemaAttributes)) { - schemaAttributes = repositoryHandler.getEntitiesForRelationshipType( - userId, - entityDetail.getGUID(), - SCHEMA_ATTRIBUTE, - NESTED_SCHEMA_ATTRIBUTE_GUID, - NESTED_SCHEMA_ATTRIBUTE, - 0, - 0, - method); + schemaAttributes = assetHandler.getAttachedFilteredEntities(userId, entityDetail.getGUID(), + GUID_PARAMETER, SCHEMA_ATTRIBUTE, NESTED_SCHEMA_ATTRIBUTE, NESTED_SCHEMA_ATTRIBUTE_GUID, + 0, null, null, 0, false, + false, 0, method); if (CollectionUtils.isEmpty(schemaAttributes)) { continue; } @@ -1164,15 +1027,10 @@ private boolean processSchemaAttribute(String userId, AssetCatalogItemElement as private void processPrimitiveSchema(String userId, AssetCatalogItemElement assetCatalogItemElement, String method, EntityDetail schemaAttribute) throws UserNotAuthorizedException, PropertyServerException, InvalidParameterException { - List schemaAttributeTypeEntities = repositoryHandler.getEntitiesForRelationshipType( - userId, - schemaAttribute.getGUID(), - schemaAttribute.getType().getTypeDefName(), - SCHEMA_ATTRIBUTE_TYPE_GUID, - SCHEMA_ATTRIBUTE_TYPE, - 0, - 0, - method); + List schemaAttributeTypeEntities = assetHandler.getAttachedFilteredEntities(userId, schemaAttribute.getGUID(), + GUID_PARAMETER, schemaAttribute.getType().getTypeDefName(), SCHEMA_ATTRIBUTE_TYPE, + SCHEMA_ATTRIBUTE_TYPE_GUID, 0, null, null, 0, + false, false, 0, method); if (CollectionUtils.isNotEmpty(schemaAttributeTypeEntities)) { schemaAttributeTypeEntities.forEach(schemaAttributeTypeEntity -> assetCatalogConverter.addElement(assetCatalogItemElement, schemaAttributeTypeEntity)); @@ -1204,15 +1062,10 @@ private void getContextForSchemaType(String userId, if (isComplexSchemaType.isPresent()) { setAssetDetails(userId, assetCatalogItemElement, entityDetail); } else { - List attributeForSchemas = repositoryHandler.getEntitiesForRelationshipType( - userId, - entityDetail.getGUID(), - entityDetail.getType().getTypeDefName(), - ATTRIBUTE_FOR_SCHEMA_GUID, - ATTRIBUTE_FOR_SCHEMA, - 0, - 0, - method); + List attributeForSchemas = assetHandler.getAttachedFilteredEntities(userId, entityDetail.getGUID(), + GUID_PARAMETER, entityDetail.getType().getTypeDefName(), ATTRIBUTE_FOR_SCHEMA, + ATTRIBUTE_FOR_SCHEMA_GUID, 0, null, null, 0, + false, false, 0, method); if (CollectionUtils.isEmpty(attributeForSchemas)) { return; } @@ -1224,15 +1077,10 @@ private void getContextForSchemaType(String userId, setAssetDetails(userId, assetCatalogItemElement, attributeForSchema); return; } else { - List schemaAttributeTypeEntities = repositoryHandler.getEntitiesForRelationshipType( - userId, - attributeForSchema.getGUID(), - attributeForSchema.getType().getTypeDefName(), - SCHEMA_ATTRIBUTE_TYPE_GUID, - SCHEMA_ATTRIBUTE_TYPE, - 0, - 0, - method); + List schemaAttributeTypeEntities = assetHandler.getAttachedFilteredEntities(userId, + attributeForSchema.getGUID(), GUID_PARAMETER, attributeForSchema.getType().getTypeDefName(), + SCHEMA_ATTRIBUTE_TYPE, SCHEMA_ATTRIBUTE_TYPE_GUID, 0, null, + null, 0, false, false, 0, method); for (EntityDetail schema : schemaAttributeTypeEntities) { assetCatalogConverter.addElement(assetCatalogItemElement, schema); @@ -1249,13 +1097,9 @@ private void setAssetDetails(String userId, throws InvalidParameterException, PropertyServerException, UserNotAuthorizedException { String methodName = "setAssetDetails"; - EntityDetail dataSet = repositoryHandler.getEntityForRelationshipType(userId, - entity.getGUID(), - entity.getType().getTypeDefName(), - ASSET_SCHEMA_TYPE_GUID, - ASSET_SCHEMA_TYPE, - methodName); - + EntityDetail dataSet = assetHandler.getAttachedEntity(userId, entity.getGUID(), + GUID_PARAMETER, entity.getType().getTypeDefName(), ASSET_SCHEMA_TYPE_GUID, ASSET_SCHEMA_TYPE, + null, false, false, null, methodName); if (dataSet == null) { return; } @@ -1290,12 +1134,10 @@ private void getAsset(String userId, if (dataSet == null) return; String methodName = "getAsset"; - List assetToDataSetRelationships = repositoryHandler.getRelationshipsByType(userId, - dataSet.getGUID(), - dataSet.getType().getTypeDefName(), - DATA_CONTENT_FOR_DATA_SET_GUID, - DATA_CONTENT_FOR_DATA_SET, - methodName); + List assetToDataSetRelationships = assetHandler.getAttachmentLinks(userId, dataSet.getGUID(), + GUID_PARAMETER, dataSet.getType().getTypeDefName(), DATA_CONTENT_FOR_DATA_SET_GUID, + DATA_CONTENT_FOR_DATA_SET, null, 0, invalidParameterHandler.getMaxPagingSize(), + null, methodName); if (CollectionUtils.isEmpty(assetToDataSetRelationships)) { return; @@ -1329,7 +1171,7 @@ private void getAsset(String userId, private void setConnections(String userId, AssetCatalogItemElement assetCatalogItemElement, EntityDetail asset) - throws UserNotAuthorizedException, PropertyServerException { + throws UserNotAuthorizedException, PropertyServerException, InvalidParameterException { List connections = getConnections(userId, asset.getGUID()); assetCatalogItemElement.setConnections(connections); } @@ -1345,19 +1187,12 @@ private Optional isComplexSchemaType(String typeDefName) { } private List getConnections(String userId, String dataSetGuid) - throws UserNotAuthorizedException, PropertyServerException { + throws UserNotAuthorizedException, PropertyServerException, InvalidParameterException { String methodName = "getConnections"; - List connections = repositoryHandler.getEntitiesForRelationshipType( - userId, - dataSetGuid, - CONNECTION, - CONNECTION_TO_ASSET_GUID, - CONNECTION_TO_ASSET, - 0, - 0, - methodName); - - + List connections = assetHandler.getAttachedFilteredEntities(userId, + dataSetGuid, GUID_PARAMETER, CONNECTION, + CONNECTION_TO_ASSET, CONNECTION_TO_ASSET_GUID, 0, null, + null, 0, false, false, 0, methodName); if (CollectionUtils.isNotEmpty(connections)) { List connectionList = new ArrayList<>(); @@ -1393,35 +1228,22 @@ private List getEntityClassifications(String userId, String asse private List searchEntityByCriteria(String userId, String searchCriteria, String entityTypeGUID, - SearchParameters searchParameters, OMRSMetadataCollection metadataCollection) - throws org.odpi.openmetadata.repositoryservices.ffdc.exception.UserNotAuthorizedException, - FunctionNotSupportedException, org.odpi.openmetadata.repositoryservices.ffdc.exception.InvalidParameterException, - PropertyErrorException, TypeErrorException, PagingErrorException, RepositoryErrorException, InvalidParameterException { - - InstanceProperties matchProperties = new InstanceProperties(); - PrimitivePropertyValue primitivePropertyValue = new PrimitivePropertyValue(); - - primitivePropertyValue.setPrimitiveDefCategory(PrimitiveDefCategory.OM_PRIMITIVE_TYPE_STRING); - primitivePropertyValue.setPrimitiveValue(searchCriteria); - primitivePropertyValue.setTypeName(PrimitiveDefCategory.OM_PRIMITIVE_TYPE_STRING.getName()); - primitivePropertyValue.setTypeGUID(PrimitiveDefCategory.OM_PRIMITIVE_TYPE_STRING.getGUID()); + String entityTypeName, + SearchParameters searchParameters, + String methodName) + throws InvalidParameterException, PropertyServerException, UserNotAuthorizedException { + String propertyName = NAME; if (commonHandler.hasDisplayName(userId, entityTypeGUID)) { - matchProperties.setProperty(DISPLAY_NAME, primitivePropertyValue); - } else { - matchProperties.setProperty(NAME, primitivePropertyValue); + propertyName = DISPLAY_NAME; } - List entitiesByPropertyValue = metadataCollection.findEntitiesByProperty(userId, - entityTypeGUID, - matchProperties, - MatchCriteria.ANY, - searchParameters.getFrom(), - Collections.singletonList(InstanceStatus.ACTIVE), - searchParameters.getLimitResultsByClassification(), - null, - searchParameters.getSequencingProperty(), - searchParameters.getSequencingOrder() == null ? SequencingOrder.ANY : searchParameters.getSequencingOrder(), - searchParameters.getPageSize()); + + SequencingOrder sequencingOrder = searchParameters.getSequencingOrder() == null ? SequencingOrder.ANY : searchParameters.getSequencingOrder(); + List entitiesByPropertyValue = assetHandler.getEntitiesByValue(userId, searchCriteria, + SEARCH_STRING_PARAMETER_NAME, entityTypeGUID, entityTypeName, Collections.singletonList(propertyName), + searchParameters.getExactMatch(), null, null, false, + false, supportedZones, sequencingOrder.getName(),searchParameters.getFrom(), + searchParameters.getPageSize(), null, methodName); if (CollectionUtils.isNotEmpty(entitiesByPropertyValue)) { return entitiesByPropertyValue; diff --git a/open-metadata-implementation/access-services/asset-catalog/asset-catalog-server/src/main/java/org/odpi/openmetadata/accessservices/assetcatalog/handlers/CommonHandler.java b/open-metadata-implementation/access-services/asset-catalog/asset-catalog-server/src/main/java/org/odpi/openmetadata/accessservices/assetcatalog/handlers/CommonHandler.java index c87575e9668..3cdd7dc6548 100644 --- a/open-metadata-implementation/access-services/asset-catalog/asset-catalog-server/src/main/java/org/odpi/openmetadata/accessservices/assetcatalog/handlers/CommonHandler.java +++ b/open-metadata-implementation/access-services/asset-catalog/asset-catalog-server/src/main/java/org/odpi/openmetadata/accessservices/assetcatalog/handlers/CommonHandler.java @@ -3,8 +3,10 @@ package org.odpi.openmetadata.accessservices.assetcatalog.handlers; import org.apache.commons.collections4.CollectionUtils; -import org.odpi.openmetadata.accessservices.assetcatalog.builders.AssetCatalogConverter; +import org.odpi.openmetadata.accessservices.assetcatalog.converters.AssetCatalogConverter; +import org.odpi.openmetadata.accessservices.assetcatalog.model.AssetCatalogBean; import org.odpi.openmetadata.accessservices.assetcatalog.model.Type; +import org.odpi.openmetadata.commonservices.generichandlers.OpenMetadataAPIGenericHandler; import org.odpi.openmetadata.commonservices.repositoryhandler.RepositoryErrorHandler; import org.odpi.openmetadata.commonservices.repositoryhandler.RepositoryHandler; import org.odpi.openmetadata.frameworks.connectors.ffdc.InvalidParameterException; @@ -17,16 +19,15 @@ import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.typedefs.TypeDefAttribute; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.typedefs.TypeDefLink; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.repositoryconnector.OMRSRepositoryHelper; -import org.odpi.openmetadata.repositoryservices.ffdc.exception.EntityNotKnownException; -import org.odpi.openmetadata.repositoryservices.ffdc.exception.EntityProxyOnlyException; -import org.odpi.openmetadata.repositoryservices.ffdc.exception.RepositoryErrorException; import org.odpi.openmetadata.repositoryservices.ffdc.exception.TypeErrorException; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; +import java.util.HashMap; import java.util.HashSet; import java.util.List; +import java.util.Map; import java.util.Objects; import java.util.Optional; import java.util.Set; @@ -45,9 +46,11 @@ public class CommonHandler { public static final String ZONE_MEMBERSHIP = "zoneMembership"; + public static final String NONE = "none"; private final String sourceName; private final RepositoryHandler repositoryHandler; private final OMRSRepositoryHelper repositoryHelper; + private final OpenMetadataAPIGenericHandler assetHandler; private final RepositoryErrorHandler errorHandler; /** @@ -56,12 +59,15 @@ public class CommonHandler { * @param sourceName the name of the component * @param repositoryHandler manages calls to the repository services * @param repositoryHelper provides utilities for manipulating the repository services objects + * @param assetHandler provides utilities for manipulating asset catalog objects using a generic handler * @param errorHandler provides common validation routines for the other handler classes */ - public CommonHandler(String sourceName, RepositoryHandler repositoryHandler, OMRSRepositoryHelper repositoryHelper, RepositoryErrorHandler errorHandler) { + CommonHandler(String sourceName, RepositoryHandler repositoryHandler, OMRSRepositoryHelper repositoryHelper, + OpenMetadataAPIGenericHandler assetHandler, RepositoryErrorHandler errorHandler) { this.sourceName = sourceName; this.repositoryHandler = repositoryHandler; this.repositoryHelper = repositoryHelper; + this.assetHandler = assetHandler; this.errorHandler = errorHandler; } @@ -79,7 +85,7 @@ OMRSMetadataCollection getOMRSMetadataCollection() { List getTypeContext(String userId, String typeDefName) { List response = new ArrayList<>(); TypeDef typeDefByName = repositoryHelper.getTypeDefByName(userId, typeDefName); - AssetCatalogConverter converter = new AssetCatalogConverter(sourceName, repositoryHelper); + AssetCatalogConverter converter = new AssetCatalogConverter<>(repositoryHelper, sourceName, assetHandler.getServerName()); if (typeDefByName != null) { if (repositoryHelper.getKnownTypeDefGallery() == null @@ -109,7 +115,7 @@ List getTypeContext(String userId, String typeDefName) { Type getTypeByTypeDefName(String userId, String typeDefName) { TypeDef typeDefByName = repositoryHelper.getTypeDefByName(userId, typeDefName); - AssetCatalogConverter converter = new AssetCatalogConverter(sourceName, repositoryHelper); + AssetCatalogConverter converter = new AssetCatalogConverter<>(repositoryHelper, sourceName, assetHandler.getServerName()); if (typeDefByName != null) { return converter.convertType(typeDefByName); @@ -182,6 +188,7 @@ List getAssetZoneMembership(List classifications) { * * @param userId calling user * @param guid unique identifier for the entity + * @param type entity type name * @return entity detail object * @throws InvalidParameterException one of the parameters is null or invalid. * @throws UserNotAuthorizedException user not authorized to issue this request. @@ -191,21 +198,14 @@ EntityDetail getEntityByGUID(String userId, String guid, String type) throws InvalidParameterException, UserNotAuthorizedException, PropertyServerException { - String entityTypeName = type == null ? "Unknown" : type; - String methodName = "getEntityByGUID"; - try { - return repositoryHandler.getMetadataCollection().getEntityDetail(userId, guid); - } catch (org.odpi.openmetadata.repositoryservices.ffdc.exception.InvalidParameterException | RepositoryErrorException e) { - errorHandler.handleRepositoryError(e, methodName); - } catch (EntityNotKnownException e) { - errorHandler.handleUnknownEntity(e, guid, entityTypeName, methodName, GUID_PARAMETER); - } catch (EntityProxyOnlyException e) { - errorHandler.handleEntityProxy(e, guid, entityTypeName, methodName, GUID_PARAMETER); - } catch (org.odpi.openmetadata.repositoryservices.ffdc.exception.UserNotAuthorizedException e) { - errorHandler.handleUnauthorizedUser(userId, methodName); + String entityTypeName = type; + if(NONE.equals(type)) { + entityTypeName = null; } - - return null; + String methodName = "getEntityByGUID"; + return assetHandler.getEntityFromRepository(userId, guid, GUID_PARAMETER, entityTypeName, + null, null, false, false, + null, methodName); } /** @@ -226,6 +226,29 @@ List getTypesGUID(String userId, List types) { collect(Collectors.toList()); } + /** + * Return a map of the types def GUIDs and their associated type names + * + * @param userId calling user + * @param types list of the type def names + * @return a list of type def GUIDs + */ + Map getTypesAndGUIDs(String userId, List types) { + if (CollectionUtils.isEmpty(types)) { + return Collections.emptyMap(); + } + Map typesAndGUIDs = new HashMap<>(); + for (String type : types) { + TypeDef typeDef = repositoryHelper.getTypeDefByName(userId, type); + String typeDefGUID = null; + if(typeDef != null) { + typeDefGUID = typeDef.getGUID(); + } + typesAndGUIDs.put(type, typeDefGUID); + } + return typesAndGUIDs; + } + private void collectSubTypes(List types, List activeTypeDefs, List collector) { for (Type currentSubType : types) { List subTypes = getSubTypes(activeTypeDefs, currentSubType); @@ -236,7 +259,7 @@ private void collectSubTypes(List types, List activeTypeDefs, Lis private List getSubTypes(List activeTypeDefs, Type type) { String typeName = type.getName(); - AssetCatalogConverter converter = new AssetCatalogConverter(sourceName, repositoryHelper); + AssetCatalogConverter converter = new AssetCatalogConverter<>(repositoryHelper, sourceName, assetHandler.getServerName()); List subTypes = new ArrayList<>(); for (TypeDef typeDef : activeTypeDefs) { diff --git a/open-metadata-implementation/access-services/asset-catalog/asset-catalog-server/src/main/java/org/odpi/openmetadata/accessservices/assetcatalog/handlers/RelationshipHandler.java b/open-metadata-implementation/access-services/asset-catalog/asset-catalog-server/src/main/java/org/odpi/openmetadata/accessservices/assetcatalog/handlers/RelationshipHandler.java index 6e1de0453ea..6a68c620f8e 100644 --- a/open-metadata-implementation/access-services/asset-catalog/asset-catalog-server/src/main/java/org/odpi/openmetadata/accessservices/assetcatalog/handlers/RelationshipHandler.java +++ b/open-metadata-implementation/access-services/asset-catalog/asset-catalog-server/src/main/java/org/odpi/openmetadata/accessservices/assetcatalog/handlers/RelationshipHandler.java @@ -2,14 +2,16 @@ /* Copyright Contributors to the ODPi Egeria project. */ package org.odpi.openmetadata.accessservices.assetcatalog.handlers; -import org.odpi.openmetadata.accessservices.assetcatalog.builders.AssetCatalogConverter; +import org.odpi.openmetadata.accessservices.assetcatalog.converters.AssetCatalogConverter; +import org.odpi.openmetadata.accessservices.assetcatalog.model.AssetCatalogBean; +import org.odpi.openmetadata.accessservices.assetcatalog.util.Constants; import org.odpi.openmetadata.commonservices.ffdc.InvalidParameterHandler; +import org.odpi.openmetadata.commonservices.generichandlers.OpenMetadataAPIGenericHandler; import org.odpi.openmetadata.commonservices.repositoryhandler.RepositoryErrorHandler; import org.odpi.openmetadata.commonservices.repositoryhandler.RepositoryHandler; import org.odpi.openmetadata.frameworks.connectors.ffdc.InvalidParameterException; import org.odpi.openmetadata.frameworks.connectors.ffdc.PropertyServerException; import org.odpi.openmetadata.frameworks.connectors.ffdc.UserNotAuthorizedException; -import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.EntityDetail; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.Relationship; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.repositoryconnector.OMRSRepositoryHelper; @@ -19,38 +21,40 @@ */ public class RelationshipHandler { - private final RepositoryHandler repositoryHandler; + public static final String ENTITY_1_GUID_PARAMETER = "entity1GUID"; + public static final String ENTITY_2_GUID_PARAMETER = "entity2GUID"; private final OMRSRepositoryHelper repositoryHelper; private final InvalidParameterHandler invalidParameterHandler; - private final RepositoryErrorHandler errorHandler; - private final String sourceName; + private final OpenMetadataAPIGenericHandler assetHandler; + private final CommonHandler commonHandler; - private CommonHandler commonHandler; + private final String sourceName; /** * Construct the handler information needed to interact with the repository services * - * @param sourceName name of the component + * @param sourceName name of the component * @param invalidParameterHandler handler for managing parameter errors * @param repositoryHandler manages calls to the repository services * @param repositoryHelper provides utilities for manipulating the repository services objects + * @param assetHandler provides utilities for manipulating asset catalog objects using a generic handler * @param errorHandler provides common validation routines for the other handler classes */ public RelationshipHandler(String sourceName, InvalidParameterHandler invalidParameterHandler, RepositoryHandler repositoryHandler, - OMRSRepositoryHelper repositoryHelper, RepositoryErrorHandler errorHandler, CommonHandler commonHandler) { + OMRSRepositoryHelper repositoryHelper, OpenMetadataAPIGenericHandler assetHandler, + RepositoryErrorHandler errorHandler) { this.sourceName = sourceName; this.invalidParameterHandler = invalidParameterHandler; this.repositoryHelper = repositoryHelper; - this.repositoryHandler = repositoryHandler; - this.errorHandler = errorHandler; - this.commonHandler = commonHandler; + this.assetHandler = assetHandler; + this.commonHandler = new CommonHandler(sourceName, repositoryHandler, repositoryHelper, assetHandler, errorHandler); } /** * Fetch relationship between entities details based on its unique identifier of the ends * * @param userId String unique identifier for the user - * @param serverName String server name + * @param serverName server name * @param entity1GUID Entity guid of the first end of the relationship * @param entity2GUID Entity guid of the second end of the relationship * @param relationshipType Type of the relationship @@ -68,30 +72,21 @@ public org.odpi.openmetadata.accessservices.assetcatalog.model.Relationship getR final String methodName = "getRelationshipBetweenEntities"; invalidParameterHandler.validateUserId(userId, methodName); - invalidParameterHandler.validateGUID(entity1GUID, "entity1GUID", methodName); - invalidParameterHandler.validateGUID(entity2GUID, "entity2GUID", methodName); + invalidParameterHandler.validateGUID(entity1GUID, ENTITY_1_GUID_PARAMETER, methodName); + invalidParameterHandler.validateGUID(entity2GUID, ENTITY_2_GUID_PARAMETER, methodName); String relationshipTypeGUID = null; if (relationshipType != null) { relationshipTypeGUID = commonHandler.getTypeDefGUID(userId, relationshipType); } - EntityDetail entityDetail1 = commonHandler.getEntityByGUID(userId, entity1GUID, null); - if(entityDetail1 == null){ - invalidParameterHandler.throwUnknownElement(userId, entity1GUID, "-unknown-", sourceName, serverName, methodName); - } - String entity1TypeName = entityDetail1.getType().getTypeDefName(); - - Relationship relationshipBetweenEntities = repositoryHandler.getRelationshipBetweenEntities(userId, - entity1GUID, - entity1TypeName, - entity2GUID, - relationshipTypeGUID, - relationshipType, - methodName); + Relationship relationshipBetweenEntities = assetHandler.getUniqueAttachmentLink(userId, entity1GUID, + Constants.GUID_PARAMETER, "", relationshipTypeGUID, relationshipType, entity2GUID, + "", null, methodName); if (relationshipBetweenEntities != null) { - AssetCatalogConverter converter = new AssetCatalogConverter(sourceName, repositoryHelper); + AssetCatalogConverter converter = new AssetCatalogConverter<>(repositoryHelper, serverName, + assetHandler.getServerName()); return converter.convertRelationship(relationshipBetweenEntities); } diff --git a/open-metadata-implementation/access-services/asset-catalog/asset-catalog-server/src/main/java/org/odpi/openmetadata/accessservices/assetcatalog/listenenrs/AssetCatalogOMRSTopicListener.java b/open-metadata-implementation/access-services/asset-catalog/asset-catalog-server/src/main/java/org/odpi/openmetadata/accessservices/assetcatalog/listeners/AssetCatalogOMRSTopicListener.java similarity index 92% rename from open-metadata-implementation/access-services/asset-catalog/asset-catalog-server/src/main/java/org/odpi/openmetadata/accessservices/assetcatalog/listenenrs/AssetCatalogOMRSTopicListener.java rename to open-metadata-implementation/access-services/asset-catalog/asset-catalog-server/src/main/java/org/odpi/openmetadata/accessservices/assetcatalog/listeners/AssetCatalogOMRSTopicListener.java index 84e83efc8b8..9f401a74827 100644 --- a/open-metadata-implementation/access-services/asset-catalog/asset-catalog-server/src/main/java/org/odpi/openmetadata/accessservices/assetcatalog/listenenrs/AssetCatalogOMRSTopicListener.java +++ b/open-metadata-implementation/access-services/asset-catalog/asset-catalog-server/src/main/java/org/odpi/openmetadata/accessservices/assetcatalog/listeners/AssetCatalogOMRSTopicListener.java @@ -1,9 +1,9 @@ /* SPDX-License-Identifier: Apache-2.0 */ /* Copyright Contributors to the ODPi Egeria project. */ -package org.odpi.openmetadata.accessservices.assetcatalog.listenenrs; +package org.odpi.openmetadata.accessservices.assetcatalog.listeners; import org.odpi.openmetadata.accessservices.assetcatalog.auditlog.AssetCatalogAuditCode; -import org.odpi.openmetadata.accessservices.assetcatalog.builders.AssetCatalogConverter; +import org.odpi.openmetadata.accessservices.assetcatalog.converters.AssetCatalogConverter; import org.odpi.openmetadata.accessservices.assetcatalog.model.AssetCatalogBean; import org.odpi.openmetadata.accessservices.assetcatalog.model.AssetCatalogEvent; import org.odpi.openmetadata.accessservices.assetcatalog.publishers.AssetCatalogSearchPublisher; @@ -32,15 +32,15 @@ public class AssetCatalogOMRSTopicListener extends OMRSTopicListenerBase { private static final Logger log = LoggerFactory.getLogger( AssetCatalogOMRSTopicListener.class ); - private static final String ASSET_TYPE = "Asset"; + private static final String ASSET_TYPE = "Asset"; - private OMRSRepositoryHelper repositoryHelper; - private OMRSRepositoryValidator repositoryValidator; - private String serverName; - private List supportedZones; - private List supportedTypesForSearch; - private AssetCatalogSearchPublisher publisher; - private AssetCatalogConverter converter; + private final OMRSRepositoryHelper repositoryHelper; + private final OMRSRepositoryValidator repositoryValidator; + private final String serverName; + private final List supportedZones; + private final List supportedTypesForSearch; + private final AssetCatalogSearchPublisher publisher; + private final AssetCatalogConverter converter; public AssetCatalogOMRSTopicListener(String serviceName, AuditLog auditLog, @@ -57,7 +57,7 @@ public AssetCatalogOMRSTopicListener(String serviceName, this.supportedZones = supportedZones; this.repositoryHelper = repositoryHelper; this.repositoryValidator = repositoryValidator; - this.converter = new AssetCatalogConverter(serverName, repositoryHelper); + this.converter = new AssetCatalogConverter<>(repositoryHelper, serviceName, serverName); this.supportedTypesForSearch = supportedTypesForSearch; } diff --git a/open-metadata-implementation/access-services/asset-catalog/asset-catalog-server/src/main/java/org/odpi/openmetadata/accessservices/assetcatalog/service/AssetCatalogRESTService.java b/open-metadata-implementation/access-services/asset-catalog/asset-catalog-server/src/main/java/org/odpi/openmetadata/accessservices/assetcatalog/service/AssetCatalogRESTService.java index 6faad496521..36c7f80e496 100644 --- a/open-metadata-implementation/access-services/asset-catalog/asset-catalog-server/src/main/java/org/odpi/openmetadata/accessservices/assetcatalog/service/AssetCatalogRESTService.java +++ b/open-metadata-implementation/access-services/asset-catalog/asset-catalog-server/src/main/java/org/odpi/openmetadata/accessservices/assetcatalog/service/AssetCatalogRESTService.java @@ -3,7 +3,6 @@ package org.odpi.openmetadata.accessservices.assetcatalog.service; import org.odpi.openmetadata.accessservices.assetcatalog.admin.AssetCatalogInstanceHandler; -import org.odpi.openmetadata.accessservices.assetcatalog.exception.AssetCatalogException; import org.odpi.openmetadata.accessservices.assetcatalog.handlers.AssetCatalogHandler; import org.odpi.openmetadata.accessservices.assetcatalog.model.AssetCatalogBean; import org.odpi.openmetadata.accessservices.assetcatalog.model.Elements; @@ -30,8 +29,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.List; - /** * The AssetCatalogService provides the server-side implementation of the Asset Catalog Open Metadata * Assess Service (OMAS). @@ -45,7 +42,7 @@ public class AssetCatalogRESTService { private final AssetCatalogInstanceHandler instanceHandler = new AssetCatalogInstanceHandler(); private final RESTExceptionHandler restExceptionHandler = new RESTExceptionHandler(); - private ExceptionHandler exceptionHandler = new ExceptionHandler(); + private final ExceptionHandler exceptionHandler = new ExceptionHandler(); /** * Fetch asset's header, classification and properties @@ -155,43 +152,6 @@ public ClassificationListResponse getClassificationByAssetGUID(String serverName return response; } - /** - * Return a sub-graph of relationships that connect two assets - * - * @param serverName unique identifier for requested server. - * @param userId the unique identifier for the user - * @param startAssetGUID the starting asset identifier of the query - * @param endAssetGUID the ending asset identifier of the query - * @return a list of relationships that connects the assets - */ - public RelationshipListResponse getLinkingRelationships(String serverName, - String userId, - String startAssetGUID, - String endAssetGUID) { - String methodName = "getLinkingRelationships"; - log.debug(CALLING_METHOD, methodName); - - RelationshipListResponse response = new RelationshipListResponse(); - try { - - AssetCatalogHandler assetCatalogHandler = instanceHandler.getAssetCatalogHandler(userId, serverName, methodName); - response.setRelationships(assetCatalogHandler.getLinkingRelationshipsBetweenAssets(serverName, - userId, startAssetGUID, endAssetGUID)); - } catch (AssetCatalogException e) { - exceptionHandler.captureAssetCatalogExeption(response, e); - } catch (org.odpi.openmetadata.frameworks.connectors.ffdc.UserNotAuthorizedException e) { - restExceptionHandler.captureUserNotAuthorizedException(response, e); - } catch (org.odpi.openmetadata.frameworks.connectors.ffdc.InvalidParameterException e) { - restExceptionHandler.captureInvalidParameterException(response, e); - } catch (org.odpi.openmetadata.frameworks.connectors.ffdc.PropertyServerException e) { - restExceptionHandler.capturePropertyServerException(response, e); - } - - log.debug(METHOD_WITH_RESPONSE, methodName, response); - - return response; - } - public RelationshipListResponse getAssetRelationships(String serverName, String userId, String assetGUID, @@ -220,69 +180,6 @@ public RelationshipListResponse getAssetRelationships(String serverName, return response; } - public AssetCatalogListResponse getLinkingAssets(String serverName, - String userId, - String startAssetId, - String endAssetId) { - String methodName = "getLinkingAssets"; - log.debug(CALLING_METHOD, methodName); - - AssetCatalogListResponse response = new AssetCatalogListResponse(); - try { - AssetCatalogHandler assetCatalogHandler = instanceHandler.getAssetCatalogHandler(userId, serverName, methodName); - response.setAssetCatalogBeanList(assetCatalogHandler.getIntermediateAssets(userId, startAssetId, endAssetId, serverName)); - } catch (AssetCatalogException e) { - exceptionHandler.captureAssetCatalogExeption(response, e); - } catch (org.odpi.openmetadata.frameworks.connectors.ffdc.UserNotAuthorizedException e) { - restExceptionHandler.captureUserNotAuthorizedException(response, e); - } catch (org.odpi.openmetadata.frameworks.connectors.ffdc.InvalidParameterException e) { - restExceptionHandler.captureInvalidParameterException(response, e); - } catch (org.odpi.openmetadata.frameworks.connectors.ffdc.PropertyServerException e) { - restExceptionHandler.capturePropertyServerException(response, e); - } - - log.debug(METHOD_WITH_RESPONSE, methodName, response); - - return response; - } - - /** - * Returns the sub-graph that represents the returned linked relationships. - * - * @param serverName unique identifier for requested server. - * @param userId the unique identifier for the user - * @param assetGUID the starting asset identifier of the query - * @param searchParameters constrains to make the assets's search results more precise - * @return a list of assets that in neighborhood of the given asset - */ - public AssetCatalogListResponse getAssetsFromNeighborhood(String serverName, - String userId, - String assetGUID, - SearchParameters searchParameters) { - String methodName = "getAssetsFromNeighborhood"; - log.debug(CALLING_METHOD, methodName); - - AssetCatalogListResponse response = new AssetCatalogListResponse(); - try { - AssetCatalogHandler assetCatalogHandler = instanceHandler.getAssetCatalogHandler(userId, serverName, methodName); - List entitiesFromNeighborhood = assetCatalogHandler.getEntitiesFromNeighborhood(userId, assetGUID, searchParameters, serverName); - - response.setAssetCatalogBeanList(entitiesFromNeighborhood); - } catch (AssetCatalogException e) { - exceptionHandler.captureAssetCatalogExeption(response, e); - } catch (org.odpi.openmetadata.frameworks.connectors.ffdc.UserNotAuthorizedException e) { - restExceptionHandler.captureUserNotAuthorizedException(response, e); - } catch (org.odpi.openmetadata.frameworks.connectors.ffdc.InvalidParameterException e) { - restExceptionHandler.captureInvalidParameterException(response, e); - } catch (org.odpi.openmetadata.frameworks.connectors.ffdc.PropertyServerException e) { - restExceptionHandler.capturePropertyServerException(response, e); - } - - log.debug(METHOD_WITH_RESPONSE, methodName, response); - - return response; - } - /** * Return a list of assets/glossary terms/schema elements matching the search criteria without the full context. * If the searchParameters have an empty list of entity types, the response contains Glossary Terms, Schema Elements, Assets diff --git a/open-metadata-implementation/access-services/asset-catalog/asset-catalog-server/src/main/java/org/odpi/openmetadata/accessservices/assetcatalog/util/Constants.java b/open-metadata-implementation/access-services/asset-catalog/asset-catalog-server/src/main/java/org/odpi/openmetadata/accessservices/assetcatalog/util/Constants.java index 6cdda3ae5be..11ea1479c72 100644 --- a/open-metadata-implementation/access-services/asset-catalog/asset-catalog-server/src/main/java/org/odpi/openmetadata/accessservices/assetcatalog/util/Constants.java +++ b/open-metadata-implementation/access-services/asset-catalog/asset-catalog-server/src/main/java/org/odpi/openmetadata/accessservices/assetcatalog/util/Constants.java @@ -77,8 +77,6 @@ public final class Constants { public static final String HOST_LOCATION = "HostLocation"; public static final String ASSET_LOCATION_GUID = "bc236b62-d0e6-4c5c-93a1-3a35c3dba7b1"; public static final String ASSET_LOCATION = "AssetLocation"; - public static final String NESTED_LOCATION_GUID = "f82a96c2-95a3-4223-88c0-9cbf2882b772"; - public static final String NESTED_LOCATION = "NestedLocation"; public static final String API_ENDPOINT_GUID = "de5b9501-3ad4-4803-a8b2-e311c72a4336"; public static final String API_ENDPOINT = "APIEndpoint"; public static final String CONNECTION_ENDPOINT_GUID = "887a7132-d6bc-4b92-a483-e80b60c86fb2"; @@ -90,7 +88,6 @@ public final class Constants { public static final String ATTRIBUTE_FOR_SCHEMA_GUID = "86b176a2-015c-44a6-8106-54d5d69ba661"; public static final String ATTRIBUTE_FOR_SCHEMA = "AttributeForSchema"; //Instance Properties fields - public static final String TYPE = "dataType"; public static final String QUALIFIED_NAME = "qualifiedName"; public static final String NAME = "name"; public static final String DISPLAY_NAME = "displayName"; @@ -99,4 +96,5 @@ public final class Constants { public static final String GUID_PARAMETER = "GUID"; public static final String SEARCH_PARAMETER = "searchParameter"; public static final String ADDITIONAL_PROPERTIES_PROPERTY_NAME = "additionalProperties"; + public static final String SEARCH_STRING_PARAMETER_NAME = "searchCriteria"; } \ No newline at end of file diff --git a/open-metadata-implementation/access-services/asset-catalog/asset-catalog-server/src/test/java/org/odpi/openmetadata/accessservices/assetcatalog/handlers/AssetCatalogHandlerTest.java b/open-metadata-implementation/access-services/asset-catalog/asset-catalog-server/src/test/java/org/odpi/openmetadata/accessservices/assetcatalog/handlers/AssetCatalogHandlerTest.java index c9d15d188d7..ec53783d4c5 100644 --- a/open-metadata-implementation/access-services/asset-catalog/asset-catalog-server/src/test/java/org/odpi/openmetadata/accessservices/assetcatalog/handlers/AssetCatalogHandlerTest.java +++ b/open-metadata-implementation/access-services/asset-catalog/asset-catalog-server/src/test/java/org/odpi/openmetadata/accessservices/assetcatalog/handlers/AssetCatalogHandlerTest.java @@ -7,29 +7,29 @@ import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.MockitoAnnotations; +import org.odpi.openmetadata.accessservices.assetcatalog.converters.AssetCatalogConverter; import org.odpi.openmetadata.accessservices.assetcatalog.exception.AssetCatalogErrorCode; import org.odpi.openmetadata.accessservices.assetcatalog.exception.AssetCatalogException; import org.odpi.openmetadata.accessservices.assetcatalog.model.AssetCatalogBean; -import org.odpi.openmetadata.accessservices.assetcatalog.model.Elements; import org.odpi.openmetadata.accessservices.assetcatalog.model.Classification; +import org.odpi.openmetadata.accessservices.assetcatalog.model.Elements; +import org.odpi.openmetadata.accessservices.assetcatalog.model.Type; import org.odpi.openmetadata.accessservices.assetcatalog.model.rest.body.SearchParameters; import org.odpi.openmetadata.commonservices.ffdc.InvalidParameterHandler; +import org.odpi.openmetadata.commonservices.generichandlers.AssetHandler; import org.odpi.openmetadata.commonservices.repositoryhandler.RepositoryErrorHandler; import org.odpi.openmetadata.commonservices.repositoryhandler.RepositoryHandler; import org.odpi.openmetadata.frameworks.connectors.ffdc.InvalidParameterException; import org.odpi.openmetadata.frameworks.connectors.ffdc.PropertyServerException; import org.odpi.openmetadata.frameworks.connectors.ffdc.UserNotAuthorizedException; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.OMRSMetadataCollection; -import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.MatchCriteria; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.SequencingOrder; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.EntityDetail; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.InstanceGraph; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.InstanceProperties; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.InstanceStatus; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.InstanceType; -import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.PrimitivePropertyValue; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.Relationship; -import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.typedefs.PrimitiveDefCategory; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.typedefs.TypeDef; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.typedefs.TypeDefLink; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.repositoryconnector.OMRSRepositoryHelper; @@ -53,6 +53,7 @@ import static org.mockito.Mockito.when; import static org.odpi.openmetadata.accessservices.assetcatalog.util.Constants.GUID_PARAMETER; import static org.odpi.openmetadata.accessservices.assetcatalog.util.Constants.NAME; +import static org.odpi.openmetadata.accessservices.assetcatalog.util.Constants.SEARCH_STRING_PARAMETER_NAME; public class AssetCatalogHandlerTest { @@ -64,7 +65,6 @@ public class AssetCatalogHandlerTest { private static final String ASSET_TYPE_GUID = "ababa-12232-abc"; private static final String SEARCH_CRITERIA = "employee"; private static final String FIRST_GUID = "ababa-123-acbd"; - private static final String SECOND_GUID = "ababc-2134-2341f"; private static final String RELATIONSHIP_TYPE_GUID = "adadad-bcba-123"; public static final String SERVER_NAME = "server"; private final String USER = "test-user"; @@ -74,6 +74,9 @@ public class AssetCatalogHandlerTest { @Mock private RepositoryHandler repositoryHandler; + @Mock + private AssetHandler assetHandler; + @Mock private OMRSRepositoryHelper repositoryHelper; @@ -83,6 +86,9 @@ public class AssetCatalogHandlerTest { @Mock private RepositoryErrorHandler errorHandler; + @Mock + private AssetCatalogConverter assetCatalogConverter; + @InjectMocks private AssetCatalogHandler assetCatalogHandler; @@ -95,12 +101,12 @@ public void before() { } @Test - public void getEntityDetails() throws InvalidParameterException, PropertyServerException, UserNotAuthorizedException, RepositoryErrorException { + public void getEntityDetails() throws InvalidParameterException, PropertyServerException, UserNotAuthorizedException { String methodName = "getEntityDetails"; - mockMetadataCollection(); - mockEntityDetails(FIRST_GUID); - + EntityDetail mockEntityDetail = mockEntityDetails(FIRST_GUID); + AssetCatalogBean assetCatalogBean = convertEntityToAssetCatalogBean(mockEntityDetail); + when(assetCatalogConverter.getAssetCatalogBean(mockEntityDetail)).thenReturn(assetCatalogBean); AssetCatalogBean result = assetCatalogHandler.getEntityDetails(USER, FIRST_GUID, ASSET_TYPE); assertEquals(FIRST_GUID, result.getGuid()); @@ -109,9 +115,8 @@ public void getEntityDetails() throws InvalidParameterException, PropertyServerE } @Test - public void getEntityDetails_throwsInvalidParameterException() throws InvalidParameterException, PropertyServerException, UserNotAuthorizedException, RepositoryErrorException { + public void getEntityDetails_throwsInvalidParameterException() throws InvalidParameterException, PropertyServerException, UserNotAuthorizedException { String methodName = "getEntityDetails"; - mockMetadataCollection(); mockEntityDetails(FIRST_GUID); doThrow(new org.odpi.openmetadata.commonservices.ffdc.exceptions.InvalidParameterException(AssetCatalogErrorCode.SERVICE_NOT_INITIALIZED.getMessageDefinition(SERVER_NAME), this.getClass().getName(), "", "")) @@ -126,12 +131,13 @@ public void getRelationshipsByEntityGUID() throws InvalidParameterException, Pro List relationshipsByType = Collections.singletonList(mockRelationship()); - when(repositoryHandler.getRelationshipsByType(USER, - FIRST_GUID, - ASSET_TYPE, - null, - null, - methodName)).thenReturn(relationshipsByType); + when(invalidParameterHandler.getMaxPagingSize()).thenReturn(500); + when(assetHandler.getAttachmentLinks(USER, FIRST_GUID, GUID_PARAMETER, + ASSET_TYPE, null, null, null, + 0, 500, null, methodName)) + .thenReturn(relationshipsByType); + when(assetCatalogConverter.convertRelationships(relationshipsByType)). + thenReturn(convertRelationships(relationshipsByType)); List result = assetCatalogHandler.getRelationshipsByEntityGUID(USER, FIRST_GUID, ASSET_TYPE); @@ -166,11 +172,23 @@ public void getRelationshipsByEntityGUID_throwsInvalidParameterException() throw } @Test - public void getEntityClassificationByName() throws InvalidParameterException, PropertyServerException, UserNotAuthorizedException, RepositoryErrorException { + public void getEntityClassificationByName() throws InvalidParameterException, PropertyServerException, UserNotAuthorizedException { String methodName = "getEntityClassificationByName"; - mockMetadataCollection(); - mockEntityDetails(FIRST_GUID); + EntityDetail entityDetail = new EntityDetail(); + when(commonHandler + .getEntityByGUID(USER, FIRST_GUID, ASSET_TYPE)) + .thenReturn(entityDetail); + + entityDetail.setGUID(FIRST_GUID); + entityDetail.setType(mockType(ASSET_TYPE, ASSET_TYPE_GUID)); + List + classifications = mockClassifications(); + entityDetail.setClassifications(classifications); + entityDetail.setProperties(mockProperties()); + Classification classification = new Classification(); + classification.setName(CLASSIFICATION_NAME); + when(assetCatalogConverter.convertClassifications(classifications)).thenReturn(Collections.singletonList(classification)); List result = assetCatalogHandler .getEntityClassificationByName(USER, FIRST_GUID, ASSET_TYPE, CLASSIFICATION_NAME); @@ -182,10 +200,9 @@ public void getEntityClassificationByName() throws InvalidParameterException, Pr } @Test - public void getEntityClassificationByName_throwsInvalidParameterException() throws InvalidParameterException, PropertyServerException, UserNotAuthorizedException, RepositoryErrorException { + public void getEntityClassificationByName_throwsInvalidParameterException() throws InvalidParameterException, PropertyServerException, UserNotAuthorizedException { String methodName = "getEntityClassificationByName"; - mockMetadataCollection(); mockEntityDetails(FIRST_GUID); doThrow(new org.odpi.openmetadata.commonservices.ffdc.exceptions.InvalidParameterException(AssetCatalogErrorCode.SERVICE_NOT_INITIALIZED.getMessageDefinition(SERVER_NAME), @@ -197,162 +214,16 @@ public void getEntityClassificationByName_throwsInvalidParameterException() thro } - @Test - public void getLinkingRelationshipsBetweenAssets() - throws InvalidParameterException, PropertyServerException, UserNotAuthorizedException, org.odpi.openmetadata.repositoryservices.ffdc.exception.UserNotAuthorizedException, - EntityNotKnownException, FunctionNotSupportedException, org.odpi.openmetadata.repositoryservices.ffdc.exception.InvalidParameterException, RepositoryErrorException, PropertyErrorException, AssetCatalogException { - String methodName = "getLinkingRelationshipsBetweenAssets"; - - OMRSMetadataCollection metadataCollection = mockMetadataCollection(); - when(metadataCollection.getLinkingEntities(USER, FIRST_GUID, SECOND_GUID, Collections.singletonList(InstanceStatus.ACTIVE), null)) - .thenReturn(mockInstanceGraph()); - - List result = assetCatalogHandler - .getLinkingRelationshipsBetweenAssets(SERVER_NAME, USER, FIRST_GUID, SECOND_GUID); - - assertEquals(RELATIONSHIP_GUID, result.get(0).getGuid()); - verify(invalidParameterHandler, times(1)).validateUserId(USER, methodName); - verify(invalidParameterHandler, times(1)).validateGUID(FIRST_GUID, "startAssetGUID", methodName); - verify(invalidParameterHandler, times(1)).validateGUID(SECOND_GUID, "endAssetGUID", methodName); - } - - @Test - public void getLinkingRelationshipsBetweenAssets_throwsInvalidParameterException() throws org.odpi.openmetadata.repositoryservices.ffdc.exception.UserNotAuthorizedException, EntityNotKnownException, FunctionNotSupportedException, org.odpi.openmetadata.repositoryservices.ffdc.exception.InvalidParameterException, RepositoryErrorException, PropertyErrorException, org.odpi.openmetadata.commonservices.ffdc.exceptions.InvalidParameterException { - String methodName = "getLinkingRelationshipsBetweenAssets"; - - OMRSMetadataCollection metadataCollection = mockMetadataCollection(); - when(metadataCollection.getLinkingEntities(USER, FIRST_GUID, SECOND_GUID, Collections.singletonList(InstanceStatus.ACTIVE), null)) - .thenReturn(mockInstanceGraph()); - - doThrow(new org.odpi.openmetadata.commonservices.ffdc.exceptions.InvalidParameterException(AssetCatalogErrorCode.SERVICE_NOT_INITIALIZED.getMessageDefinition(SERVER_NAME), - this.getClass().getName(), "", "")) - .when(invalidParameterHandler).validateUserId(USER, methodName); - - assertThrows(InvalidParameterException.class, - () -> assetCatalogHandler.getLinkingRelationshipsBetweenAssets(SERVER_NAME, USER, FIRST_GUID, SECOND_GUID)); - } - - @Test - public void getLinkingRelationshipsBetweenAssets_throwsPropertyServerException() throws org.odpi.openmetadata.repositoryservices.ffdc.exception.UserNotAuthorizedException, EntityNotKnownException, FunctionNotSupportedException, org.odpi.openmetadata.repositoryservices.ffdc.exception.InvalidParameterException, RepositoryErrorException, PropertyErrorException, PropertyServerException { - OMRSMetadataCollection metadataCollection = mockMetadataCollection(); - - FunctionNotSupportedException mockedException = new FunctionNotSupportedException(AssetCatalogErrorCode.SERVICE_NOT_INITIALIZED.getMessageDefinition(SERVER_NAME), this.getClass().getName(), ""); - - doThrow(mockedException).when(metadataCollection).getLinkingEntities(USER, FIRST_GUID, SECOND_GUID, Collections.singletonList(InstanceStatus.ACTIVE), null); - String methodName = "getLinkingRelationshipsBetweenAssets"; - doThrow(new PropertyServerException(AssetCatalogErrorCode.SERVICE_NOT_INITIALIZED.getMessageDefinition(SERVER_NAME), - this.getClass().getName(), "")).when(errorHandler).handleRepositoryError(mockedException, methodName); - assertThrows(PropertyServerException.class, - () -> assetCatalogHandler.getLinkingRelationshipsBetweenAssets(SERVER_NAME, USER, FIRST_GUID, SECOND_GUID)); - } - - @Test - public void getLinkingRelationshipsBetweenAssets_throwsUserNotAuthorizedException() throws org.odpi.openmetadata.repositoryservices.ffdc.exception.UserNotAuthorizedException, EntityNotKnownException, FunctionNotSupportedException, org.odpi.openmetadata.repositoryservices.ffdc.exception.InvalidParameterException, RepositoryErrorException, PropertyErrorException, UserNotAuthorizedException { - OMRSMetadataCollection metadataCollection = mockMetadataCollection(); - - doThrow(new org.odpi.openmetadata.repositoryservices.ffdc.exception.UserNotAuthorizedException(AssetCatalogErrorCode.SERVICE_NOT_INITIALIZED.getMessageDefinition(SERVER_NAME), - this.getClass().getName(), "", "")).when(metadataCollection).getLinkingEntities(USER, FIRST_GUID, SECOND_GUID, Collections.singletonList(InstanceStatus.ACTIVE), null); - String methodName = "getLinkingRelationshipsBetweenAssets"; - doThrow(new UserNotAuthorizedException(AssetCatalogErrorCode.SERVICE_NOT_INITIALIZED.getMessageDefinition(SERVER_NAME), - this.getClass().getName(), "", "")).when(errorHandler).handleUnauthorizedUser(USER, methodName); - - assertThrows(UserNotAuthorizedException.class, - () -> assetCatalogHandler.getLinkingRelationshipsBetweenAssets(SERVER_NAME, USER, FIRST_GUID, SECOND_GUID)); - } - - @Test - public void getLinkingRelationshipsBetweenAssets_throwsAssetNotFoundException() throws org.odpi.openmetadata.repositoryservices.ffdc.exception.UserNotAuthorizedException, EntityNotKnownException, FunctionNotSupportedException, org.odpi.openmetadata.repositoryservices.ffdc.exception.InvalidParameterException, RepositoryErrorException, PropertyErrorException { - OMRSMetadataCollection metadataCollection = mockMetadataCollection(); - when(metadataCollection.getLinkingEntities(USER, FIRST_GUID, SECOND_GUID, Collections.singletonList(InstanceStatus.ACTIVE), null)) - .thenReturn(null); - - assertThrows(AssetCatalogException.class, - () -> assetCatalogHandler.getLinkingRelationshipsBetweenAssets(SERVER_NAME, USER, FIRST_GUID, SECOND_GUID)); - } - - @Test - public void getIntermediateAssets() - throws InvalidParameterException, PropertyServerException, UserNotAuthorizedException, org.odpi.openmetadata.repositoryservices.ffdc.exception.UserNotAuthorizedException, - EntityNotKnownException, FunctionNotSupportedException, org.odpi.openmetadata.repositoryservices.ffdc.exception.InvalidParameterException, RepositoryErrorException, PropertyErrorException, AssetCatalogException { - - OMRSMetadataCollection metadataCollection = mockMetadataCollection(); - when(metadataCollection.getLinkingEntities(USER, FIRST_GUID, SECOND_GUID, Collections.singletonList(InstanceStatus.ACTIVE), null)) - .thenReturn(mockInstanceGraph()); - - List result = assetCatalogHandler.getIntermediateAssets(USER, FIRST_GUID, SECOND_GUID, SERVER_NAME); - - assertEquals(FIRST_GUID, result.get(0).getGuid()); - String methodName = "getIntermediateAssets"; - verify(invalidParameterHandler, times(1)).validateUserId(USER, methodName); - verify(invalidParameterHandler, times(1)).validateGUID(FIRST_GUID, "startAssetGUID", methodName); - verify(invalidParameterHandler, times(1)).validateGUID(SECOND_GUID, "endAssetGUID", methodName); - } - - @Test - public void getIntermediateAssets_throwsInvalidParameterException() throws org.odpi.openmetadata.repositoryservices.ffdc.exception.UserNotAuthorizedException, EntityNotKnownException, FunctionNotSupportedException, org.odpi.openmetadata.repositoryservices.ffdc.exception.InvalidParameterException, RepositoryErrorException, PropertyErrorException, org.odpi.openmetadata.commonservices.ffdc.exceptions.InvalidParameterException { - String methodName = "getIntermediateAssets"; - - OMRSMetadataCollection metadataCollection = mockMetadataCollection(); - when(metadataCollection.getLinkingEntities(USER, FIRST_GUID, SECOND_GUID, Collections.singletonList(InstanceStatus.ACTIVE), null)) - .thenReturn(mockInstanceGraph()); - - doThrow(new org.odpi.openmetadata.commonservices.ffdc.exceptions.InvalidParameterException(AssetCatalogErrorCode.SERVICE_NOT_INITIALIZED.getMessageDefinition(SERVER_NAME), this.getClass().getName(), "", "")) - .when(invalidParameterHandler).validateUserId(USER, methodName); - - assertThrows(InvalidParameterException.class, - () -> assetCatalogHandler.getIntermediateAssets(USER, FIRST_GUID, SECOND_GUID, SERVER_NAME)); - } - - @Test - public void getIntermediateAssets_throwsPropertyServerException() throws org.odpi.openmetadata.repositoryservices.ffdc.exception.UserNotAuthorizedException, EntityNotKnownException, FunctionNotSupportedException, org.odpi.openmetadata.repositoryservices.ffdc.exception.InvalidParameterException, RepositoryErrorException, PropertyErrorException, PropertyServerException { - OMRSMetadataCollection metadataCollection = mockMetadataCollection(); - String methodName = "getIntermediateAssets"; - FunctionNotSupportedException mockedException = new FunctionNotSupportedException(AssetCatalogErrorCode.SERVICE_NOT_INITIALIZED.getMessageDefinition(SERVER_NAME), - this.getClass().getName(), ""); - - when(metadataCollection.getLinkingEntities(USER, FIRST_GUID, SECOND_GUID, Collections.singletonList(InstanceStatus.ACTIVE), null)) - .thenThrow(mockedException); - doThrow(PropertyServerException.class).when(errorHandler).handleRepositoryError(mockedException, methodName); - - assertThrows(PropertyServerException.class, - () -> assetCatalogHandler.getIntermediateAssets(USER, FIRST_GUID, SECOND_GUID, SERVER_NAME)); - } - - @Test - public void getIntermediateAssets_throwsUserNotAuthorizedException() throws org.odpi.openmetadata.repositoryservices.ffdc.exception.UserNotAuthorizedException, EntityNotKnownException, FunctionNotSupportedException, org.odpi.openmetadata.repositoryservices.ffdc.exception.InvalidParameterException, RepositoryErrorException, PropertyErrorException, UserNotAuthorizedException { - OMRSMetadataCollection metadataCollection = mockMetadataCollection(); - String methodName = "getIntermediateAssets"; - doThrow(new org.odpi.openmetadata.repositoryservices.ffdc.exception.UserNotAuthorizedException(AssetCatalogErrorCode.SERVICE_NOT_INITIALIZED.getMessageDefinition(SERVER_NAME), - this.getClass().getName(), "", "")).when(metadataCollection).getLinkingEntities(USER, FIRST_GUID, SECOND_GUID, Collections.singletonList(InstanceStatus.ACTIVE), null); - doThrow(new UserNotAuthorizedException(AssetCatalogErrorCode.SERVICE_NOT_INITIALIZED.getMessageDefinition(SERVER_NAME), - this.getClass().getName(), "", "")).when(errorHandler).handleUnauthorizedUser(USER, methodName); - - assertThrows(UserNotAuthorizedException.class, - () -> assetCatalogHandler.getIntermediateAssets(USER, FIRST_GUID, SECOND_GUID, SERVER_NAME)); - } - - @Test - public void getIntermediateAssets_throwsAssetNotFoundException() throws org.odpi.openmetadata.repositoryservices.ffdc.exception.UserNotAuthorizedException, EntityNotKnownException, FunctionNotSupportedException, org.odpi.openmetadata.repositoryservices.ffdc.exception.InvalidParameterException, RepositoryErrorException, PropertyErrorException { - OMRSMetadataCollection metadataCollection = mockMetadataCollection(); - when(metadataCollection.getLinkingEntities(USER, FIRST_GUID, SECOND_GUID, Collections.singletonList(InstanceStatus.ACTIVE), null)) - .thenReturn(null); - - assertThrows(AssetCatalogException.class, - () -> assetCatalogHandler.getIntermediateAssets(USER, FIRST_GUID, SECOND_GUID, SERVER_NAME)); - } - @Test public void getRelationships() - throws InvalidParameterException, PropertyServerException, UserNotAuthorizedException, RepositoryErrorException { + throws InvalidParameterException, PropertyServerException, UserNotAuthorizedException { String methodName = "getRelationships"; mockPagedRelationships(methodName); - mockMetadataCollection(); mockTypeDef(RELATIONSHIP_TYPE, RELATIONSHIP_TYPE_GUID); List result = - assetCatalogHandler.getRelationships(USER, FIRST_GUID, ASSET_TYPE, - RELATIONSHIP_TYPE, FROM, PAGE_SIZE); + assetCatalogHandler.getRelationships(USER, FIRST_GUID, ASSET_TYPE, RELATIONSHIP_TYPE, FROM, PAGE_SIZE); assertEquals(RELATIONSHIP_GUID, result.get(0).getGuid()); assertEquals(RELATIONSHIP_TYPE, result.get(0).getType().getName()); @@ -361,7 +232,7 @@ public void getRelationships() } @Test - public void getRelationships_throwsInvalidParameterException() throws UserNotAuthorizedException, PropertyServerException, org.odpi.openmetadata.commonservices.ffdc.exceptions.InvalidParameterException { + public void getRelationships_throwsInvalidParameterException() throws UserNotAuthorizedException, PropertyServerException, InvalidParameterException { String methodName = "getRelationships"; mockPagedRelationships(methodName); @@ -376,38 +247,28 @@ public void getRelationships_throwsInvalidParameterException() throws UserNotAut } @Test - public void getRelationships_throwsPropertyServerException() throws UserNotAuthorizedException, PropertyServerException { + public void getRelationships_throwsPropertyServerException() throws UserNotAuthorizedException, PropertyServerException, InvalidParameterException { String methodName = "getRelationships"; mockTypeDef(RELATIONSHIP_TYPE, RELATIONSHIP_TYPE_GUID); - doThrow(new PropertyServerException(AssetCatalogErrorCode.SERVICE_NOT_INITIALIZED.getMessageDefinition(SERVER_NAME), - this.getClass().getName(), "")).when(repositoryHandler).getPagedRelationshipsByType(USER, - FIRST_GUID, - ASSET_TYPE, - RELATIONSHIP_TYPE_GUID, - RELATIONSHIP_TYPE, - FROM, - PAGE_SIZE, - methodName); + doThrow(new PropertyServerException(AssetCatalogErrorCode.SERVICE_NOT_INITIALIZED.getMessageDefinition(), + this.getClass().getName(), "")).when(assetHandler).getAttachmentLinks(USER, FIRST_GUID, GUID_PARAMETER, + ASSET_TYPE, RELATIONSHIP_TYPE_GUID, RELATIONSHIP_TYPE, null, + FROM, PAGE_SIZE, null, methodName); assertThrows(PropertyServerException.class, () -> assetCatalogHandler.getRelationships(USER, FIRST_GUID, ASSET_TYPE, RELATIONSHIP_TYPE, FROM, PAGE_SIZE)); } @Test - public void getRelationships_throwsUserNotAuthorizedException() throws UserNotAuthorizedException, PropertyServerException { + public void getRelationships_throwsUserNotAuthorizedException() throws UserNotAuthorizedException, PropertyServerException, InvalidParameterException { String methodName = "getRelationships"; mockTypeDef(RELATIONSHIP_TYPE, RELATIONSHIP_TYPE_GUID); - doThrow(new UserNotAuthorizedException(AssetCatalogErrorCode.SERVICE_NOT_INITIALIZED.getMessageDefinition(SERVER_NAME), - this.getClass().getName(), "", "")).when(repositoryHandler).getPagedRelationshipsByType(USER, - FIRST_GUID, - ASSET_TYPE, - RELATIONSHIP_TYPE_GUID, - RELATIONSHIP_TYPE, - FROM, - PAGE_SIZE, - methodName); + doThrow(new UserNotAuthorizedException(AssetCatalogErrorCode.SERVICE_NOT_INITIALIZED.getMessageDefinition(), + this.getClass().getName(), "", "")).when(assetHandler).getAttachmentLinks(USER, FIRST_GUID, GUID_PARAMETER, + ASSET_TYPE, RELATIONSHIP_TYPE_GUID, RELATIONSHIP_TYPE, null, + FROM, PAGE_SIZE, null, methodName); assertThrows(UserNotAuthorizedException.class, () -> assetCatalogHandler.getRelationships(USER, FIRST_GUID, ASSET_TYPE, RELATIONSHIP_TYPE, FROM, PAGE_SIZE)); @@ -419,6 +280,7 @@ public void getEntitiesFromNeighborhood() EntityNotKnownException, FunctionNotSupportedException, org.odpi.openmetadata.repositoryservices.ffdc.exception.InvalidParameterException, RepositoryErrorException, PropertyErrorException, AssetCatalogException, TypeErrorException { OMRSMetadataCollection metadataCollection = mockMetadataCollection(); + InstanceGraph instanceGraph = mockInstanceGraph(); when(metadataCollection.getEntityNeighborhood(USER, FIRST_GUID, Collections.singletonList(ASSET_TYPE_GUID), @@ -427,8 +289,11 @@ public void getEntitiesFromNeighborhood() null, null, 1)) - .thenReturn(mockInstanceGraph()); - + .thenReturn(instanceGraph); + for(EntityDetail entityDetail : instanceGraph.getEntities()) { + AssetCatalogBean assetCatalogBean = convertEntityToAssetCatalogBean(entityDetail); + when(assetCatalogConverter.getAssetCatalogBean(entityDetail)).thenReturn(assetCatalogBean); + } SearchParameters searchParams = mockSearchParams(); mockTypeDef(ASSET_TYPE, ASSET_TYPE_GUID); List result = assetCatalogHandler.getEntitiesFromNeighborhood(USER, FIRST_GUID, searchParams, SERVER_NAME); @@ -440,6 +305,13 @@ public void getEntitiesFromNeighborhood() verify(invalidParameterHandler, times(1)).validateObject(searchParams, "searchParameter", methodName); } + private AssetCatalogBean convertEntityToAssetCatalogBean(EntityDetail entityDetail) { + AssetCatalogBean assetCatalogBean = new AssetCatalogBean(); + assetCatalogBean.setGuid(entityDetail.getGUID()); + assetCatalogBean.setType(convertInstanceType(entityDetail.getType())); + return assetCatalogBean; + } + @Test public void getEntitiesFromNeighborhood_throwsInvalidParameterException() throws org.odpi.openmetadata.commonservices.ffdc.exceptions.InvalidParameterException, org.odpi.openmetadata.repositoryservices.ffdc.exception.UserNotAuthorizedException, EntityNotKnownException, FunctionNotSupportedException, org.odpi.openmetadata.repositoryservices.ffdc.exception.InvalidParameterException, RepositoryErrorException, PropertyErrorException, TypeErrorException { String methodName = "getEntitiesFromNeighborhood"; @@ -544,26 +416,23 @@ public void getTypeDefGUID() { @Test public void searchByType() throws InvalidParameterException, org.odpi.openmetadata.repositoryservices.ffdc.exception.UserNotAuthorizedException, FunctionNotSupportedException, org.odpi.openmetadata.repositoryservices.ffdc.exception.InvalidParameterException, - RepositoryErrorException, PropertyErrorException, TypeErrorException, PagingErrorException, EntityNotKnownException { + RepositoryErrorException, PropertyErrorException, TypeErrorException, PagingErrorException, EntityNotKnownException, PropertyServerException, UserNotAuthorizedException { String methodName = "searchByType"; SearchParameters searchParams = mockSearchParams(); mockTypeDef(ASSET_TYPE, ASSET_TYPE_GUID); mockSearchString(SEARCH_CRITERIA, searchParams.getCaseInsensitive()); - InstanceProperties matchProperties = mockMatchProperties(); - OMRSMetadataCollection metadataCollection = mockMetadataCollection(); - when(metadataCollection.findEntitiesByProperty(USER, - ASSET_TYPE_GUID, - matchProperties, - MatchCriteria.ANY, - FROM, - Collections.singletonList(InstanceStatus.ACTIVE), - null, - null, - null, - SequencingOrder.ANY, - PAGE_SIZE)).thenReturn(mockEntities()); + List mockedEntities = mockEntities(); + when(assetHandler.getEntitiesByValue(USER, SEARCH_CRITERIA, + SEARCH_STRING_PARAMETER_NAME, ASSET_TYPE_GUID, ASSET_TYPE, Collections.singletonList(NAME), + searchParams.getCaseInsensitive(), null, null, + false, false, null, + SequencingOrder.ANY.getName(), FROM, PAGE_SIZE, null, methodName)).thenReturn(mockedEntities); + for(EntityDetail mockedEntity : mockedEntities) { + Elements mockedElements = getElementsFromEntity(mockedEntity); + when(assetCatalogConverter.buildAssetElements(mockedEntity)).thenReturn(mockedElements); + } List elements = assetCatalogHandler.searchByType(USER, SEARCH_CRITERIA, searchParams); assertEquals(2, elements.size()); if (FIRST_GUID.equals(elements.get(0).getGuid())) @@ -581,39 +450,32 @@ public void searchByType() throws InvalidParameterException, org.odpi.openmetada verify(invalidParameterHandler, times(1)).validateObject(searchParams, "searchParameter", methodName); } - @Test - public void searchByType_throwsEntityNotKnownException() throws InvalidParameterException { - String methodName = "searchByType"; - SearchParameters searchParams = mockSearchParams(); - mockSearchString(SEARCH_CRITERIA, searchParams.getCaseInsensitive()); + private Elements getElementsFromEntity(EntityDetail mockedEntity) { + if (mockedEntity == null) { + return null; + } - assertThrows(EntityNotKnownException.class, () -> assetCatalogHandler.searchByType(USER, SEARCH_CRITERIA, searchParams)); + Elements element = new Elements(); + element.setGuid(mockedEntity.getGUID()); + element.setType(convertInstanceType(mockedEntity.getType())); - verify(invalidParameterHandler, times(1)).validateUserId(USER, methodName); - verify(invalidParameterHandler, times(1)).validatePaging(searchParams.getFrom(), - searchParams.getPageSize(), methodName); - verify(invalidParameterHandler, times(1)).validateObject(searchParams, - "searchParameter", methodName); + return element; + } + + private Type convertInstanceType(InstanceType instanceType) { + Type type = new Type(); + type.setName(instanceType.getTypeDefName()); + type.setDescription(instanceType.getTypeDefDescription()); + type.setVersion(instanceType.getTypeDefVersion()); + return type; } @Test - public void searchByType_throwsInvalidParameterException() throws org.odpi.openmetadata.commonservices.ffdc.exceptions.InvalidParameterException, org.odpi.openmetadata.repositoryservices.ffdc.exception.UserNotAuthorizedException, FunctionNotSupportedException, org.odpi.openmetadata.repositoryservices.ffdc.exception.InvalidParameterException, RepositoryErrorException, PropertyErrorException, TypeErrorException, PagingErrorException { + public void searchByType_throwsInvalidParameterException() throws InvalidParameterException { String methodName = "searchByType"; SearchParameters searchParams = mockSearchParams(); - OMRSMetadataCollection metadataCollection = mockMetadataCollection(); - when(metadataCollection.findEntitiesByPropertyValue(USER, - ASSET_TYPE_GUID, - SEARCH_CRITERIA, - FROM, - Collections.singletonList(InstanceStatus.ACTIVE), - null, - null, - null, - SequencingOrder.ANY, - PAGE_SIZE)).thenReturn(mockEntities()); - - doThrow(new org.odpi.openmetadata.commonservices.ffdc.exceptions.InvalidParameterException(AssetCatalogErrorCode.SERVICE_NOT_INITIALIZED.getMessageDefinition(SERVER_NAME), + doThrow(new org.odpi.openmetadata.commonservices.ffdc.exceptions.InvalidParameterException(AssetCatalogErrorCode.SERVICE_NOT_INITIALIZED.getMessageDefinition(), this.getClass().getName(), "", "")) .when(invalidParameterHandler).validateUserId(USER, methodName); @@ -623,13 +485,13 @@ public void searchByType_throwsInvalidParameterException() throws org.odpi.openm } @Test - public void buildContextByType() throws InvalidParameterException, PropertyServerException, UserNotAuthorizedException, RepositoryErrorException { + public void buildContextByType() throws InvalidParameterException, PropertyServerException, UserNotAuthorizedException { String methodName = "buildContextByType"; - mockMetadataCollection(); - mockEntityDetails(FIRST_GUID); + EntityDetail mockedEntity = mockEntityDetails(FIRST_GUID); mockTypeDef(ASSET_TYPE, ASSET_TYPE_GUID); - + Elements mockedElements = getElementsFromEntity(mockedEntity); + when(assetCatalogConverter.buildAssetElements(mockedEntity)).thenReturn(mockedElements); Elements elements = assetCatalogHandler.buildContextByType(USER, FIRST_GUID, ASSET_TYPE); assertEquals(FIRST_GUID, elements.getGuid()); @@ -638,9 +500,8 @@ public void buildContextByType() throws InvalidParameterException, PropertyServe } @Test - public void buildContextByType_throwsInvalidParameterException() throws InvalidParameterException, PropertyServerException, UserNotAuthorizedException, RepositoryErrorException { + public void buildContextByType_throwsInvalidParameterException() throws InvalidParameterException, PropertyServerException, UserNotAuthorizedException { String methodName = "buildContextByType"; - mockMetadataCollection(); mockEntityDetails(FIRST_GUID); mockTypeDef(ASSET_TYPE, ASSET_TYPE_GUID); @@ -664,15 +525,14 @@ private SearchParameters mockSearchParams() { } - private void mockPagedRelationships(String methodName) throws UserNotAuthorizedException, PropertyServerException { - when(repositoryHandler.getPagedRelationshipsByType(USER, - FIRST_GUID, - ASSET_TYPE, - RELATIONSHIP_TYPE_GUID, - RELATIONSHIP_TYPE, - FROM, - PAGE_SIZE, - methodName)).thenReturn(mockRelationships()); + private void mockPagedRelationships(String methodName) throws UserNotAuthorizedException, PropertyServerException, InvalidParameterException { + List mockedRelationships = mockRelationships(); + when(assetHandler.getAttachmentLinks(USER, FIRST_GUID, GUID_PARAMETER, + ASSET_TYPE, RELATIONSHIP_TYPE_GUID, RELATIONSHIP_TYPE, null, + FROM, PAGE_SIZE, null, methodName)).thenReturn(mockedRelationships); + + when(assetCatalogConverter.convertRelationships(mockedRelationships)). + thenReturn(convertRelationships(mockedRelationships)); } private OMRSMetadataCollection mockMetadataCollection() throws RepositoryErrorException { @@ -711,7 +571,7 @@ private List mockEntities() { return entityDetails; } - private void mockEntityDetails(String guid) throws InvalidParameterException, PropertyServerException, UserNotAuthorizedException { + private EntityDetail mockEntityDetails(String guid) throws InvalidParameterException, PropertyServerException, UserNotAuthorizedException { EntityDetail entityDetail = mock(EntityDetail.class); when(commonHandler .getEntityByGUID(USER, guid, ASSET_TYPE)) @@ -721,6 +581,7 @@ private void mockEntityDetails(String guid) throws InvalidParameterException, Pr when(entityDetail.getType()).thenReturn(mockType(ASSET_TYPE, ASSET_TYPE_GUID)); when(entityDetail.getClassifications()).thenReturn(mockClassifications()); when(entityDetail.getProperties()).thenReturn(mockProperties()); + return entityDetail; } private InstanceProperties mockProperties() { @@ -746,6 +607,19 @@ private Relationship mockRelationship() { return relationship; } + private List convertRelationships( + List relationships) { + List result = new ArrayList<>(); + for (Relationship relationship : relationships) { + org.odpi.openmetadata.accessservices.assetcatalog.model.Relationship convertedRelationship = + new org.odpi.openmetadata.accessservices.assetcatalog.model.Relationship(); + convertedRelationship.setGuid(relationship.getGUID()); + convertedRelationship.setType(convertInstanceType(relationship.getType())); + result.add(convertedRelationship); + } + return result; + } + private InstanceType mockInstanceType(String typeName, String typeGUID) { InstanceType instanceType = new InstanceType(); instanceType.setTypeDefName(typeName); @@ -775,17 +649,4 @@ private void mockSearchString(String searchCriteria, boolean isCaseSensitive) { when(repositoryHelper.getContainsRegex(searchCriteria, isCaseSensitive)).thenReturn(searchCriteria); } - private InstanceProperties mockMatchProperties() { - InstanceProperties matchProperties = new InstanceProperties(); - PrimitivePropertyValue primitivePropertyValue = new PrimitivePropertyValue(); - - primitivePropertyValue.setPrimitiveDefCategory(PrimitiveDefCategory.OM_PRIMITIVE_TYPE_STRING); - primitivePropertyValue.setPrimitiveValue(SEARCH_CRITERIA); - primitivePropertyValue.setTypeName(PrimitiveDefCategory.OM_PRIMITIVE_TYPE_STRING.getName()); - primitivePropertyValue.setTypeGUID(PrimitiveDefCategory.OM_PRIMITIVE_TYPE_STRING.getGUID()); - - matchProperties.setProperty(NAME, primitivePropertyValue); - return matchProperties; - } - } diff --git a/open-metadata-implementation/access-services/asset-catalog/asset-catalog-server/src/test/java/org/odpi/openmetadata/accessservices/assetcatalog/handlers/RelationshipHandlerTest.java b/open-metadata-implementation/access-services/asset-catalog/asset-catalog-server/src/test/java/org/odpi/openmetadata/accessservices/assetcatalog/handlers/RelationshipHandlerTest.java index f6b485e1d48..ea9f60193f6 100644 --- a/open-metadata-implementation/access-services/asset-catalog/asset-catalog-server/src/test/java/org/odpi/openmetadata/accessservices/assetcatalog/handlers/RelationshipHandlerTest.java +++ b/open-metadata-implementation/access-services/asset-catalog/asset-catalog-server/src/test/java/org/odpi/openmetadata/accessservices/assetcatalog/handlers/RelationshipHandlerTest.java @@ -8,14 +8,15 @@ import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.odpi.openmetadata.accessservices.assetcatalog.exception.AssetCatalogErrorCode; +import org.odpi.openmetadata.accessservices.assetcatalog.model.AssetCatalogBean; +import org.odpi.openmetadata.accessservices.assetcatalog.util.Constants; import org.odpi.openmetadata.commonservices.ffdc.InvalidParameterHandler; +import org.odpi.openmetadata.commonservices.generichandlers.AssetHandler; import org.odpi.openmetadata.commonservices.repositoryhandler.RepositoryHandler; import org.odpi.openmetadata.frameworks.connectors.ffdc.InvalidParameterException; import org.odpi.openmetadata.frameworks.connectors.ffdc.PropertyServerException; import org.odpi.openmetadata.frameworks.connectors.ffdc.UserNotAuthorizedException; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.OMRSMetadataCollection; -import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.EntityDetail; -import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.InstanceType; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.Relationship; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.typedefs.TypeDef; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.repositoryconnector.OMRSRepositoryHelper; @@ -37,10 +38,9 @@ public class RelationshipHandlerTest { private static final String FIRST_GUID = "ababa-123-acbd"; private static final String SECOND_GUID = "ababc-2134-2341f"; private static final String RELATIONSHIP_TYPE_GUID = "adadad-bcba-123"; + public static final String SERVER_NAME = "server-name"; private final String USER = "test-user"; - private final String SERVER = "test-server"; private final String RELATIONSHIP_TYPE = "SemanticAssigment"; - private final String DATABASE_TYPE = "Database"; @Mock private RepositoryHandler repositoryHandler; @@ -48,10 +48,10 @@ public class RelationshipHandlerTest { private OMRSRepositoryHelper repositoryHelper; @Mock - private InvalidParameterHandler invalidParameterHandler; + private AssetHandler assetHandler; @Mock - private CommonHandler commonHandler; + private InvalidParameterHandler invalidParameterHandler; @InjectMocks private RelationshipHandler relationshipHandler; @@ -69,28 +69,15 @@ public void getRelationshipBetweenEntities() Relationship mock = mockRelationship(); mockTypeDef(RELATIONSHIP_TYPE, RELATIONSHIP_TYPE_GUID); mockMetadataCollection(); - InstanceType type = mockType(DATABASE_TYPE); - EntityDetail entity1Mock = mockEntity1Detail(type); - - when(repositoryHandler.getRelationshipBetweenEntities(USER, - FIRST_GUID, - DATABASE_TYPE, - SECOND_GUID, - RELATIONSHIP_TYPE_GUID, - RELATIONSHIP_TYPE, - methodName)).thenReturn(mock); - when(commonHandler.getTypeDefGUID(USER, RELATIONSHIP_TYPE)).thenReturn(RELATIONSHIP_TYPE_GUID); - when(commonHandler.getEntityByGUID(USER, FIRST_GUID, null)).thenReturn(entity1Mock); + when(assetHandler.getUniqueAttachmentLink(USER, FIRST_GUID, + Constants.GUID_PARAMETER, "", RELATIONSHIP_TYPE_GUID, RELATIONSHIP_TYPE, SECOND_GUID, + "", null, methodName)).thenReturn(mock); org.odpi.openmetadata.accessservices.assetcatalog.model.Relationship - result = relationshipHandler.getRelationshipBetweenEntities(USER, - SERVER, - FIRST_GUID, - SECOND_GUID, + result = relationshipHandler.getRelationshipBetweenEntities(USER, SERVER_NAME, FIRST_GUID, SECOND_GUID, RELATIONSHIP_TYPE); - assertNotNull(result); assertEquals(mock.getGUID(), result.getGuid()); verify(invalidParameterHandler, times(1)).validateUserId(USER, methodName); @@ -104,27 +91,14 @@ public void getRelationshipBetweenEntities_throwsUserNotAuthorizedException() String methodName = "getRelationshipBetweenEntities"; mockTypeDef(RELATIONSHIP_TYPE, RELATIONSHIP_TYPE_GUID); mockMetadataCollection(); - InstanceType type = mockType(DATABASE_TYPE); - EntityDetail entity1Mock = mockEntity1Detail(type); - - when(commonHandler.getTypeDefGUID(USER, RELATIONSHIP_TYPE)).thenReturn(RELATIONSHIP_TYPE_GUID); - when(commonHandler.getEntityByGUID(USER, FIRST_GUID, null)).thenReturn(entity1Mock); UserNotAuthorizedException mockedException = new UserNotAuthorizedException(AssetCatalogErrorCode.SERVICE_NOT_INITIALIZED.getMessageDefinition(), this.getClass().getName(), "", ""); - doThrow(mockedException).when(repositoryHandler).getRelationshipBetweenEntities(USER, - FIRST_GUID, - DATABASE_TYPE, - SECOND_GUID, - RELATIONSHIP_TYPE_GUID, - RELATIONSHIP_TYPE, - methodName); + doThrow(mockedException).when(assetHandler).getUniqueAttachmentLink(USER, FIRST_GUID, + Constants.GUID_PARAMETER, "", RELATIONSHIP_TYPE_GUID, RELATIONSHIP_TYPE, SECOND_GUID, + "", null, methodName); assertThrows(UserNotAuthorizedException.class, () -> - relationshipHandler.getRelationshipBetweenEntities(USER, - SERVER, - FIRST_GUID, - SECOND_GUID, - RELATIONSHIP_TYPE)); + relationshipHandler.getRelationshipBetweenEntities(USER, SERVER_NAME, FIRST_GUID, SECOND_GUID, RELATIONSHIP_TYPE)); } @@ -140,11 +114,7 @@ public void getRelationshipBetweenEntities_throwsInvalidParameterException() thr doThrow(mockedException).when(invalidParameterHandler).validateGUID(FIRST_GUID, "entity1GUID", methodName); assertThrows(InvalidParameterException.class, () -> - relationshipHandler.getRelationshipBetweenEntities(USER, - SERVER, - FIRST_GUID, - SECOND_GUID, - RELATIONSHIP_TYPE)); + relationshipHandler.getRelationshipBetweenEntities(USER, SERVER_NAME, FIRST_GUID, SECOND_GUID, RELATIONSHIP_TYPE)); } @@ -162,26 +132,13 @@ private Relationship mockRelationship() { return relationship; } - private OMRSMetadataCollection mockMetadataCollection() throws RepositoryErrorException { + private void mockMetadataCollection() throws RepositoryErrorException { OMRSMetadataCollection metadataCollection = mock(OMRSMetadataCollection.class); when(repositoryHandler.getMetadataCollection()).thenReturn(metadataCollection); when(metadataCollection.getMetadataCollectionId(USER)).thenReturn("metadataCollectionID"); when(repositoryHelper.getMetadataCollectionName("metadataCollectionID")).thenReturn("metadataCollectionName"); - return metadataCollection; - } - - private EntityDetail mockEntity1Detail(InstanceType mockType) { - EntityDetail entityDetail = mock(EntityDetail.class); - when(entityDetail.getType()).thenReturn(mockType); - return entityDetail; - } - - private InstanceType mockType(String typeName) { - InstanceType type = mock(InstanceType.class); - when(type.getTypeDefName()).thenReturn(typeName); - return type; } } diff --git a/open-metadata-implementation/access-services/asset-catalog/asset-catalog-server/src/test/java/org/odpi/openmetadata/accessservices/assetcatalog/service/AssetCatalogServiceTest.java b/open-metadata-implementation/access-services/asset-catalog/asset-catalog-server/src/test/java/org/odpi/openmetadata/accessservices/assetcatalog/service/AssetCatalogServiceTest.java index b22c4a696ac..decc800a694 100644 --- a/open-metadata-implementation/access-services/asset-catalog/asset-catalog-server/src/test/java/org/odpi/openmetadata/accessservices/assetcatalog/service/AssetCatalogServiceTest.java +++ b/open-metadata-implementation/access-services/asset-catalog/asset-catalog-server/src/test/java/org/odpi/openmetadata/accessservices/assetcatalog/service/AssetCatalogServiceTest.java @@ -8,13 +8,15 @@ import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.odpi.openmetadata.accessservices.assetcatalog.admin.AssetCatalogInstanceHandler; -import org.odpi.openmetadata.accessservices.assetcatalog.exception.AssetCatalogException; import org.odpi.openmetadata.accessservices.assetcatalog.handlers.AssetCatalogHandler; import org.odpi.openmetadata.accessservices.assetcatalog.handlers.CommonHandler; -import org.odpi.openmetadata.accessservices.assetcatalog.model.*; import org.odpi.openmetadata.accessservices.assetcatalog.model.AssetCatalogBean; +import org.odpi.openmetadata.accessservices.assetcatalog.model.Classification; +import org.odpi.openmetadata.accessservices.assetcatalog.model.Element; +import org.odpi.openmetadata.accessservices.assetcatalog.model.Elements; +import org.odpi.openmetadata.accessservices.assetcatalog.model.Relationship; +import org.odpi.openmetadata.accessservices.assetcatalog.model.Type; import org.odpi.openmetadata.accessservices.assetcatalog.model.rest.body.SearchParameters; -import org.odpi.openmetadata.accessservices.assetcatalog.model.rest.responses.AssetCatalogListResponse; import org.odpi.openmetadata.accessservices.assetcatalog.model.rest.responses.AssetCatalogResponse; import org.odpi.openmetadata.accessservices.assetcatalog.model.rest.responses.AssetListResponse; import org.odpi.openmetadata.accessservices.assetcatalog.model.rest.responses.AssetResponse; @@ -182,74 +184,6 @@ public void testGetClassificationByAssetGUID() throws InvalidParameterException, assertEquals(response.get(0).getName(), classificationByAssetGUID.getClassifications().get(0).getName()); } - @Test - public void testGetIntermediateAssets() throws InvalidParameterException, PropertyServerException, UserNotAuthorizedException, AssetCatalogException { - List response = new ArrayList<>(); - response.add(mockAssetDescription(FIRST_GUID)); - - when(instanceHandler.getAssetCatalogHandler(USER, - SERVER_NAME, - "getLinkingAssets")) - .thenReturn(assetCatalogHandler); - - when(assetCatalogHandler - .getIntermediateAssets(USER, FIRST_GUID, SECOND_GUID, SERVER_NAME)) - .thenReturn(response); - - AssetCatalogListResponse assetCatalogListResponse = assetCatalogRESTService.getLinkingAssets(SERVER_NAME, - USER, - FIRST_GUID, - SECOND_GUID); - - assertEquals(response.get(0).getGuid(), assetCatalogListResponse.getAssetCatalogBeanList().get(0).getGuid()); - } - - @Test - public void testGetLinkingRelationships() throws InvalidParameterException, PropertyServerException, UserNotAuthorizedException, AssetCatalogException { - List response = new ArrayList<>(); - response.add(mockRelationshipResponse()); - - when(instanceHandler.getAssetCatalogHandler(USER, - SERVER_NAME, - "getLinkingRelationships")) - .thenReturn(assetCatalogHandler); - - when(assetCatalogHandler - .getLinkingRelationshipsBetweenAssets(SERVER_NAME, USER, FIRST_GUID, SECOND_GUID)) - .thenReturn(response); - - RelationshipListResponse linkingRelationships = assetCatalogRESTService.getLinkingRelationships(SERVER_NAME, - USER, - FIRST_GUID, - SECOND_GUID); - - assertEquals(response.get(0).getGuid(), linkingRelationships.getRelationships().get(0).getGuid()); - } - - @Test - public void testGetAssetsFromNeighborhood() - throws InvalidParameterException, PropertyServerException, UserNotAuthorizedException, AssetCatalogException { - SearchParameters searchParameters = mockSearchParams(); - List response = new ArrayList<>(); - response.add(mockAssetDescription(FIRST_GUID)); - - when(instanceHandler.getAssetCatalogHandler(USER, - SERVER_NAME, - "getAssetsFromNeighborhood")) - .thenReturn(assetCatalogHandler); - - when(assetCatalogHandler - .getEntitiesFromNeighborhood(USER, FIRST_GUID, searchParameters, SERVER_NAME)) - .thenReturn(response); - - AssetCatalogListResponse assetsFromNeighborhood = assetCatalogRESTService.getAssetsFromNeighborhood(SERVER_NAME, - USER, - FIRST_GUID, - searchParameters); - - assertEquals(response.get(0).getGuid(), assetsFromNeighborhood.getAssetCatalogBeanList().get(0).getGuid()); - } - @Test public void testSearchByType() throws org.odpi.openmetadata.frameworks.connectors.ffdc.OCFCheckedExceptionBase { diff --git a/open-metadata-implementation/access-services/asset-catalog/asset-catalog-spring/src/main/java/org/odpi/openmetadata/accessservices/assetcatalog/server/spring/AssetCatalogEntityResource.java b/open-metadata-implementation/access-services/asset-catalog/asset-catalog-spring/src/main/java/org/odpi/openmetadata/accessservices/assetcatalog/server/spring/AssetCatalogEntityResource.java index 6d2960ce864..0a6b7f5447b 100644 --- a/open-metadata-implementation/access-services/asset-catalog/asset-catalog-spring/src/main/java/org/odpi/openmetadata/accessservices/assetcatalog/server/spring/AssetCatalogEntityResource.java +++ b/open-metadata-implementation/access-services/asset-catalog/asset-catalog-spring/src/main/java/org/odpi/openmetadata/accessservices/assetcatalog/server/spring/AssetCatalogEntityResource.java @@ -119,60 +119,6 @@ public ClassificationListResponse getClassificationsForAsset(@PathVariable("serv return assetService.getClassificationByAssetGUID(serverName, userId, assetGUID, assetType, classificationName); } - /** - * Returns a sub-graph of intermediate assets that connected two assets - * - * @param serverName unique identifier for requested server. - * @param userId the unique identifier for the user - * @param startAssetGUID the starting asset identifier of the query - * @param endAssetGUID the ending asset identifier of the query - * @return a list of assets between the given assets - */ - @GetMapping(path = "/linking-assets/from/{assetGUID}/to/{endAssetGUID}", - produces = MediaType.APPLICATION_JSON_VALUE) - public AssetCatalogListResponse getLinkingAssets(@PathVariable("serverName") String serverName, - @PathVariable("userId") String userId, - @PathVariable("assetGUID") @NotBlank String startAssetGUID, - @PathVariable("endAssetGUID") @NotBlank String endAssetGUID) { - return assetService.getLinkingAssets(serverName, userId, startAssetGUID, endAssetGUID); - } - - /** - * Return a sub-graph of relationships that connect two assets - * - * @param serverName unique identifier for requested server. - * @param userId the unique identifier for the user - * @param startAssetGUID the starting asset identifier of the query - * @param endAssetGUID the ending asset identifier of the query - * @return a list of relationships that connects the assets - */ - @GetMapping(path = "/linking-assets-relationships/from/{assetGUID}/to/{endAssetGUID}", - produces = MediaType.APPLICATION_JSON_VALUE) - public RelationshipListResponse getLinkingRelationships(@PathVariable("serverName") String serverName, - @PathVariable("userId") String userId, - @PathVariable("assetGUID") String startAssetGUID, - @PathVariable("endAssetGUID") String endAssetGUID) { - return assetService.getLinkingRelationships(serverName, userId, startAssetGUID, endAssetGUID); - } - - /** - * Returns the sub-graph that represents the returned linked relationships. - * - * @param serverName unique identifier for requested server. - * @param userId the unique identifier for the user - * @param assetGUID the starting asset identifier of the query - * @param searchParameters constrains to make the assets's search results more precise - * @return a list of assets that in neighborhood of the given asset - */ - @PostMapping(path = "/assets-from-neighborhood/{assetGUID}", - produces = MediaType.APPLICATION_JSON_VALUE) - public AssetCatalogListResponse getAssetsFromNeighborhood(@PathVariable("serverName") String serverName, - @PathVariable("userId") String userId, - @PathVariable("assetGUID") @NotBlank String assetGUID, - @RequestBody SearchParameters searchParameters) { - return assetService.getAssetsFromNeighborhood(serverName, userId, assetGUID, searchParameters); - } - /** * Return a list of assets matching the search criteria without the full context * @@ -190,7 +136,6 @@ public AssetListResponse searchByType(@PathVariable("serverName") String serverN return assetService.searchByType(serverName, userId, searchCriteria, searchParameters); } - /** * Return the full context of an asset/glossary term based on its identifier. * The response contains the list of the connections assigned to the asset. diff --git a/open-metadata-implementation/access-services/asset-catalog/asset-catalog-spring/src/test/java/org/odpi/openmetadata/accessservices/assetcatalog/server/spring/AssetCatalogEntityResourceTest.java b/open-metadata-implementation/access-services/asset-catalog/asset-catalog-spring/src/test/java/org/odpi/openmetadata/accessservices/assetcatalog/server/spring/AssetCatalogEntityResourceTest.java index 577291047a1..bb7e1156339 100644 --- a/open-metadata-implementation/access-services/asset-catalog/asset-catalog-spring/src/test/java/org/odpi/openmetadata/accessservices/assetcatalog/server/spring/AssetCatalogEntityResourceTest.java +++ b/open-metadata-implementation/access-services/asset-catalog/asset-catalog-spring/src/test/java/org/odpi/openmetadata/accessservices/assetcatalog/server/spring/AssetCatalogEntityResourceTest.java @@ -23,7 +23,6 @@ class AssetCatalogEntityResourceTest { private static final String USER = "user"; private static final String SERVER_NAME = "serverName"; private static final String ASSET_GUID = "b1c497ce.60641b50.0v9mgsb1m.9vbkmkr"; - private static final String SECOND_ASSET_GUID = "b1c497ce.60641b50.0v9mgsb1m.ab12343"; private static final String ASSET_TYPE = "GlossaryTerm"; private static final String SEMANTIC_ASSIGMENT = "SemanticAssigment"; private static final Integer FROM = 0; @@ -64,28 +63,6 @@ void testGetClassificationsForAsset() { verify(assetCatalogService, times(1)).getClassificationByAssetGUID(SERVER_NAME, USER, ASSET_GUID, ASSET_TYPE, CONFIDENTIALITY); } - @Test - void testGetAssetsFromNeighborhood() { - SearchParameters searchParameters = mockSearchParameters(); - assetCatalogEntityResource.getAssetsFromNeighborhood(SERVER_NAME, USER, ASSET_GUID, searchParameters); - - verify(assetCatalogService, times(1)).getAssetsFromNeighborhood(SERVER_NAME, USER, ASSET_GUID, searchParameters); - } - - @Test - void testGetLinkingAssets() { - assetCatalogEntityResource.getLinkingAssets(SERVER_NAME, USER, ASSET_GUID, SECOND_ASSET_GUID); - - verify(assetCatalogService, times(1)).getLinkingAssets(SERVER_NAME, USER, ASSET_GUID, SECOND_ASSET_GUID); - } - - @Test - void testGetLinkingRelationships() { - assetCatalogEntityResource.getLinkingRelationships(SERVER_NAME, USER, ASSET_GUID, SECOND_ASSET_GUID); - - verify(assetCatalogService, times(1)).getLinkingRelationships(SERVER_NAME, USER, ASSET_GUID, SECOND_ASSET_GUID); - } - @Test void testSearchAssetsAndGlossaryTerms() { SearchParameters searchParameters = mockSearchParameters(); diff --git a/open-metadata-implementation/access-services/asset-catalog/docs/samples/collections/Asset-Catalog-endpoints.postman_collection.json b/open-metadata-implementation/access-services/asset-catalog/docs/samples/collections/Asset-Catalog-endpoints.postman_collection.json new file mode 100644 index 00000000000..8d5e458bddc --- /dev/null +++ b/open-metadata-implementation/access-services/asset-catalog/docs/samples/collections/Asset-Catalog-endpoints.postman_collection.json @@ -0,0 +1,290 @@ +{ + "info": { + "_postman_id": "bc085e19-5492-4446-b323-6ce7c7a0642f", + "name": "Asset Catalog endpoints", + "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" + }, + "item": [ + { + "name": "1. Get supported types", + "request": { + "method": "GET", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "url": { + "raw": "{{base-url}}/servers/{{server-id}}/open-metadata/access-services/asset-catalog/users/{{user-id}}/supportedTypes?type={{asset-type}}", + "host": [ + "{{base-url}}" + ], + "path": [ + "servers", + "{{server-id}}", + "open-metadata", + "access-services", + "asset-catalog", + "users", + "{{user-id}}", + "supportedTypes" + ], + "query": [ + { + "key": "type", + "value": "{{asset-type}}" + } + ] + } + }, + "response": [] + }, + { + "name": "2. Search", + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "value": "application/json", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"class\": \"SearchParameters\",\n\t\"status\": \"ACTIVE\",\n\t\"from\": 0,\n\t\"pageSize\":100,\n\t\"isCaseInsensitive\": false\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{base-url}}/servers/{{server-id}}/open-metadata/access-services/asset-catalog/users/{{user-id}}/search?searchCriteria={{search-criteria}}", + "host": [ + "{{base-url}}" + ], + "path": [ + "servers", + "{{server-id}}", + "open-metadata", + "access-services", + "asset-catalog", + "users", + "{{user-id}}", + "search" + ], + "query": [ + { + "key": "searchCriteria", + "value": "{{search-criteria}}" + } + ] + } + }, + "response": [] + }, + { + "name": "3. Get asset details", + "request": { + "method": "GET", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "url": { + "raw": "{{base-url}}/servers/{{server-id}}/open-metadata/access-services/asset-catalog/users/{{user-id}}/asset-details/{{asset-guid}}/?assetType={{asset-type}}", + "host": [ + "{{base-url}}" + ], + "path": [ + "servers", + "{{server-id}}", + "open-metadata", + "access-services", + "asset-catalog", + "users", + "{{user-id}}", + "asset-details", + "{{asset-guid}}", + "" + ], + "query": [ + { + "key": "assetType", + "value": "{{asset-type}}" + } + ] + } + }, + "response": [] + }, + { + "name": "4. Get asset classifications", + "request": { + "method": "GET", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "url": { + "raw": "{{base-url}}/servers/{{server-id}}/open-metadata/access-services/asset-catalog/users/{{user-id}}/asset-classifications/{{asset-guid}}?classificationName={{classification-name}}", + "host": [ + "{{base-url}}" + ], + "path": [ + "servers", + "{{server-id}}", + "open-metadata", + "access-services", + "asset-catalog", + "users", + "{{user-id}}", + "asset-classifications", + "{{asset-guid}}" + ], + "query": [ + { + "key": "from", + "value": "0", + "disabled": true + }, + { + "key": "pageSize", + "value": "10", + "disabled": true + }, + { + "key": "assetType", + "value": "{{asset-type-1}}", + "disabled": true + }, + { + "key": "classificationName", + "value": "{{classification-name}}" + } + ] + } + }, + "response": [] + }, + { + "name": "5. Get asset relationships", + "request": { + "method": "GET", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "url": { + "raw": "{{base-url}}/servers/{{server-id}}/open-metadata/access-services/asset-catalog/users/{{user-id}}/asset-relationships/{{asset-guid}}?assetType={{asset-type}}&relationshipType={{relationship-type}}", + "host": [ + "{{base-url}}" + ], + "path": [ + "servers", + "{{server-id}}", + "open-metadata", + "access-services", + "asset-catalog", + "users", + "{{user-id}}", + "asset-relationships", + "{{asset-guid}}" + ], + "query": [ + { + "key": "assetType", + "value": "{{asset-type}}" + }, + { + "key": "relationshipType", + "value": "{{relationship-type}}" + } + ] + } + }, + "response": [] + }, + { + "name": "6. Get asset context", + "request": { + "method": "GET", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "url": { + "raw": "{{base-url}}/servers/{{server-id}}/open-metadata/access-services/asset-catalog/users/{{user-id}}/asset-context/{{asset-guid}}", + "host": [ + "{{base-url}}" + ], + "path": [ + "servers", + "{{server-id}}", + "open-metadata", + "access-services", + "asset-catalog", + "users", + "{{user-id}}", + "asset-context", + "{{asset-guid}}" + ] + } + }, + "response": [] + }, + { + "name": "7. Get asset universe", + "request": { + "method": "GET", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "url": { + "raw": "{{base-url}}/servers/{{server-id}}/open-metadata/access-services/asset-catalog/users/{{user-id}}/asset-universe/{{asset-guid}}", + "host": [ + "{{base-url}}" + ], + "path": [ + "servers", + "{{server-id}}", + "open-metadata", + "access-services", + "asset-catalog", + "users", + "{{user-id}}", + "asset-universe", + "{{asset-guid}}" + ] + } + }, + "response": [] + } + ] +} \ No newline at end of file