From f4d8462ac8a40714f389f45e7130e24579de3f7b Mon Sep 17 00:00:00 2001 From: Mandy Chessell Date: Mon, 16 Jan 2023 11:37:05 +0000 Subject: [PATCH 1/3] Detect deleted entities quicker (#7303) Signed-off-by: Mandy Chessell --- .../OpenMetadataAPIGenericHandler.java | 2 +- .../EnterpriseOMRSMetadataCollection.java | 6 +-- .../ClassificationAccumulator.java | 19 ++++++- .../accumulators/EntityDetailAccumulator.java | 7 +-- .../EntitySummaryAccumulator.java | 2 +- .../executors/GetEntityDetailExecutor.java | 49 ++++++++++--------- 6 files changed, 53 insertions(+), 32 deletions(-) diff --git a/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/OpenMetadataAPIGenericHandler.java b/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/OpenMetadataAPIGenericHandler.java index 493d5bb6b10..ad5b4e4d252 100644 --- a/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/OpenMetadataAPIGenericHandler.java +++ b/open-metadata-implementation/common-services/generic-handlers/src/main/java/org/odpi/openmetadata/commonservices/generichandlers/OpenMetadataAPIGenericHandler.java @@ -7083,7 +7083,7 @@ public void deleteAnchoredEntity(List anchoredEntityGUIDs, * because it is a parent object. If it now has no anchor then it can be * deleted because it is a child object. */ - String derivedAnchorGUID = this.deriveAnchorGUID(entityGUID, entityTypeName, forLineage, forDuplicateProcessing, effectiveTime, methodName); + String derivedAnchorGUID = this.deriveAnchorGUID(entity.getGUID(), entityTypeName, forLineage, forDuplicateProcessing, effectiveTime, methodName); if (derivedAnchorGUID == null) { diff --git a/open-metadata-implementation/repository-services/repository-services-implementation/src/main/java/org/odpi/openmetadata/repositoryservices/enterprise/repositoryconnector/EnterpriseOMRSMetadataCollection.java b/open-metadata-implementation/repository-services/repository-services-implementation/src/main/java/org/odpi/openmetadata/repositoryservices/enterprise/repositoryconnector/EnterpriseOMRSMetadataCollection.java index 694e5603df2..98a28e32f88 100644 --- a/open-metadata-implementation/repository-services/repository-services-implementation/src/main/java/org/odpi/openmetadata/repositoryservices/enterprise/repositoryconnector/EnterpriseOMRSMetadataCollection.java +++ b/open-metadata-implementation/repository-services/repository-services-implementation/src/main/java/org/odpi/openmetadata/repositoryservices/enterprise/repositoryconnector/EnterpriseOMRSMetadataCollection.java @@ -895,7 +895,7 @@ public EntityDetail isEntityKnown(String userId, List cohortConnectors = enterpriseParentConnector.getCohortConnectors(methodName); FederationControl federationControl = new ParallelFederationControl(userId, cohortConnectors, auditLog, methodName); - GetEntityDetailExecutor executor = new GetEntityDetailExecutor(userId, guid, false, auditLog, methodName); + GetEntityDetailExecutor executor = new GetEntityDetailExecutor(userId, guid, auditLog, methodName); /* * Ready to process the request. Create requests occur in the first repository that accepts the call. @@ -904,7 +904,7 @@ public EntityDetail isEntityKnown(String userId, */ federationControl.executeCommand(executor); - return executor.isEntityKnown(); + return executor.isEntityKnown(true); } @@ -994,7 +994,7 @@ public EntityDetail getEntityDetail(String userId, List cohortConnectors = enterpriseParentConnector.getCohortConnectors(methodName); FederationControl federationControl = new ParallelFederationControl(userId, cohortConnectors, auditLog, methodName); - GetEntityDetailExecutor executor = new GetEntityDetailExecutor(userId, guid, true, auditLog, methodName); + GetEntityDetailExecutor executor = new GetEntityDetailExecutor(userId, guid, auditLog, methodName); federationControl.executeCommand(executor); diff --git a/open-metadata-implementation/repository-services/repository-services-implementation/src/main/java/org/odpi/openmetadata/repositoryservices/enterprise/repositoryconnector/accumulators/ClassificationAccumulator.java b/open-metadata-implementation/repository-services/repository-services-implementation/src/main/java/org/odpi/openmetadata/repositoryservices/enterprise/repositoryconnector/accumulators/ClassificationAccumulator.java index b5b4135138c..440648afb99 100644 --- a/open-metadata-implementation/repository-services/repository-services-implementation/src/main/java/org/odpi/openmetadata/repositoryservices/enterprise/repositoryconnector/accumulators/ClassificationAccumulator.java +++ b/open-metadata-implementation/repository-services/repository-services-implementation/src/main/java/org/odpi/openmetadata/repositoryservices/enterprise/repositoryconnector/accumulators/ClassificationAccumulator.java @@ -5,6 +5,7 @@ import org.odpi.openmetadata.frameworks.auditlog.AuditLog; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.Classification; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.InstanceStatus; import java.util.ArrayList; import java.util.HashMap; @@ -120,18 +121,32 @@ public void saveClassifications(List retrievedClassifications) /** * Return the accumulated classifications to the caller. * + * @param returnDeletedClassifications should classifications in deleted status be returned? * @return null or list of classifications */ - List getClassifications() + List getClassifications(boolean returnDeletedClassifications) { if (allClassifications.isEmpty()) { return null; } - else + else if (returnDeletedClassifications) { return new ArrayList<>(allClassifications.values()); } + else + { + List activeClassifications = new ArrayList<>(); + + for (Classification accumulatedClassification : allClassifications.values()) + { + if (accumulatedClassification.getStatus() != InstanceStatus.DELETED) + { + activeClassifications.add(accumulatedClassification); + } + } + return activeClassifications; + } } } diff --git a/open-metadata-implementation/repository-services/repository-services-implementation/src/main/java/org/odpi/openmetadata/repositoryservices/enterprise/repositoryconnector/accumulators/EntityDetailAccumulator.java b/open-metadata-implementation/repository-services/repository-services-implementation/src/main/java/org/odpi/openmetadata/repositoryservices/enterprise/repositoryconnector/accumulators/EntityDetailAccumulator.java index 561dbc19715..e003355def3 100644 --- a/open-metadata-implementation/repository-services/repository-services-implementation/src/main/java/org/odpi/openmetadata/repositoryservices/enterprise/repositoryconnector/accumulators/EntityDetailAccumulator.java +++ b/open-metadata-implementation/repository-services/repository-services-implementation/src/main/java/org/odpi/openmetadata/repositoryservices/enterprise/repositoryconnector/accumulators/EntityDetailAccumulator.java @@ -99,13 +99,14 @@ public List getResultsForAugmentation() * Extract the resulting entity and accumulated classifications. It should be called once all the executors have completed processing * their request(s). * - * @return list of entities + * @param returnDeletedClassifications should classifications in deleted status be returned? + * @return consolidated entity */ - public EntityDetail getResult() + public EntityDetail getResult(boolean returnDeletedClassifications) { if (currentSavedEntity != null) { - currentSavedEntity.setClassifications(super.getClassifications()); + currentSavedEntity.setClassifications(super.getClassifications(returnDeletedClassifications)); return currentSavedEntity; } diff --git a/open-metadata-implementation/repository-services/repository-services-implementation/src/main/java/org/odpi/openmetadata/repositoryservices/enterprise/repositoryconnector/accumulators/EntitySummaryAccumulator.java b/open-metadata-implementation/repository-services/repository-services-implementation/src/main/java/org/odpi/openmetadata/repositoryservices/enterprise/repositoryconnector/accumulators/EntitySummaryAccumulator.java index 7d29129960e..50df3754300 100644 --- a/open-metadata-implementation/repository-services/repository-services-implementation/src/main/java/org/odpi/openmetadata/repositoryservices/enterprise/repositoryconnector/accumulators/EntitySummaryAccumulator.java +++ b/open-metadata-implementation/repository-services/repository-services-implementation/src/main/java/org/odpi/openmetadata/repositoryservices/enterprise/repositoryconnector/accumulators/EntitySummaryAccumulator.java @@ -106,7 +106,7 @@ public EntitySummary getResult() { if (currentSavedEntity != null) { - currentSavedEntity.setClassifications(super.getClassifications()); + currentSavedEntity.setClassifications(super.getClassifications(false)); return currentSavedEntity; } diff --git a/open-metadata-implementation/repository-services/repository-services-implementation/src/main/java/org/odpi/openmetadata/repositoryservices/enterprise/repositoryconnector/executors/GetEntityDetailExecutor.java b/open-metadata-implementation/repository-services/repository-services-implementation/src/main/java/org/odpi/openmetadata/repositoryservices/enterprise/repositoryconnector/executors/GetEntityDetailExecutor.java index a5805f1f6d9..03c48b87a3b 100644 --- a/open-metadata-implementation/repository-services/repository-services-implementation/src/main/java/org/odpi/openmetadata/repositoryservices/enterprise/repositoryconnector/executors/GetEntityDetailExecutor.java +++ b/open-metadata-implementation/repository-services/repository-services-implementation/src/main/java/org/odpi/openmetadata/repositoryservices/enterprise/repositoryconnector/executors/GetEntityDetailExecutor.java @@ -6,7 +6,9 @@ import org.odpi.openmetadata.frameworks.auditlog.AuditLog; 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.InstanceStatus; import org.odpi.openmetadata.repositoryservices.enterprise.repositoryconnector.accumulators.EntityDetailAccumulator; +import org.odpi.openmetadata.repositoryservices.ffdc.OMRSErrorCode; import org.odpi.openmetadata.repositoryservices.ffdc.exception.*; import java.util.Date; @@ -27,7 +29,6 @@ */ public class GetEntityDetailExecutor extends GetEntityExecutor { - private boolean allExceptions = true; private Date asOfTime = null; private final EntityDetailAccumulator accumulator; @@ -38,17 +39,15 @@ public class GetEntityDetailExecutor extends GetEntityExecutor * * @param userId unique identifier for requesting user. * @param entityGUID unique identifier (guid) for the entity. - * @param allExceptions is the a isEntityKnown or getEntityDetail request. * @param auditLog logging destination * @param methodName calling method */ public GetEntityDetailExecutor(String userId, String entityGUID, - boolean allExceptions, AuditLog auditLog, String methodName) { - this(userId, entityGUID, allExceptions, new EntityDetailAccumulator(auditLog), methodName); + this(userId, entityGUID, new EntityDetailAccumulator(auditLog), methodName); } @@ -57,19 +56,15 @@ public GetEntityDetailExecutor(String userId, * * @param userId unique identifier for requesting user. * @param entityGUID unique identifier (guid) for the entity. - * @param allExceptions is the a isEntityKnown or getEntityDetail request. * @param accumulator to use * @param methodName calling method */ private GetEntityDetailExecutor(String userId, String entityGUID, - boolean allExceptions, EntityDetailAccumulator accumulator, String methodName) { super(userId, entityGUID, accumulator, methodName); - - this.allExceptions = allExceptions; this.accumulator = accumulator; } @@ -147,14 +142,7 @@ public boolean issueRequestToRepository(String metadataCollectio EntityDetail retrievedEntity; if (asOfTime == null) { - if (allExceptions) - { - retrievedEntity = metadataCollection.getEntityDetail(userId, entityGUID); - } - else - { - retrievedEntity = metadataCollection.isEntityKnown(userId, entityGUID); - } + retrievedEntity = metadataCollection.isEntityKnown(userId, entityGUID); } else { @@ -211,17 +199,18 @@ public boolean issueRequestToRepository(String metadataCollectio /** * Returns the entity if the entity is stored in the metadata collection, otherwise null. * + * @param returnDeletedClassifications should classifications in deleted status be returned? * @return the entity details if the entity is found in the metadata collection; otherwise return null * @throws InvalidParameterException the guid is null. * @throws RepositoryErrorException there is a problem communicating with the metadata repository where * the metadata collection is stored. * @throws UserNotAuthorizedException the userId is not permitted to perform this operation. */ - public EntityDetail isEntityKnown() throws InvalidParameterException, - RepositoryErrorException, - UserNotAuthorizedException + public EntityDetail isEntityKnown(boolean returnDeletedClassifications) throws InvalidParameterException, + RepositoryErrorException, + UserNotAuthorizedException { - EntityDetail result = accumulator.getResult(); + EntityDetail result = accumulator.getResult(returnDeletedClassifications); if (result != null) { return result; @@ -252,17 +241,33 @@ public EntityDetail getEntityDetail() throws InvalidParameterException, EntityProxyOnlyException, UserNotAuthorizedException { - EntityDetail entity = this.isEntityKnown(); + final String repositoryName = "Enterprise"; + + EntityDetail entity = this.isEntityKnown(false); if (entity != null) { + if (entity.getStatus() == InstanceStatus.DELETED) + { + throw new EntityNotKnownException(OMRSErrorCode.ENTITY_SOFT_DELETED.getMessageDefinition(entity.getType().getTypeDefName(), + entity.getGUID(), + methodName, + repositoryName), + this.getClass().getName(), + methodName); + } + return entity; } accumulator.throwCapturedEntityProxyOnlyException(); accumulator.throwCapturedEntityNotKnownException(); - return null; + throw new EntityNotKnownException(OMRSErrorCode.ENTITY_NOT_KNOWN.getMessageDefinition(entityGUID, + methodName, + repositoryName), + this.getClass().getName(), + methodName); } From a8557d0a4994915474038d73c04523f33afa52c6 Mon Sep 17 00:00:00 2001 From: Mandy Chessell Date: Mon, 16 Jan 2023 12:02:11 +0000 Subject: [PATCH 2/3] Fix code warnings and javadoc Signed-off-by: Mandy Chessell --- .../openmetadata/frameworks/auditlog/AuditLog.java | 9 +++------ .../frameworks/auditlog/ComponentDescription.java | 4 ++-- .../auditlog/ComponentDevelopmentStatus.java | 6 +++--- .../messagesets/AuditLogMessageDefinition.java | 4 ++-- .../messagesets/ExceptionMessageDefinition.java | 2 +- .../auditlog/messagesets/MessageDefinition.java | 11 +++++------ 6 files changed, 16 insertions(+), 20 deletions(-) diff --git a/open-metadata-implementation/frameworks/audit-log-framework/src/main/java/org/odpi/openmetadata/frameworks/auditlog/AuditLog.java b/open-metadata-implementation/frameworks/audit-log-framework/src/main/java/org/odpi/openmetadata/frameworks/auditlog/AuditLog.java index d663f079a37..0bb69f25e65 100644 --- a/open-metadata-implementation/frameworks/audit-log-framework/src/main/java/org/odpi/openmetadata/frameworks/auditlog/AuditLog.java +++ b/open-metadata-implementation/frameworks/audit-log-framework/src/main/java/org/odpi/openmetadata/frameworks/auditlog/AuditLog.java @@ -374,8 +374,8 @@ public AuditLogReport getReport() */ public static class AuditLogActivity { - private volatile Map> severityIdentificationMap = new HashMap<>(); - private volatile Map severityCountMap = new HashMap<>(); + private final Map> severityIdentificationMap = new HashMap<>(); + private final Map severityCountMap = new HashMap<>(); /** * Update the maps with information about another log record. @@ -466,10 +466,7 @@ synchronized Map getSeverityCountMap() result.put(severityCode, severityCount); } - if (! result.isEmpty()) - { - return result; - } + return result; } return null; diff --git a/open-metadata-implementation/frameworks/audit-log-framework/src/main/java/org/odpi/openmetadata/frameworks/auditlog/ComponentDescription.java b/open-metadata-implementation/frameworks/audit-log-framework/src/main/java/org/odpi/openmetadata/frameworks/auditlog/ComponentDescription.java index 40b453321e5..90ac3ed8731 100644 --- a/open-metadata-implementation/frameworks/audit-log-framework/src/main/java/org/odpi/openmetadata/frameworks/auditlog/ComponentDescription.java +++ b/open-metadata-implementation/frameworks/audit-log-framework/src/main/java/org/odpi/openmetadata/frameworks/auditlog/ComponentDescription.java @@ -4,7 +4,7 @@ package org.odpi.openmetadata.frameworks.auditlog; /** - * ComponentDescription is an interface implemented by a enum that describes the components using the audit log + * ComponentDescription is an interface implemented by an enum that describes the components using the audit log */ public interface ComponentDescription { @@ -43,7 +43,7 @@ public interface ComponentDescription String getComponentDescription(); /** - * URL link to the wiki page that describes this component. This provides more information to the log reader + * URL to the wiki page that describes this component. This provides more information to the log reader * on the operation of the component. * * @return String URL diff --git a/open-metadata-implementation/frameworks/audit-log-framework/src/main/java/org/odpi/openmetadata/frameworks/auditlog/ComponentDevelopmentStatus.java b/open-metadata-implementation/frameworks/audit-log-framework/src/main/java/org/odpi/openmetadata/frameworks/auditlog/ComponentDevelopmentStatus.java index 8a58c7dab46..aac3dd8203c 100644 --- a/open-metadata-implementation/frameworks/audit-log-framework/src/main/java/org/odpi/openmetadata/frameworks/auditlog/ComponentDevelopmentStatus.java +++ b/open-metadata-implementation/frameworks/audit-log-framework/src/main/java/org/odpi/openmetadata/frameworks/auditlog/ComponentDevelopmentStatus.java @@ -13,9 +13,9 @@ public enum ComponentDevelopmentStatus SAMPLE (3, "Sample", "This component is supplied as a sample. It can be used 'as is' or may be modified as desired."), DEPRECATED (99, "Deprecated", "This component is deprecated an may be removed in a later release."); - private int ordinal; - private String name; - private String description; + private final int ordinal; + private final String name; + private final String description; private static final long serialVersionUID = 1L; diff --git a/open-metadata-implementation/frameworks/audit-log-framework/src/main/java/org/odpi/openmetadata/frameworks/auditlog/messagesets/AuditLogMessageDefinition.java b/open-metadata-implementation/frameworks/audit-log-framework/src/main/java/org/odpi/openmetadata/frameworks/auditlog/messagesets/AuditLogMessageDefinition.java index c78bfb5344f..0fc09ccc8ca 100644 --- a/open-metadata-implementation/frameworks/audit-log-framework/src/main/java/org/odpi/openmetadata/frameworks/auditlog/messagesets/AuditLogMessageDefinition.java +++ b/open-metadata-implementation/frameworks/audit-log-framework/src/main/java/org/odpi/openmetadata/frameworks/auditlog/messagesets/AuditLogMessageDefinition.java @@ -21,14 +21,14 @@ @JsonIgnoreProperties(ignoreUnknown=true) public class AuditLogMessageDefinition extends MessageDefinition { - private AuditLogRecordSeverity severity; + private final AuditLogRecordSeverity severity; /** * Constructor to save all the fixed values of a message. This is typically populated * from an Enum message set. The constructor passes most values to the super class and just retains * the additional value for the audit log. * - * @param messageId unique Id for the message + * @param messageId unique id for the message * @param severity severity of the message * @param messageTemplate text for the message * @param systemAction description of the action taken by the system when the condition happened diff --git a/open-metadata-implementation/frameworks/audit-log-framework/src/main/java/org/odpi/openmetadata/frameworks/auditlog/messagesets/ExceptionMessageDefinition.java b/open-metadata-implementation/frameworks/audit-log-framework/src/main/java/org/odpi/openmetadata/frameworks/auditlog/messagesets/ExceptionMessageDefinition.java index 2bb54abcb5c..aa159d00241 100644 --- a/open-metadata-implementation/frameworks/audit-log-framework/src/main/java/org/odpi/openmetadata/frameworks/auditlog/messagesets/ExceptionMessageDefinition.java +++ b/open-metadata-implementation/frameworks/audit-log-framework/src/main/java/org/odpi/openmetadata/frameworks/auditlog/messagesets/ExceptionMessageDefinition.java @@ -21,7 +21,7 @@ @JsonIgnoreProperties(ignoreUnknown=true) public class ExceptionMessageDefinition extends MessageDefinition { - private int httpErrorCode; + private final int httpErrorCode; /** diff --git a/open-metadata-implementation/frameworks/audit-log-framework/src/main/java/org/odpi/openmetadata/frameworks/auditlog/messagesets/MessageDefinition.java b/open-metadata-implementation/frameworks/audit-log-framework/src/main/java/org/odpi/openmetadata/frameworks/auditlog/messagesets/MessageDefinition.java index bd9c58b09e5..f99be945889 100644 --- a/open-metadata-implementation/frameworks/audit-log-framework/src/main/java/org/odpi/openmetadata/frameworks/auditlog/messagesets/MessageDefinition.java +++ b/open-metadata-implementation/frameworks/audit-log-framework/src/main/java/org/odpi/openmetadata/frameworks/auditlog/messagesets/MessageDefinition.java @@ -23,10 +23,10 @@ @JsonIgnoreProperties(ignoreUnknown=true) public abstract class MessageDefinition { - private String messageId; - private String messageTemplate; - private String systemAction; - private String userAction; + private final String messageId; + private final String messageTemplate; + private final String systemAction; + private final String userAction; private String[] params; @@ -93,7 +93,7 @@ public String getSystemAction() /** - * Returns instructions on what to do next given that this situation has occurred. + * Returns instructions on what to do next, given that this situation has occurred. * * @return userAction String */ @@ -117,7 +117,6 @@ public String toString() ", systemAction='" + systemAction + '\'' + ", userAction='" + userAction + '\'' + ", params=" + Arrays.toString(params) + - ", messageParams=" + Arrays.toString(getMessageParams()) + '}'; } } From d6a6ddc58626fe33ed8f2958835da594a5f0994b Mon Sep 17 00:00:00 2001 From: Mandy Chessell Date: Mon, 16 Jan 2023 12:26:08 +0000 Subject: [PATCH 3/3] Detect deleted relationship as fast as possible Signed-off-by: Mandy Chessell --- .../EnterpriseOMRSMetadataCollection.java | 4 +- .../RelationshipsAccumulator.java | 4 +- .../executors/GetEntityDetailExecutor.java | 2 - .../executors/GetRelationshipExecutor.java | 38 ++++++++++--------- .../executors/RepositoryExecutorBase.java | 2 + 5 files changed, 26 insertions(+), 24 deletions(-) diff --git a/open-metadata-implementation/repository-services/repository-services-implementation/src/main/java/org/odpi/openmetadata/repositoryservices/enterprise/repositoryconnector/EnterpriseOMRSMetadataCollection.java b/open-metadata-implementation/repository-services/repository-services-implementation/src/main/java/org/odpi/openmetadata/repositoryservices/enterprise/repositoryconnector/EnterpriseOMRSMetadataCollection.java index 98a28e32f88..d41ce3cd8f3 100644 --- a/open-metadata-implementation/repository-services/repository-services-implementation/src/main/java/org/odpi/openmetadata/repositoryservices/enterprise/repositoryconnector/EnterpriseOMRSMetadataCollection.java +++ b/open-metadata-implementation/repository-services/repository-services-implementation/src/main/java/org/odpi/openmetadata/repositoryservices/enterprise/repositoryconnector/EnterpriseOMRSMetadataCollection.java @@ -1657,7 +1657,7 @@ public Relationship isRelationshipKnown(String userId, List cohortConnectors = enterpriseParentConnector.getCohortConnectors(methodName); FederationControl federationControl = new SequentialFederationControl(userId, cohortConnectors, auditLog, methodName); - GetRelationshipExecutor executor = new GetRelationshipExecutor(userId, guid, false, auditLog, methodName); + GetRelationshipExecutor executor = new GetRelationshipExecutor(userId, guid, auditLog, methodName); /* * Ready to process the request. Create requests occur in the first repository that accepts the call. @@ -1706,7 +1706,7 @@ public Relationship getRelationship(String userId, List cohortConnectors = enterpriseParentConnector.getCohortConnectors(methodName); FederationControl federationControl = new SequentialFederationControl(userId, cohortConnectors, auditLog, methodName); - GetRelationshipExecutor executor = new GetRelationshipExecutor(userId, guid, true, auditLog, methodName); + GetRelationshipExecutor executor = new GetRelationshipExecutor(userId, guid, auditLog, methodName); /* * Ready to process the request. Create requests occur in the first repository that accepts the call. diff --git a/open-metadata-implementation/repository-services/repository-services-implementation/src/main/java/org/odpi/openmetadata/repositoryservices/enterprise/repositoryconnector/accumulators/RelationshipsAccumulator.java b/open-metadata-implementation/repository-services/repository-services-implementation/src/main/java/org/odpi/openmetadata/repositoryservices/enterprise/repositoryconnector/accumulators/RelationshipsAccumulator.java index 07cb5ba9063..a94ef870ef4 100644 --- a/open-metadata-implementation/repository-services/repository-services-implementation/src/main/java/org/odpi/openmetadata/repositoryservices/enterprise/repositoryconnector/accumulators/RelationshipsAccumulator.java +++ b/open-metadata-implementation/repository-services/repository-services-implementation/src/main/java/org/odpi/openmetadata/repositoryservices/enterprise/repositoryconnector/accumulators/RelationshipsAccumulator.java @@ -20,7 +20,7 @@ */ public class RelationshipsAccumulator extends QueryInstanceAccumulatorBase { - private volatile Map accumulatedRelationships = new HashMap<>(); + private final Map accumulatedRelationships = new HashMap<>(); /** @@ -108,7 +108,7 @@ public synchronized void addRelationships(List relationships, /** - * Extract the results - this will the a unique list of relationships selected from the instances + * Extract the results - this will a list of unique relationships selected from the instances * supplied to this accumulator. It should be called once all the executors have completed processing * their request(s). * diff --git a/open-metadata-implementation/repository-services/repository-services-implementation/src/main/java/org/odpi/openmetadata/repositoryservices/enterprise/repositoryconnector/executors/GetEntityDetailExecutor.java b/open-metadata-implementation/repository-services/repository-services-implementation/src/main/java/org/odpi/openmetadata/repositoryservices/enterprise/repositoryconnector/executors/GetEntityDetailExecutor.java index 03c48b87a3b..aee40d71fee 100644 --- a/open-metadata-implementation/repository-services/repository-services-implementation/src/main/java/org/odpi/openmetadata/repositoryservices/enterprise/repositoryconnector/executors/GetEntityDetailExecutor.java +++ b/open-metadata-implementation/repository-services/repository-services-implementation/src/main/java/org/odpi/openmetadata/repositoryservices/enterprise/repositoryconnector/executors/GetEntityDetailExecutor.java @@ -241,8 +241,6 @@ public EntityDetail getEntityDetail() throws InvalidParameterException, EntityProxyOnlyException, UserNotAuthorizedException { - final String repositoryName = "Enterprise"; - EntityDetail entity = this.isEntityKnown(false); if (entity != null) diff --git a/open-metadata-implementation/repository-services/repository-services-implementation/src/main/java/org/odpi/openmetadata/repositoryservices/enterprise/repositoryconnector/executors/GetRelationshipExecutor.java b/open-metadata-implementation/repository-services/repository-services-implementation/src/main/java/org/odpi/openmetadata/repositoryservices/enterprise/repositoryconnector/executors/GetRelationshipExecutor.java index 4a169db992b..bc406d7087c 100644 --- a/open-metadata-implementation/repository-services/repository-services-implementation/src/main/java/org/odpi/openmetadata/repositoryservices/enterprise/repositoryconnector/executors/GetRelationshipExecutor.java +++ b/open-metadata-implementation/repository-services/repository-services-implementation/src/main/java/org/odpi/openmetadata/repositoryservices/enterprise/repositoryconnector/executors/GetRelationshipExecutor.java @@ -5,8 +5,10 @@ import org.odpi.openmetadata.frameworks.auditlog.AuditLog; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.OMRSMetadataCollection; +import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.InstanceStatus; import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.Relationship; import org.odpi.openmetadata.repositoryservices.enterprise.repositoryconnector.accumulators.MaintenanceAccumulator; +import org.odpi.openmetadata.repositoryservices.ffdc.OMRSErrorCode; import org.odpi.openmetadata.repositoryservices.ffdc.exception.*; import java.util.Date; @@ -19,7 +21,7 @@ public class GetRelationshipExecutor extends RepositoryExecutorBase private final MaintenanceAccumulator accumulator; private final String relationshipGUID; - private boolean allExceptions = true; + private Date asOfTime = null; private Relationship retrievedRelationship = null; @@ -30,13 +32,11 @@ public class GetRelationshipExecutor extends RepositoryExecutorBase * * @param userId unique identifier for requesting user * @param relationshipGUID unique identifier (guid) for the relationship - * @param allExceptions is the a isRelationshipKnown or getRelationship request * @param auditLog logging destination * @param methodName calling method */ public GetRelationshipExecutor(String userId, String relationshipGUID, - boolean allExceptions, AuditLog auditLog, String methodName) { @@ -45,7 +45,6 @@ public GetRelationshipExecutor(String userId, this.accumulator = new MaintenanceAccumulator(auditLog); this.relationshipGUID = relationshipGUID; - this.allExceptions = allExceptions; } @@ -96,22 +95,11 @@ public boolean issueRequestToRepository(String metadataCollectio */ if (asOfTime == null) { - if (allExceptions) - { - retrievedRelationship = metadataCollection.getRelationship(userId, - relationshipGUID); - } - else - { - retrievedRelationship = metadataCollection.isRelationshipKnown(userId, - relationshipGUID); - } + retrievedRelationship = metadataCollection.isRelationshipKnown(userId, relationshipGUID); } else { - retrievedRelationship = metadataCollection.getRelationship(userId, - relationshipGUID, - asOfTime); + retrievedRelationship = metadataCollection.getRelationship(userId, relationshipGUID, asOfTime); } if (retrievedRelationship != null) { @@ -191,12 +179,26 @@ public Relationship getRelationship() throws InvalidParameterException, if (relationship != null) { + if (relationship.getStatus() == InstanceStatus.DELETED) + { + throw new RelationshipNotKnownException(OMRSErrorCode.RELATIONSHIP_SOFT_DELETED.getMessageDefinition(relationship.getType().getTypeDefName(), + relationship.getGUID(), + methodName, + repositoryName), + this.getClass().getName(), + methodName); + } + return relationship; } accumulator.throwCapturedRelationshipNotKnownException(); - return null; + throw new RelationshipNotKnownException(OMRSErrorCode.RELATIONSHIP_NOT_KNOWN.getMessageDefinition(relationshipGUID, + methodName, + repositoryName), + this.getClass().getName(), + methodName); } diff --git a/open-metadata-implementation/repository-services/repository-services-implementation/src/main/java/org/odpi/openmetadata/repositoryservices/enterprise/repositoryconnector/executors/RepositoryExecutorBase.java b/open-metadata-implementation/repository-services/repository-services-implementation/src/main/java/org/odpi/openmetadata/repositoryservices/enterprise/repositoryconnector/executors/RepositoryExecutorBase.java index 33d06a072c0..10d98a0c13d 100644 --- a/open-metadata-implementation/repository-services/repository-services-implementation/src/main/java/org/odpi/openmetadata/repositoryservices/enterprise/repositoryconnector/executors/RepositoryExecutorBase.java +++ b/open-metadata-implementation/repository-services/repository-services-implementation/src/main/java/org/odpi/openmetadata/repositoryservices/enterprise/repositoryconnector/executors/RepositoryExecutorBase.java @@ -6,6 +6,8 @@ public abstract class RepositoryExecutorBase implements RepositoryExecutor { + final String repositoryName = "Enterprise"; + protected String methodName; protected String userId;