in service/src/main/java/org/apache/fineract/cn/provisioner/internal/service/applications/IdentityServiceInitializer.java [143:168]
public List<EventExpectation> postApplicationPermittableGroups(
final @Nonnull String tenantIdentifier,
final @Nonnull String identityManagerApplicationName,
final @Nonnull String identityManagerApplicationUri,
final @Nonnull String applicationUri) {
final List<PermittableEndpoint> permittables;
try (final AutoCloseable ignored = applicationCallContextProvider.getApplicationCallGuestContext(tenantIdentifier)) {
permittables = getPermittables(applicationUri);
} catch (final Exception e) {
throw new IllegalStateException(e);
}
try (final AutoCloseable ignored
= applicationCallContextProvider.getApplicationCallContext(tenantIdentifier, identityManagerApplicationName)) {
final IdentityManager identityService = applicationCallContextProvider.getApplication(IdentityManager.class, identityManagerApplicationUri);
final Stream<PermittableGroup> permittableGroups = getPermittableGroups(permittables);
//You might look at this and wonder: "Why isn't she returning a stream here? She's just turning it back into
//a stream on the other side..."
//The answer is that you need the createOrFindPermittableGroup to be executed in the proper tenant context. If you
//return the stream, the call to createOrFindPermittableGroup will be executed when the stream is iterated over.
return permittableGroups.map(x -> createOrFindPermittableGroup(identityService, x)).collect(Collectors.toList());
} catch (final Exception e) {
throw new IllegalStateException(e);
}
}