8641efa9 by Adam Heath

Fix entity hook processing.

1 parent 93137dec
......@@ -64,6 +64,11 @@ class HookSynchronization implements Synchronization {
newExtraParameters.putAll(extraParameters)
}
updates.put(entityToken, newExtraParameters)
if (existingExtraParameters == null) {
ec.getLogger().info("Add new synchronization for ${entityName}: [${keyValue}]")
} else {
ec.getLogger().info("Updated synchronization for ${entityName}: [${keyValue}]")
}
}
@Override
......@@ -79,8 +84,10 @@ class HookSynchronization implements Synchronization {
extraParameters: extraParameters,
])
}
if (updates) {
ec.getService().async().name("keycloak.HookServices.process#Updates").parameter('updates', updates).call()
}
}
@Override
public void afterCompletion(int status) {
......@@ -190,11 +197,6 @@ Map<String, Object> handleEntityUpdate() {
logger.info("context: ${context}")
ExecutionContext ec = context.ec
Map<String, Object> contextRoot = ec.getContextRoot()
Map<String, Set<Object>> toRegister = contextRoot['KeycloakEntityRegistrations']
logger.info("toRegister: ${toRegister}")
if (toRegister == null) {
toRegister = contextRoot['KeycloakEntityRegistrations'] = [:]
}
HookSynchronization hookSync = getHookSync()
......@@ -205,13 +207,6 @@ Map<String, Object> handleEntityUpdate() {
logger.info("processing entry: ${entry}")
String entityName = entry.entityName
Object value = entry.value
Set<Object> entityRegistrations = toRegister[entityName]
if (entityRegistrations == null) {
entityRegistrations = toRegister[entityName] = new HashSet()
entityRegistrations.add(value)
} else if (entityRegistrations.contains(value)) {
continue
}
String keyName
switch (entityName) {
case 'Party':
......@@ -245,7 +240,6 @@ Map<String, Object> handleEntityUpdate() {
keyName = 'roleTypeId'
break
}
ec.getLogger().info("Registered synchronization for ${entityName}: [${value}]")
hookSync.add(entityName, keyName, value, [:])
//ec.getService().special().name("keycloak.KeycloakServices.send#${entityName}").parameter(keyName, value).registerOnCommit()
}
......