Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed asset catalog error codes #6210

Merged
merged 8 commits into from
Feb 10, 2022
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,6 @@ 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."),

NO_RELATIONSHIPS_FROM_NEIGHBORHOOD_NOT_FOUND(404, "OMAS-ASSET-CATALOG-404-013 ",
"There is no relationships available in the neighbourhood of asset {0} in OMAS Server {1}",
"The system is unable to retrieve the neighborhood relationships for 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.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class AssetCatalogServicesInstance extends OMASServiceInstance {
relationshipHandler = new RelationshipHandler(sourceName, invalidParameterHandler, repositoryHandler, repositoryHelper, errorHandler);
} else {
final String methodName = "new ServiceInstance";
throw new NewInstanceException(AssetCatalogErrorCode.OMRS_NOT_INITIALIZED.getMessageDefinition(methodName),
throw new NewInstanceException(AssetCatalogErrorCode.OMRS_NOT_INITIALIZED.getMessageDefinition(serverName),
this.getClass().getName(),
methodName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public enum AssetCatalogAuditCode implements AuditLogMessageSet {

EVENT_PROCESSING_EXCEPTION("OMAS-ASSET-CATALOG-0005",
OMRSAuditLogRecordSeverity.EXCEPTION,
"An exception occurred while processing incoming event {0}",
"An exception with message {0} occurred while processing incoming event {1}",
"The event could not be processed",
"Review the exception to determine the source of the error and correct it."),
EVENT_NOT_PROCESSING("OMAS-ASSET-CATALOG-0006",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ public List<org.odpi.openmetadata.accessservices.assetcatalog.model.Relationship
}

if (linkingEntities == null || CollectionUtils.isEmpty(linkingEntities.getRelationships())) {
throw new AssetCatalogException(AssetCatalogErrorCode.LINKING_RELATIONSHIPS_NOT_FOUND.getMessageDefinition(methodName),
throw new AssetCatalogException(AssetCatalogErrorCode.LINKING_RELATIONSHIPS_NOT_FOUND.getMessageDefinition(startAssetGUID, endAssetGUID, serverName),
this.getClass().getName(),
methodName);
}
Expand Down Expand Up @@ -292,13 +292,14 @@ public List<org.odpi.openmetadata.accessservices.assetcatalog.model.Relationship
* @param userId user identifier that issues the call
* @param startAssetGUID the starting asset identifier
* @param endAssetGUID the ending asset identifier
* @param serverName the name of the server
* @return a list of the entities that connects the given assets from the request
* @throws AssetCatalogException is thrown by the Asset Catalog OMAS when the asset passed on a request is not found in the repository
* @throws InvalidParameterException is thrown by the OMAG Service when a parameter is null or an invalid value.
* @throws PropertyServerException reporting errors when connecting to a metadata repository to retrieve properties about the connection and/or connector
* @throws UserNotAuthorizedException is thrown by the OCF when a userId passed on a request is not authorized to perform the requested action.
*/
public List<AssetCatalogBean> getIntermediateAssets(String userId, String startAssetGUID, String endAssetGUID)
public List<AssetCatalogBean> getIntermediateAssets(String userId, String startAssetGUID, String endAssetGUID, String serverName)
throws InvalidParameterException, PropertyServerException, UserNotAuthorizedException, AssetCatalogException {

String methodName = "getIntermediateAssets";
Expand All @@ -324,7 +325,7 @@ public List<AssetCatalogBean> getIntermediateAssets(String userId, String startA
}

if (linkingEntities == null || CollectionUtils.isEmpty(linkingEntities.getEntities())) {
throw new AssetCatalogException(AssetCatalogErrorCode.LINKING_ASSETS_NOT_FOUND.getMessageDefinition(methodName),
throw new AssetCatalogException(AssetCatalogErrorCode. LINKING_ASSETS_NOT_FOUND.getMessageDefinition(startAssetGUID, endAssetGUID, serverName),
this.getClass().getName(),
methodName);
}
Expand All @@ -336,13 +337,14 @@ public List<AssetCatalogBean> getIntermediateAssets(String userId, String startA
* @param userId user identifier that issues the call
* @param assetGUID the asset identifier
* @param searchParameters additional parameters for searching and filtering
* @param serverName
* @return a list of entities from the neighborhood of the given entity
* @throws AssetCatalogException is thrown by the Asset Catalog OMAS when the asset passed on a request is not found in the repository
* @throws InvalidParameterException is thrown by the OMAG Service when a parameter is null or an invalid value.
* @throws PropertyServerException reporting errors when connecting to a metadata repository to retrieve properties about the connection and/or connector
* @throws UserNotAuthorizedException is thrown by the OCF when a userId passed on a request is not authorized to perform the requested action.
*/
public List<AssetCatalogBean> getEntitiesFromNeighborhood(String userId, String assetGUID, SearchParameters searchParameters)
public List<AssetCatalogBean> getEntitiesFromNeighborhood(String userId, String assetGUID, SearchParameters searchParameters, String serverName)
throws InvalidParameterException, PropertyServerException, UserNotAuthorizedException, AssetCatalogException {

String methodName = "getEntitiesFromNeighborhood";
Expand All @@ -352,11 +354,11 @@ public List<AssetCatalogBean> getEntitiesFromNeighborhood(String userId, String
invalidParameterHandler.validateObject(searchParameters, SEARCH_PARAMETER, methodName);
invalidParameterHandler.validatePaging(searchParameters.getFrom(), searchParameters.getPageSize(), methodName);

InstanceGraph entityNeighborhood = getAssetNeighborhood(userId, assetGUID, searchParameters);
InstanceGraph entityNeighborhood = getAssetNeighborhood(userId, assetGUID, searchParameters, serverName);

List<EntityDetail> entities = entityNeighborhood.getEntities();
if (CollectionUtils.isEmpty(entities)) {
throw new AssetCatalogException(AssetCatalogErrorCode.NO_ASSET_FROM_NEIGHBORHOOD_NOT_FOUND.getMessageDefinition(methodName),
throw new AssetCatalogException(AssetCatalogErrorCode.NO_ASSET_FROM_NEIGHBORHOOD_NOT_FOUND.getMessageDefinition(assetGUID, serverName),
this.getClass().getName(),
methodName);
}
Expand Down Expand Up @@ -1431,7 +1433,7 @@ private List<Classification> filterClassificationByName(List<Classification> cla
return classifications.stream().filter(classification -> classification.getName().equals(classificationName)).collect(Collectors.toList());
}

private InstanceGraph getAssetNeighborhood(String userId, String entityGUID, SearchParameters searchParameters)
private InstanceGraph getAssetNeighborhood(String userId, String entityGUID, SearchParameters searchParameters, String serverName)
throws AssetCatalogException, PropertyServerException, InvalidParameterException, UserNotAuthorizedException {
OMRSMetadataCollection metadataCollection = commonHandler.getOMRSMetadataCollection();

Expand Down Expand Up @@ -1459,7 +1461,7 @@ private InstanceGraph getAssetNeighborhood(String userId, String entityGUID, Sea
}

if (entityNeighborhood == null) {
throw new AssetCatalogException(AssetCatalogErrorCode.ASSET_NEIGHBORHOOD_NOT_FOUND.getMessageDefinition(methodName),
throw new AssetCatalogException(AssetCatalogErrorCode.ASSET_NEIGHBORHOOD_NOT_FOUND.getMessageDefinition(entityGUID, serverName),
this.getClass().getName(),
methodName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public void processInstanceEvent(OMRSInstanceEvent instanceEvent)
log.debug("Ignored instance event - null OMRSEventOriginator");
auditLog.logMessage(
"No instance origin. Event IGNORED!",
AssetCatalogAuditCode.EVENT_NOT_PROCESSING.getMessageDefinition());
AssetCatalogAuditCode.EVENT_NOT_PROCESSING.getMessageDefinition("no instance origin"));
return;
}

Expand Down Expand Up @@ -208,7 +208,7 @@ private void logExceptionToAudit(OMRSInstanceEvent instanceEvent, Exception e) {
String actionDescription = "Asset Lineage OMAS is unable to process an OMRSTopic event.";

auditLog.logException(actionDescription,
AssetCatalogAuditCode.EVENT_PROCESSING_EXCEPTION.getMessageDefinition(e.getMessage(), serverName),
AssetCatalogAuditCode.EVENT_PROCESSING_EXCEPTION.getMessageDefinition(e.getMessage(), instanceEvent.toString()),
instanceEvent.toString(), e);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ public AssetCatalogListResponse getLinkingAssets(String serverName,
AssetCatalogListResponse response = new AssetCatalogListResponse();
try {
AssetCatalogHandler assetCatalogHandler = instanceHandler.getAssetCatalogHandler(userId, serverName, methodName);
response.setAssetCatalogBeanList(assetCatalogHandler.getIntermediateAssets(userId, startAssetId, endAssetId));
response.setAssetCatalogBeanList(assetCatalogHandler.getIntermediateAssets(userId, startAssetId, endAssetId, serverName));
} catch (AssetCatalogException e) {
exceptionHandler.captureAssetCatalogExeption(response, e);
} catch (org.odpi.openmetadata.frameworks.connectors.ffdc.UserNotAuthorizedException e) {
Expand Down Expand Up @@ -265,7 +265,7 @@ public AssetCatalogListResponse getAssetsFromNeighborhood(String serverName,
AssetCatalogListResponse response = new AssetCatalogListResponse();
try {
AssetCatalogHandler assetCatalogHandler = instanceHandler.getAssetCatalogHandler(userId, serverName, methodName);
List<AssetCatalogBean> entitiesFromNeighborhood = assetCatalogHandler.getEntitiesFromNeighborhood(userId, assetGUID, searchParameters);
List<AssetCatalogBean> entitiesFromNeighborhood = assetCatalogHandler.getEntitiesFromNeighborhood(userId, assetGUID, searchParameters, serverName);

response.setAssetCatalogBeanList(entitiesFromNeighborhood);
} catch (AssetCatalogException e) {
Expand Down
Loading