Skip to content

Commit

Permalink
Merge branch 'V1.7-Maintenance' of
Browse files Browse the repository at this point in the history
  • Loading branch information
gsergiu committed Feb 4, 2025
1 parent 7622ef4 commit 02d4044
Showing 1 changed file with 22 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -351,25 +351,36 @@ List<String> performEntityRegistration(SortedSet<Operation> createOperations,

Optional<EntityRecord> 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<EntityRecord> 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
*
Expand Down Expand Up @@ -476,9 +487,9 @@ List<EntityRecord> findDupplicateOrganization(Operation operation,
List<EntityRecord> 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;
}
Expand Down

0 comments on commit 02d4044

Please sign in to comment.