Skip to content

Instantly share code, notes, and snippets.

@douglascrp
Created December 2, 2021 19:15
Show Gist options
  • Save douglascrp/2c46aca72d0b837e08b15c83478a0f37 to your computer and use it in GitHub Desktop.
Save douglascrp/2c46aca72d0b837e08b15c83478a0f37 to your computer and use it in GitHub Desktop.
LDAP sync fail: Job DEFAULT.ldapPeopleJobDetail threw an unhandled Exception: org.springframework.dao.DataIntegrityViolationException: No property value exists for ID
// from https://hub.alfresco.com/t5/alfresco-content-services-forum/ldap-sync-fails-after-cleanalfproptablespostexec-sql/m-p/40015/highlight/true#M2224
var context = Packages.org.springframework.web.context.ContextLoader.getCurrentWebApplicationContext();
var SyncStatus = Packages.org.alfresco.repo.security.sync.SyncStatus;
var attributeService = context.getBean('attributeService', Packages.org.alfresco.service.cmr.attributes.AttributeService);
var ROOT_ATTRIBUTE_PATH = ".ChainingUserRegistrySynchronizer";
var STATUS_ATTRIBUTE = "STATUS";
var SUMMARY_ATTRIBUTE = "SUMMARY";
var zone = "ldap1";
try {
logger.log(attributeService.getAttribute(ROOT_ATTRIBUTE_PATH, STATUS_ATTRIBUTE));
} catch(excep) {
logger.log("Missing attribute:" + ROOT_ATTRIBUTE_PATH + " " + STATUS_ATTRIBUTE + excep);
attributeService.removeAttribute(ROOT_ATTRIBUTE_PATH, STATUS_ATTRIBUTE);
attributeService.createAttribute(SyncStatus.COMPLETE_ERROR.toString() ,ROOT_ATTRIBUTE_PATH, STATUS_ATTRIBUTE);
logger.log("Created attribute");
logger.log(attributeService.getAttribute(ROOT_ATTRIBUTE_PATH, STATUS_ATTRIBUTE));
}
try {
logger.log(attributeService.getAttribute(ROOT_ATTRIBUTE_PATH, STATUS_ATTRIBUTE, zone));
} catch(excep) {
logger.log("Missing attribute:" + ROOT_ATTRIBUTE_PATH + " " + STATUS_ATTRIBUTE + " " + zone + excep);
attributeService.removeAttribute(ROOT_ATTRIBUTE_PATH, STATUS_ATTRIBUTE, zone);
attributeService.createAttribute(SyncStatus.COMPLETE_ERROR.toString() ,ROOT_ATTRIBUTE_PATH, STATUS_ATTRIBUTE, zone);
logger.log("Created attribute");
logger.log(attributeService.getAttribute(ROOT_ATTRIBUTE_PATH, STATUS_ATTRIBUTE, zone));
}
try {
logger.log(attributeService.getAttribute(ROOT_ATTRIBUTE_PATH, SUMMARY_ATTRIBUTE, zone));
} catch(excep) {
logger.log("Missing attribute:" + ROOT_ATTRIBUTE_PATH + " " + SUMMARY_ATTRIBUTE + " " + zone + excep);
attributeService.removeAttribute(ROOT_ATTRIBUTE_PATH, SUMMARY_ATTRIBUTE, zone);
logger.log("Removed attribute");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment