From de5767e4c8ba56646dc021f65c6ffe75a73e463a Mon Sep 17 00:00:00 2001 From: Liviu Enache Date: Thu, 20 Apr 2023 09:57:51 +0300 Subject: [PATCH 1/4] Added getAnchorAssetForEntity endpoint/method in Asset Manager. Signed-off-by: Liviu Enache --- .../api/ConnectorFactoryInterface.java | 17 ++++++ .../client/ConnectedAssetClientBase.java | 61 +++++++++++++++++++ .../server/OCFMetadataRESTServices.java | 59 ++++++++++++++++++ .../server/spring/ConnectedAssetResource.java | 24 ++++++++ 4 files changed, 161 insertions(+) diff --git a/open-metadata-implementation/framework-services/ocf-metadata-management/ocf-metadata-api/src/main/java/org/odpi/openmetadata/frameworkservices/ocf/metadatamanagement/api/ConnectorFactoryInterface.java b/open-metadata-implementation/framework-services/ocf-metadata-management/ocf-metadata-api/src/main/java/org/odpi/openmetadata/frameworkservices/ocf/metadatamanagement/api/ConnectorFactoryInterface.java index 625258bf87e..4ef76f17c88 100644 --- a/open-metadata-implementation/framework-services/ocf-metadata-management/ocf-metadata-api/src/main/java/org/odpi/openmetadata/frameworkservices/ocf/metadatamanagement/api/ConnectorFactoryInterface.java +++ b/open-metadata-implementation/framework-services/ocf-metadata-management/ocf-metadata-api/src/main/java/org/odpi/openmetadata/frameworkservices/ocf/metadatamanagement/api/ConnectorFactoryInterface.java @@ -8,6 +8,7 @@ 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.frameworks.connectors.properties.beans.Asset; import org.odpi.openmetadata.frameworks.connectors.properties.beans.Connection; @@ -108,4 +109,20 @@ Connector getConnectorByConnection(String userId, ConnectionCheckedException, ConnectorCheckedException, PropertyServerException; + /** + * Returns the anchor asset of the supplied entity. + * + * @param userId userId of user making request. + * @param entityGUID unique identifier of the requested entity. + * + * @return anchor asset of the entity. + * + * @throws InvalidParameterException one of the parameters is null or invalid. + * @throws PropertyServerException there is a problem retrieving information from the property server(s). + * @throws UserNotAuthorizedException the requesting user is not authorized to issue this request. + */ + Asset getAnchorAssetForEntity(String userId, + String entityGUID) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException; } diff --git a/open-metadata-implementation/framework-services/ocf-metadata-management/ocf-metadata-client/src/main/java/org/odpi/openmetadata/frameworkservices/ocf/metadatamanagement/client/ConnectedAssetClientBase.java b/open-metadata-implementation/framework-services/ocf-metadata-management/ocf-metadata-client/src/main/java/org/odpi/openmetadata/frameworkservices/ocf/metadatamanagement/client/ConnectedAssetClientBase.java index 20f99402281..5abc56bd9cc 100644 --- a/open-metadata-implementation/framework-services/ocf-metadata-management/ocf-metadata-client/src/main/java/org/odpi/openmetadata/frameworkservices/ocf/metadatamanagement/client/ConnectedAssetClientBase.java +++ b/open-metadata-implementation/framework-services/ocf-metadata-management/ocf-metadata-client/src/main/java/org/odpi/openmetadata/frameworkservices/ocf/metadatamanagement/client/ConnectedAssetClientBase.java @@ -482,6 +482,40 @@ protected String getAssetForConnection(OCFRESTClient restClient, return restResult.getGUID(); } + /** + * Returns the anchor asset of the supplied entity. + * + * @param restClient initialized client for calling REST APIs. + * @param serviceName name of the calling service. + * @param userId the userId of the requesting user. + * @param entityGUID unique identifier for the entity. + * + * @return anchor asset of the entity. + * + * @throws InvalidParameterException one of the parameters is null or invalid. + * @throws PropertyServerException there is a problem retrieving information from the property server. + * @throws UserNotAuthorizedException the requesting user is not authorized to issue this request. + */ + protected Asset getAnchorAssetForEntity(OCFRESTClient restClient, + String serviceName, + String userId, + String entityGUID) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException + { + final String methodName = "getAnchorAssetForEntity"; + final String urlTemplate = "/servers/{0}/open-metadata/framework-services/{1}/connected-asset/users/{2}/assets/from-anchor/{3}"; + + AssetResponse restResult = restClient.callOCFAssetGetRESTCall(methodName, + serverPlatformURLRoot + urlTemplate, + serverName, + serviceName, + userId, + entityGUID); + + return restResult.getAsset(); + } + /* * =============================================== @@ -647,4 +681,31 @@ public Connector getConnectorByConnection(String userId, return this.getConnectorForConnection(ocfrestClient, serviceURLMarker, userId, connection, methodName); } + + /** + * Returns the anchor asset of the supplied entity. + * + * @param userId the userId of the requesting user. + * @param entityGUID unique identifier for the entity. + * + * @return anchor asset of the entity. + * + * @throws InvalidParameterException one of the parameters is null or invalid. + * @throws PropertyServerException there is a problem retrieving information from the property server. + * @throws UserNotAuthorizedException the requesting user is not authorized to issue this request. + */ + @Override + public Asset getAnchorAssetForEntity(String userId, + String entityGUID) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException + { + final String methodName = "getAnchorAssetForEntity"; + final String guidParameterName = "guid"; + + invalidParameterHandler.validateUserId(userId, methodName); + invalidParameterHandler.validateGUID(entityGUID, guidParameterName, methodName); + + return this.getAnchorAssetForEntity(ocfrestClient, serviceURLMarker, userId, entityGUID); + } } diff --git a/open-metadata-implementation/framework-services/ocf-metadata-management/ocf-metadata-server/src/main/java/org/odpi/openmetadata/frameworkservices/ocf/metadatamanagement/server/OCFMetadataRESTServices.java b/open-metadata-implementation/framework-services/ocf-metadata-management/ocf-metadata-server/src/main/java/org/odpi/openmetadata/frameworkservices/ocf/metadatamanagement/server/OCFMetadataRESTServices.java index 6fe6343b6a1..39c42be0b5f 100644 --- a/open-metadata-implementation/framework-services/ocf-metadata-management/ocf-metadata-server/src/main/java/org/odpi/openmetadata/frameworkservices/ocf/metadatamanagement/server/OCFMetadataRESTServices.java +++ b/open-metadata-implementation/framework-services/ocf-metadata-management/ocf-metadata-server/src/main/java/org/odpi/openmetadata/frameworkservices/ocf/metadatamanagement/server/OCFMetadataRESTServices.java @@ -1745,4 +1745,63 @@ else if (repositoryHelper.isTypeOf(serviceURLName, relationship.getType().getTyp return response; } + + /** + * Returns the anchor asset of the supplied entity. + * + * @param serverName String name of server instance to call. + * @param serviceURLName String name of the service that created the connector that issued this request. + * @param userId String userId of user making request. + * @param entityGUID String unique id for the entity. + * + * @return a bean with the basic properties about the anchor asset or + * InvalidParameterException - the userId is null or invalid or + * UnrecognizedAssetGUIDException - the GUID is null or invalid or + * PropertyServerException - there is a problem retrieving the asset properties from the property server or + * UserNotAuthorizedException - the requesting user is not authorized to issue this request. + */ + public AssetResponse getAnchorAssetForEntity(String serverName, + String serviceURLName, + String userId, + String entityGUID) + { + final String methodName = "getAnchorAssetForEntity"; + + RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); + + AssetResponse response = new AssetResponse(); + AuditLog auditLog = null; + + Date effectiveTime = new Date(); + + try { + auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); + + ReferenceableHandler referenceableHandler = instanceHandler.getReferenceableHandler(userId, serverName, methodName); + EntityDetail entity = referenceableHandler.getEntityFromRepository(userId, + entityGUID, + OpenMetadataAPIMapper.GUID_PROPERTY_NAME, + OpenMetadataAPIMapper.REFERENCEABLE_TYPE_NAME, + null, + null, + false, + false, + effectiveTime, + methodName); + + if (entity != null) + { + String anchorGUID = referenceableHandler.getAnchorGUIDFromAnchorsClassification(entity, methodName); + response = getAssetResponse(serverName, serviceURLName, userId, anchorGUID, null, methodName); + } + } + catch (Exception error) + { + restExceptionHandler.captureExceptions(response, error, methodName, auditLog); + } + + restCallLogger.logRESTCallReturn(token, response.toString()); + + return response; + } } diff --git a/open-metadata-implementation/framework-services/ocf-metadata-management/ocf-metadata-spring/src/main/java/org/odpi/openmetadata/frameworkservices/ocf/metadatamanagement/server/spring/ConnectedAssetResource.java b/open-metadata-implementation/framework-services/ocf-metadata-management/ocf-metadata-spring/src/main/java/org/odpi/openmetadata/frameworkservices/ocf/metadatamanagement/server/spring/ConnectedAssetResource.java index 2419522ff16..53bf218b2f4 100644 --- a/open-metadata-implementation/framework-services/ocf-metadata-management/ocf-metadata-spring/src/main/java/org/odpi/openmetadata/frameworkservices/ocf/metadatamanagement/server/spring/ConnectedAssetResource.java +++ b/open-metadata-implementation/framework-services/ocf-metadata-management/ocf-metadata-spring/src/main/java/org/odpi/openmetadata/frameworkservices/ocf/metadatamanagement/server/spring/ConnectedAssetResource.java @@ -163,6 +163,30 @@ public AssetResponse getConnectedAssetSummary(@PathVariable String serverName, } + /** + * Returns the anchor asset of an entity. + * + * @param serverName String name of server instance to call. + * @param serviceURLName String name of the service that created the connector that issued this request. + * @param userId String userId of user making request. + * @param entityGUID String unique id for the entity. + * @return a bean with the basic properties about the anchor asset or + * InvalidParameterException - the userId is null or invalid or + * UnrecognizedAssetGUIDException - the GUID is null or invalid or + * PropertyServerException - there is a problem retrieving the asset properties from the property server or + * UserNotAuthorizedException - the requesting user is not authorized to issue this request. + */ + @GetMapping(path = "/assets/from-anchor/{entityGUID}") + + public AssetResponse getAnchorAssetForEntity(@PathVariable String serverName, + @PathVariable String serviceURLName, + @PathVariable String userId, + @PathVariable String entityGUID) + { + return restAPI.getAnchorAssetForEntity(serverName, serviceURLName, userId, entityGUID); + } + + /** * Returns the basic information about the asset. * From 98b3646393fce47a9e80d255c5816df8bf8b82be Mon Sep 17 00:00:00 2001 From: Liviu Enache <44894046+LeeVi3w@users.noreply.github.com> Date: Thu, 20 Apr 2023 10:13:04 +0300 Subject: [PATCH 2/4] fixed bracket Signed-off-by: Liviu Enache --- .../ocf/metadatamanagement/server/OCFMetadataRESTServices.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/open-metadata-implementation/framework-services/ocf-metadata-management/ocf-metadata-server/src/main/java/org/odpi/openmetadata/frameworkservices/ocf/metadatamanagement/server/OCFMetadataRESTServices.java b/open-metadata-implementation/framework-services/ocf-metadata-management/ocf-metadata-server/src/main/java/org/odpi/openmetadata/frameworkservices/ocf/metadatamanagement/server/OCFMetadataRESTServices.java index 39c42be0b5f..69e2fb505c3 100644 --- a/open-metadata-implementation/framework-services/ocf-metadata-management/ocf-metadata-server/src/main/java/org/odpi/openmetadata/frameworkservices/ocf/metadatamanagement/server/OCFMetadataRESTServices.java +++ b/open-metadata-implementation/framework-services/ocf-metadata-management/ocf-metadata-server/src/main/java/org/odpi/openmetadata/frameworkservices/ocf/metadatamanagement/server/OCFMetadataRESTServices.java @@ -1774,7 +1774,8 @@ public AssetResponse getAnchorAssetForEntity(String serverName, Date effectiveTime = new Date(); - try { + try + { auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); ReferenceableHandler referenceableHandler = instanceHandler.getReferenceableHandler(userId, serverName, methodName); From bad8898688bf9f854c86c3d0eabd2dbe8dcad8db Mon Sep 17 00:00:00 2001 From: Liviu Enache Date: Thu, 20 Apr 2023 18:27:19 +0300 Subject: [PATCH 3/4] Changed method name and behaviour Signed-off-by: Liviu Enache --- .../api/ConnectorFactoryInterface.java | 17 ----- .../client/ConnectedAssetClientBase.java | 56 +++++----------- .../server/OCFMetadataRESTServices.java | 66 ++++++++++++++----- .../server/spring/ConnectedAssetResource.java | 10 +-- 4 files changed, 69 insertions(+), 80 deletions(-) diff --git a/open-metadata-implementation/framework-services/ocf-metadata-management/ocf-metadata-api/src/main/java/org/odpi/openmetadata/frameworkservices/ocf/metadatamanagement/api/ConnectorFactoryInterface.java b/open-metadata-implementation/framework-services/ocf-metadata-management/ocf-metadata-api/src/main/java/org/odpi/openmetadata/frameworkservices/ocf/metadatamanagement/api/ConnectorFactoryInterface.java index 4ef76f17c88..625258bf87e 100644 --- a/open-metadata-implementation/framework-services/ocf-metadata-management/ocf-metadata-api/src/main/java/org/odpi/openmetadata/frameworkservices/ocf/metadatamanagement/api/ConnectorFactoryInterface.java +++ b/open-metadata-implementation/framework-services/ocf-metadata-management/ocf-metadata-api/src/main/java/org/odpi/openmetadata/frameworkservices/ocf/metadatamanagement/api/ConnectorFactoryInterface.java @@ -8,7 +8,6 @@ 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.frameworks.connectors.properties.beans.Asset; import org.odpi.openmetadata.frameworks.connectors.properties.beans.Connection; @@ -109,20 +108,4 @@ Connector getConnectorByConnection(String userId, ConnectionCheckedException, ConnectorCheckedException, PropertyServerException; - /** - * Returns the anchor asset of the supplied entity. - * - * @param userId userId of user making request. - * @param entityGUID unique identifier of the requested entity. - * - * @return anchor asset of the entity. - * - * @throws InvalidParameterException one of the parameters is null or invalid. - * @throws PropertyServerException there is a problem retrieving information from the property server(s). - * @throws UserNotAuthorizedException the requesting user is not authorized to issue this request. - */ - Asset getAnchorAssetForEntity(String userId, - String entityGUID) throws InvalidParameterException, - PropertyServerException, - UserNotAuthorizedException; } diff --git a/open-metadata-implementation/framework-services/ocf-metadata-management/ocf-metadata-client/src/main/java/org/odpi/openmetadata/frameworkservices/ocf/metadatamanagement/client/ConnectedAssetClientBase.java b/open-metadata-implementation/framework-services/ocf-metadata-management/ocf-metadata-client/src/main/java/org/odpi/openmetadata/frameworkservices/ocf/metadatamanagement/client/ConnectedAssetClientBase.java index 5abc56bd9cc..4f64014ecb0 100644 --- a/open-metadata-implementation/framework-services/ocf-metadata-management/ocf-metadata-client/src/main/java/org/odpi/openmetadata/frameworkservices/ocf/metadatamanagement/client/ConnectedAssetClientBase.java +++ b/open-metadata-implementation/framework-services/ocf-metadata-management/ocf-metadata-client/src/main/java/org/odpi/openmetadata/frameworkservices/ocf/metadatamanagement/client/ConnectedAssetClientBase.java @@ -482,11 +482,10 @@ protected String getAssetForConnection(OCFRESTClient restClient, return restResult.getGUID(); } + /** * Returns the anchor asset of the supplied entity. * - * @param restClient initialized client for calling REST APIs. - * @param serviceName name of the calling service. * @param userId the userId of the requesting user. * @param entityGUID unique identifier for the entity. * @@ -496,22 +495,24 @@ protected String getAssetForConnection(OCFRESTClient restClient, * @throws PropertyServerException there is a problem retrieving information from the property server. * @throws UserNotAuthorizedException the requesting user is not authorized to issue this request. */ - protected Asset getAnchorAssetForEntity(OCFRESTClient restClient, - String serviceName, - String userId, - String entityGUID) throws InvalidParameterException, - PropertyServerException, - UserNotAuthorizedException + public Asset getAnchorAssetFromGUID(String userId, + String entityGUID) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException { - final String methodName = "getAnchorAssetForEntity"; + final String methodName = "getAnchorAssetFromGUID"; + final String guidParameterName = "guid"; final String urlTemplate = "/servers/{0}/open-metadata/framework-services/{1}/connected-asset/users/{2}/assets/from-anchor/{3}"; - AssetResponse restResult = restClient.callOCFAssetGetRESTCall(methodName, - serverPlatformURLRoot + urlTemplate, - serverName, - serviceName, - userId, - entityGUID); + invalidParameterHandler.validateUserId(userId, methodName); + invalidParameterHandler.validateGUID(entityGUID, guidParameterName, methodName); + + AssetResponse restResult = ocfrestClient.callOCFAssetGetRESTCall(methodName, + serverPlatformURLRoot + urlTemplate, + serverName, + serviceURLMarker, + userId, + entityGUID); return restResult.getAsset(); } @@ -682,30 +683,5 @@ public Connector getConnectorByConnection(String userId, return this.getConnectorForConnection(ocfrestClient, serviceURLMarker, userId, connection, methodName); } - /** - * Returns the anchor asset of the supplied entity. - * - * @param userId the userId of the requesting user. - * @param entityGUID unique identifier for the entity. - * - * @return anchor asset of the entity. - * - * @throws InvalidParameterException one of the parameters is null or invalid. - * @throws PropertyServerException there is a problem retrieving information from the property server. - * @throws UserNotAuthorizedException the requesting user is not authorized to issue this request. - */ - @Override - public Asset getAnchorAssetForEntity(String userId, - String entityGUID) throws InvalidParameterException, - PropertyServerException, - UserNotAuthorizedException - { - final String methodName = "getAnchorAssetForEntity"; - final String guidParameterName = "guid"; - invalidParameterHandler.validateUserId(userId, methodName); - invalidParameterHandler.validateGUID(entityGUID, guidParameterName, methodName); - - return this.getAnchorAssetForEntity(ocfrestClient, serviceURLMarker, userId, entityGUID); - } } diff --git a/open-metadata-implementation/framework-services/ocf-metadata-management/ocf-metadata-server/src/main/java/org/odpi/openmetadata/frameworkservices/ocf/metadatamanagement/server/OCFMetadataRESTServices.java b/open-metadata-implementation/framework-services/ocf-metadata-management/ocf-metadata-server/src/main/java/org/odpi/openmetadata/frameworkservices/ocf/metadatamanagement/server/OCFMetadataRESTServices.java index 69e2fb505c3..8b161f71a37 100644 --- a/open-metadata-implementation/framework-services/ocf-metadata-management/ocf-metadata-server/src/main/java/org/odpi/openmetadata/frameworkservices/ocf/metadatamanagement/server/OCFMetadataRESTServices.java +++ b/open-metadata-implementation/framework-services/ocf-metadata-management/ocf-metadata-server/src/main/java/org/odpi/openmetadata/frameworkservices/ocf/metadatamanagement/server/OCFMetadataRESTServices.java @@ -7,6 +7,7 @@ import org.odpi.openmetadata.commonservices.ffdc.RESTExceptionHandler; import org.odpi.openmetadata.commonservices.ffdc.rest.GUIDResponse; import org.odpi.openmetadata.commonservices.generichandlers.*; +import org.odpi.openmetadata.commonservices.repositoryhandler.RepositoryHandler; import org.odpi.openmetadata.frameworkservices.ocf.metadatamanagement.rest.*; import org.odpi.openmetadata.frameworks.auditlog.AuditLog; import org.odpi.openmetadata.frameworks.connectors.properties.beans.*; @@ -1760,12 +1761,12 @@ else if (repositoryHelper.isTypeOf(serviceURLName, relationship.getType().getTyp * PropertyServerException - there is a problem retrieving the asset properties from the property server or * UserNotAuthorizedException - the requesting user is not authorized to issue this request. */ - public AssetResponse getAnchorAssetForEntity(String serverName, - String serviceURLName, - String userId, - String entityGUID) + public AssetResponse getAnchorAssetFromGUID(String serverName, + String serviceURLName, + String userId, + String entityGUID) { - final String methodName = "getAnchorAssetForEntity"; + final String methodName = "getAnchorAssetFromGUID"; RESTCallToken token = restCallLogger.logRESTCall(serverName, userId, methodName); @@ -1776,24 +1777,53 @@ public AssetResponse getAnchorAssetForEntity(String serverName, try { + ReferenceableHandler referenceableHandler = instanceHandler.getReferenceableHandler(userId, serverName, methodName); + RepositoryHandler repositoryHandler = instanceHandler.getRepositoryHandler(userId, serverName, methodName); auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); - ReferenceableHandler referenceableHandler = instanceHandler.getReferenceableHandler(userId, serverName, methodName); - EntityDetail entity = referenceableHandler.getEntityFromRepository(userId, - entityGUID, - OpenMetadataAPIMapper.GUID_PROPERTY_NAME, - OpenMetadataAPIMapper.REFERENCEABLE_TYPE_NAME, - null, - null, - false, - false, - effectiveTime, - methodName); + EntityDetail entity = repositoryHandler.getEntityByGUID(userId, + entityGUID, + OpenMetadataAPIMapper.GUID_PROPERTY_NAME, + OpenMetadataAPIMapper.REFERENCEABLE_TYPE_NAME, + false, + false, + effectiveTime, + methodName); if (entity != null) { - String anchorGUID = referenceableHandler.getAnchorGUIDFromAnchorsClassification(entity, methodName); - response = getAssetResponse(serverName, serviceURLName, userId, anchorGUID, null, methodName); + if (repositoryHandler.isEntityATypeOf(userId, + entityGUID, + OpenMetadataAPIMapper.GUID_PROPERTY_NAME, + OpenMetadataAPIMapper.ASSET_TYPE_NAME, + effectiveTime, + methodName)) + { + response = getAssetResponse(serverName, serviceURLName, userId, entityGUID, null, methodName); + } + else + { + EntityDetail anchorEntity = referenceableHandler.validateAnchorEntity(userId, + entityGUID, + OpenMetadataAPIMapper.REFERENCEABLE_TYPE_NAME, + entity, + OpenMetadataAPIMapper.GUID_PROPERTY_NAME, + false, + false, + false, + null, + effectiveTime, + methodName); + if (repositoryHandler.isEntityATypeOf(userId, + anchorEntity.getGUID(), + OpenMetadataAPIMapper.GUID_PROPERTY_NAME, + OpenMetadataAPIMapper.ASSET_TYPE_NAME, + effectiveTime, + methodName)) + { + response = getAssetResponse(serverName, serviceURLName, userId, anchorEntity.getGUID(), null, methodName); + } + } } } catch (Exception error) diff --git a/open-metadata-implementation/framework-services/ocf-metadata-management/ocf-metadata-spring/src/main/java/org/odpi/openmetadata/frameworkservices/ocf/metadatamanagement/server/spring/ConnectedAssetResource.java b/open-metadata-implementation/framework-services/ocf-metadata-management/ocf-metadata-spring/src/main/java/org/odpi/openmetadata/frameworkservices/ocf/metadatamanagement/server/spring/ConnectedAssetResource.java index 53bf218b2f4..6182c86c06e 100644 --- a/open-metadata-implementation/framework-services/ocf-metadata-management/ocf-metadata-spring/src/main/java/org/odpi/openmetadata/frameworkservices/ocf/metadatamanagement/server/spring/ConnectedAssetResource.java +++ b/open-metadata-implementation/framework-services/ocf-metadata-management/ocf-metadata-spring/src/main/java/org/odpi/openmetadata/frameworkservices/ocf/metadatamanagement/server/spring/ConnectedAssetResource.java @@ -178,12 +178,12 @@ public AssetResponse getConnectedAssetSummary(@PathVariable String serverName, */ @GetMapping(path = "/assets/from-anchor/{entityGUID}") - public AssetResponse getAnchorAssetForEntity(@PathVariable String serverName, - @PathVariable String serviceURLName, - @PathVariable String userId, - @PathVariable String entityGUID) + public AssetResponse getAnchorAssetFromGUID(@PathVariable String serverName, + @PathVariable String serviceURLName, + @PathVariable String userId, + @PathVariable String entityGUID) { - return restAPI.getAnchorAssetForEntity(serverName, serviceURLName, userId, entityGUID); + return restAPI.getAnchorAssetFromGUID(serverName, serviceURLName, userId, entityGUID); } From 3014892fc4921a1a5c834b78974de0e4deb3812a Mon Sep 17 00:00:00 2001 From: Liviu Enache Date: Thu, 27 Apr 2023 10:29:33 +0300 Subject: [PATCH 4/4] Javadoc and parameter name changes Signed-off-by: Liviu Enache --- .../client/ConnectedAssetClientBase.java | 16 ++++++------ .../server/OCFMetadataRESTServices.java | 26 +++++++++---------- .../server/spring/ConnectedAssetResource.java | 10 +++---- 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/open-metadata-implementation/framework-services/ocf-metadata-management/ocf-metadata-client/src/main/java/org/odpi/openmetadata/frameworkservices/ocf/metadatamanagement/client/ConnectedAssetClientBase.java b/open-metadata-implementation/framework-services/ocf-metadata-management/ocf-metadata-client/src/main/java/org/odpi/openmetadata/frameworkservices/ocf/metadatamanagement/client/ConnectedAssetClientBase.java index 4f64014ecb0..336687708ee 100644 --- a/open-metadata-implementation/framework-services/ocf-metadata-management/ocf-metadata-client/src/main/java/org/odpi/openmetadata/frameworkservices/ocf/metadatamanagement/client/ConnectedAssetClientBase.java +++ b/open-metadata-implementation/framework-services/ocf-metadata-management/ocf-metadata-client/src/main/java/org/odpi/openmetadata/frameworkservices/ocf/metadatamanagement/client/ConnectedAssetClientBase.java @@ -484,35 +484,35 @@ protected String getAssetForConnection(OCFRESTClient restClient, /** - * Returns the anchor asset of the supplied entity. + * Returns the anchor asset. * * @param userId the userId of the requesting user. - * @param entityGUID unique identifier for the entity. + * @param guid unique identifier for the metadata element. * - * @return anchor asset of the entity. + * @return the anchor asset. * * @throws InvalidParameterException one of the parameters is null or invalid. * @throws PropertyServerException there is a problem retrieving information from the property server. * @throws UserNotAuthorizedException the requesting user is not authorized to issue this request. */ public Asset getAnchorAssetFromGUID(String userId, - String entityGUID) throws InvalidParameterException, - PropertyServerException, - UserNotAuthorizedException + String guid) throws InvalidParameterException, + PropertyServerException, + UserNotAuthorizedException { final String methodName = "getAnchorAssetFromGUID"; final String guidParameterName = "guid"; final String urlTemplate = "/servers/{0}/open-metadata/framework-services/{1}/connected-asset/users/{2}/assets/from-anchor/{3}"; invalidParameterHandler.validateUserId(userId, methodName); - invalidParameterHandler.validateGUID(entityGUID, guidParameterName, methodName); + invalidParameterHandler.validateGUID(guid, guidParameterName, methodName); AssetResponse restResult = ocfrestClient.callOCFAssetGetRESTCall(methodName, serverPlatformURLRoot + urlTemplate, serverName, serviceURLMarker, userId, - entityGUID); + guid); return restResult.getAsset(); } diff --git a/open-metadata-implementation/framework-services/ocf-metadata-management/ocf-metadata-server/src/main/java/org/odpi/openmetadata/frameworkservices/ocf/metadatamanagement/server/OCFMetadataRESTServices.java b/open-metadata-implementation/framework-services/ocf-metadata-management/ocf-metadata-server/src/main/java/org/odpi/openmetadata/frameworkservices/ocf/metadatamanagement/server/OCFMetadataRESTServices.java index 8b161f71a37..fc8bc43ee91 100644 --- a/open-metadata-implementation/framework-services/ocf-metadata-management/ocf-metadata-server/src/main/java/org/odpi/openmetadata/frameworkservices/ocf/metadatamanagement/server/OCFMetadataRESTServices.java +++ b/open-metadata-implementation/framework-services/ocf-metadata-management/ocf-metadata-server/src/main/java/org/odpi/openmetadata/frameworkservices/ocf/metadatamanagement/server/OCFMetadataRESTServices.java @@ -1748,12 +1748,12 @@ else if (repositoryHelper.isTypeOf(serviceURLName, relationship.getType().getTyp } /** - * Returns the anchor asset of the supplied entity. + * Returns the anchor asset. * * @param serverName String name of server instance to call. * @param serviceURLName String name of the service that created the connector that issued this request. * @param userId String userId of user making request. - * @param entityGUID String unique id for the entity. + * @param guid String unique id for the metadata element. * * @return a bean with the basic properties about the anchor asset or * InvalidParameterException - the userId is null or invalid or @@ -1764,7 +1764,7 @@ else if (repositoryHelper.isTypeOf(serviceURLName, relationship.getType().getTyp public AssetResponse getAnchorAssetFromGUID(String serverName, String serviceURLName, String userId, - String entityGUID) + String guid) { final String methodName = "getAnchorAssetFromGUID"; @@ -1782,7 +1782,7 @@ public AssetResponse getAnchorAssetFromGUID(String serverName, auditLog = instanceHandler.getAuditLog(userId, serverName, methodName); EntityDetail entity = repositoryHandler.getEntityByGUID(userId, - entityGUID, + guid, OpenMetadataAPIMapper.GUID_PROPERTY_NAME, OpenMetadataAPIMapper.REFERENCEABLE_TYPE_NAME, false, @@ -1793,18 +1793,18 @@ public AssetResponse getAnchorAssetFromGUID(String serverName, if (entity != null) { if (repositoryHandler.isEntityATypeOf(userId, - entityGUID, + guid, OpenMetadataAPIMapper.GUID_PROPERTY_NAME, OpenMetadataAPIMapper.ASSET_TYPE_NAME, effectiveTime, methodName)) { - response = getAssetResponse(serverName, serviceURLName, userId, entityGUID, null, methodName); + response = getAssetResponse(serverName, serviceURLName, userId, guid, null, methodName); } else { EntityDetail anchorEntity = referenceableHandler.validateAnchorEntity(userId, - entityGUID, + guid, OpenMetadataAPIMapper.REFERENCEABLE_TYPE_NAME, entity, OpenMetadataAPIMapper.GUID_PROPERTY_NAME, @@ -1814,12 +1814,12 @@ public AssetResponse getAnchorAssetFromGUID(String serverName, null, effectiveTime, methodName); - if (repositoryHandler.isEntityATypeOf(userId, - anchorEntity.getGUID(), - OpenMetadataAPIMapper.GUID_PROPERTY_NAME, - OpenMetadataAPIMapper.ASSET_TYPE_NAME, - effectiveTime, - methodName)) + if (anchorEntity != null && repositoryHandler.isEntityATypeOf(userId, + anchorEntity.getGUID(), + OpenMetadataAPIMapper.GUID_PROPERTY_NAME, + OpenMetadataAPIMapper.ASSET_TYPE_NAME, + effectiveTime, + methodName)) { response = getAssetResponse(serverName, serviceURLName, userId, anchorEntity.getGUID(), null, methodName); } diff --git a/open-metadata-implementation/framework-services/ocf-metadata-management/ocf-metadata-spring/src/main/java/org/odpi/openmetadata/frameworkservices/ocf/metadatamanagement/server/spring/ConnectedAssetResource.java b/open-metadata-implementation/framework-services/ocf-metadata-management/ocf-metadata-spring/src/main/java/org/odpi/openmetadata/frameworkservices/ocf/metadatamanagement/server/spring/ConnectedAssetResource.java index 6182c86c06e..e5ef8009d0d 100644 --- a/open-metadata-implementation/framework-services/ocf-metadata-management/ocf-metadata-spring/src/main/java/org/odpi/openmetadata/frameworkservices/ocf/metadatamanagement/server/spring/ConnectedAssetResource.java +++ b/open-metadata-implementation/framework-services/ocf-metadata-management/ocf-metadata-spring/src/main/java/org/odpi/openmetadata/frameworkservices/ocf/metadatamanagement/server/spring/ConnectedAssetResource.java @@ -164,26 +164,26 @@ public AssetResponse getConnectedAssetSummary(@PathVariable String serverName, /** - * Returns the anchor asset of an entity. + * Returns the anchor asset. * * @param serverName String name of server instance to call. * @param serviceURLName String name of the service that created the connector that issued this request. * @param userId String userId of user making request. - * @param entityGUID String unique id for the entity. + * @param guid String unique id for the metadata element. * @return a bean with the basic properties about the anchor asset or * InvalidParameterException - the userId is null or invalid or * UnrecognizedAssetGUIDException - the GUID is null or invalid or * PropertyServerException - there is a problem retrieving the asset properties from the property server or * UserNotAuthorizedException - the requesting user is not authorized to issue this request. */ - @GetMapping(path = "/assets/from-anchor/{entityGUID}") + @GetMapping(path = "/assets/from-anchor/{guid}") public AssetResponse getAnchorAssetFromGUID(@PathVariable String serverName, @PathVariable String serviceURLName, @PathVariable String userId, - @PathVariable String entityGUID) + @PathVariable String guid) { - return restAPI.getAnchorAssetFromGUID(serverName, serviceURLName, userId, entityGUID); + return restAPI.getAnchorAssetFromGUID(serverName, serviceURLName, userId, guid); }