diff --git a/entity-management-web/src/main/java/eu/europeana/entitymanagement/web/service/BaseZohoAccess.java b/entity-management-web/src/main/java/eu/europeana/entitymanagement/web/service/BaseZohoAccess.java index 1a22f3bd..cb60e118 100644 --- a/entity-management-web/src/main/java/eu/europeana/entitymanagement/web/service/BaseZohoAccess.java +++ b/entity-management-web/src/main/java/eu/europeana/entitymanagement/web/service/BaseZohoAccess.java @@ -351,25 +351,36 @@ List performEntityRegistration(SortedSet createOperations, Optional registeredRecord = performEntityRegistration(operation, zohoSyncReport, entitiesToUpdate); - if (registeredRecord.isPresent()) { // entity successfully registered if (mustGenerateEuropeanaId) { - // entity registration submits Europeana ID to zoho + // entity registration submits new geenrated EuropeanaIDs to zoho zohoSyncReport.increaseSubmittedZohoEuropeanaId(); } - - if (mustGenerateEuropeanaId - && !registeredRecord.get().getEntityId().equals(beforeOperationZohoId)) { - throw new FunctionalRuntimeException( - "Organization registration should not update existing Org.ID in Zoho! Check logs for organization: " - + operation.getZohoRecord().getId()); + // verify that the organization ID was not changed if existed + if (beforeOperationZohoId != null) { + verifyOrgIdAfterRegistration(operation, registeredRecord, beforeOperationZohoId); } + } else { + // in case that the EntityRecord was not successfully created (record not available for further processing) + logger.warn("Organization registration was not completed! Check logs for organization: {}", + operation.getZohoRecord().getId()); } } return entitiesToUpdate; } + void verifyOrgIdAfterRegistration(Operation operation, Optional registeredRecord, + String beforeOperationZohoId) { + String currentEntityId = registeredRecord.get().getEntityId(); + if (beforeOperationZohoId != null && !currentEntityId.equals(beforeOperationZohoId)) { + throw new FunctionalRuntimeException( + "Organization registration should not update existing Org.ID in Zoho! Check logs for organization: " + + operation.getZohoRecord().getId() + " oldOrgId: " + beforeOperationZohoId + + " new OrgId: " + currentEntityId); + } + } + /** * registers the new organization and sets the generated organizationID in the operation * @@ -476,9 +487,9 @@ List findDupplicateOrganization(Operation operation, List existingEntities = entityRecordService.findEntitiesByCoreference(allCorefs, (String) null, excludeDisabled); - if (logger.isDebugEnabled() && !existingEntities.isEmpty()) { - logger.debug("Found existing dupplicated organization with id: {} ", - EntityRecordUtils.getEntityIds(existingEntities)); + if (logger.isInfoEnabled() && !existingEntities.isEmpty()) { + logger.info("Found existing dupplicated entity with id: {} for ZohoOrganization with id: {}", + EntityRecordUtils.getEntityIds(existingEntities), zohoOrganization.getAbout()); } return existingEntities; }