Skip to content

Commit

Permalink
corrections in StartUpTasks
Browse files Browse the repository at this point in the history
  • Loading branch information
cgeorgilakis-grnet committed Mar 11, 2024
1 parent e1e8a48 commit 93c25d4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public Stream<UserGroupMembershipExtensionEntity> getActiveByUser(String userId)
}

@Transactional
public void dailyExecutedActions(KeycloakSession session) {
public void dailyExecutedActions() {
GroupManagementEventEntity eventEntity = eventRepository.getEntity(Utils.eventId);
MemberUserAttributeConfigurationRepository memberUserAttributeConfigurationRepository = new MemberUserAttributeConfigurationRepository(session);
CustomFreeMarkerEmailTemplateProvider customFreeMarkerEmailTemplateProvider = new CustomFreeMarkerEmailTemplateProvider(session);
Expand Down Expand Up @@ -124,6 +124,7 @@ public void dailyExecutedActions(KeycloakSession session) {
pendingMembers.forEach(member -> {
member.setStatus(MemberStatusEnum.ENABLED);
update(member);
setRealm(session.realms().getRealm(member.getUser().getRealmId()));
GroupModel group = realm.getGroupById(member.getGroup().getId());
UserModel userModel = session.users().getUserById(realm, member.getUser().getId());
userModel.joinGroup(group);
Expand Down Expand Up @@ -245,7 +246,7 @@ private void clearUserAttribute(String groupName, UserModel user, MemberUserAttr
private void weeklyTaskExecution(CustomFreeMarkerEmailTemplateProvider customFreeMarkerEmailTemplateProvider, KeycloakSession session) {
session.realms().getRealmsStream().forEach(realmModel -> {
MemberUserAttributeConfigurationRepository memberUserAttributeConfigurationRepository = new MemberUserAttributeConfigurationRepository(session);
MemberUserAttributeConfigurationEntity memberUserAttribute = memberUserAttributeConfigurationRepository.getByRealm(realm.getId());
MemberUserAttributeConfigurationEntity memberUserAttribute = memberUserAttributeConfigurationRepository.getByRealm(realmModel.getId());
customFreeMarkerEmailTemplateProvider.setSignatureMessage(memberUserAttribute.getSignatureMessage());
customFreeMarkerEmailTemplateProvider.setRealm(realmModel);
String serverUrl = realm.getAttribute(Utils.KEYCLOAK_URL);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ public class GroupManagementTasks implements ScheduledTask {
@Override
public void run(KeycloakSession session) {
UserGroupMembershipExtensionRepository repository = new UserGroupMembershipExtensionRepository(session, null);
repository.dailyExecutedActions(session);
repository.dailyExecutedActions();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ public class StartUpTasks implements ScheduledTask {
@Override
public void run(KeycloakSession session) {
logger.info("Starting tasks ...");
//same as daily task (only if not executed before this day)
UserGroupMembershipExtensionRepository repository = new UserGroupMembershipExtensionRepository(session, null);
repository.dailyExecutedActions();
session.realms().getRealmsStream().forEach(realm -> {
//same as daily task (only if not executed before this day)
UserGroupMembershipExtensionRepository repository = new UserGroupMembershipExtensionRepository(session, realm);
MemberUserAttributeConfigurationRepository memberUserAttributeConfigurationRepository = new MemberUserAttributeConfigurationRepository(session);
repository.dailyExecutedActions(session);
//create default eduPersonEntitlement configuration entity if not exist
if (memberUserAttributeConfigurationRepository.getByRealm(realm.getId()).getId() == null) {
MemberUserAttributeConfigurationEntity configurationEntity = new MemberUserAttributeConfigurationEntity();
Expand Down

0 comments on commit 93c25d4

Please sign in to comment.